diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..75c5ac7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,84 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + detect: + name: Detect demos to build + runs-on: ubuntu-latest + outputs: + demos: ${{ steps.detect.outputs.demos }} + any: ${{ steps.detect.outputs.any }} + steps: + - uses: actions/checkout@v4 + with: + # PRs need full history to diff against the base branch. + fetch-depth: ${{ github.event_name == 'pull_request' && 0 || 1 }} + + - id: detect + name: Determine which demos to build + shell: bash + run: | + set -euo pipefail + + # A "demo" is any top-level directory containing a build.gradle.kts. + mapfile -t all_demos < <(find . -mindepth 2 -maxdepth 2 -name 'build.gradle.kts' -not -path './.*' -printf '%h\n' | sed 's|^\./||' | sort -u) + + if [ "${{ github.event_name }}" = "pull_request" ]; then + # Build only demos whose files changed in this PR. + base="${{ github.event.pull_request.base.sha }}" + mapfile -t changed_files < <(git diff --name-only "$base" HEAD) + demos_to_build=() + for d in "${all_demos[@]}"; do + for f in "${changed_files[@]}"; do + if [[ "$f" == "$d/"* ]]; then + demos_to_build+=("$d") + break + fi + done + done + else + # Push to main: build everything (catches drift from external bumps). + demos_to_build=("${all_demos[@]}") + fi + + if [ ${#demos_to_build[@]} -eq 0 ]; then + echo "No demos to build." + echo "demos=[]" >> "$GITHUB_OUTPUT" + echo "any=false" >> "$GITHUB_OUTPUT" + else + printf 'Demos to build:\n' + printf ' - %s\n' "${demos_to_build[@]}" + demos_json=$(printf '%s\n' "${demos_to_build[@]}" | jq -R . | jq -s -c .) + echo "demos=$demos_json" >> "$GITHUB_OUTPUT" + echo "any=true" >> "$GITHUB_OUTPUT" + fi + + build: + name: Build ${{ matrix.demo }} + needs: detect + if: needs.detect.outputs.any == 'true' + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + demo: ${{ fromJson(needs.detect.outputs.demos) }} + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + + - uses: gradle/actions/setup-gradle@v4 + + - name: Build + working-directory: ${{ matrix.demo }} + run: ./gradlew build --no-daemon diff --git a/.github/workflows/proof-html.yml b/.github/workflows/proof-html.yml deleted file mode 100644 index be7dac3..0000000 --- a/.github/workflows/proof-html.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: Proof HTML -on: - push: - workflow_dispatch: -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: anishathalye/proof-html@v1.1.0 - with: - directory: ./ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9c26ad8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +# Gradle +.gradle/ +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +# IntelliJ IDEA +.idea/ +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +# Eclipse / STS +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +# VS Code +.vscode/ + +# NetBeans +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +# OS +.DS_Store +Thumbs.db + +# Logs +*.log diff --git a/README.md b/README.md index ccbefa2..24978b3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,29 @@ -# Welcome to your organization's demo respository -This code repository (or "repo") is designed to demonstrate the best GitHub has to offer with the least amount of noise. +# devslab-examples -The repo includes an `index.html` file (so it can render a web page), two GitHub Actions workflows, and a CSS stylesheet dependency. +Runnable examples for [devslab-kr](https://github.com/devslab-kr) Spring Boot starters and libraries. + +Each subdirectory is an **independent** Spring Boot application with its own Gradle build. Pick one, `cd` into it, and run `./gradlew bootRun`. + +## Examples + +| Demo | Showcases | Maven Central coordinates | +| --- | --- | --- | +| _(none yet — first demo coming in a follow-up PR)_ | — | — | + +## Conventions + +- Each demo is a **standalone Gradle project** — its own `settings.gradle.kts`, `build.gradle.kts`, and `gradlew`. Demos do not share a root build, so their dependency versions and JDK targets can drift independently. +- Each demo depends on the **latest stable release** of the starter it showcases (pinned by version in `build.gradle.kts`). Dependabot bumps it on new releases. +- This repo is **not versioned or tagged** — demos are not published artifacts. `main` is the source of truth. +- Each demo has its own `README.md` with quickstart, prerequisites, and a tour of what the starter is doing. + +## Adding a new demo + +1. Create `-demo/` at the repo root. +2. Copy the layout of an existing demo (e.g. `easy-paging-demo/`) as a template. +3. Add a row to the table above linking to the demo and to its starter on Maven Central. +4. CI auto-detects the new demo from the presence of `build.gradle.kts` — no workflow changes needed. + +## CI + +Pull requests build only the demos whose files changed. Pushes to `main` build every demo (catches drift from starter version bumps). diff --git a/index.html b/index.html deleted file mode 100644 index 58c945b..0000000 --- a/index.html +++ /dev/null @@ -1 +0,0 @@ -

Welcome to the website generated by my demo repository

diff --git a/package.json b/package.json deleted file mode 100644 index 40427d6..0000000 --- a/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "demo-repo", - "version": "0.2.0", - "description": "A sample package.json", - "dependencies": { - "@primer/css": "17.0.1" - }, - "license": "MIT" -}