From 763afdc546b8ea88a69ba9d038fccb9b41d58e04 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 12 Mar 2025 21:03:40 +0100 Subject: [PATCH 1/4] ci: update CI workflows to include path filters --- .gitea/workflows/ci.yml | 8 ++++++++ .gitea/workflows/release.yml | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index a19b587..0a64d78 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -2,10 +2,15 @@ name: CI on: pull_request: + paths: + - 'backend/**' + - 'frontend/**' + - '.gitea/workflows/ci.yml' jobs: checkstyle: name: "Checkstyle Main" + if: ${{ contains(github.event.pull_request.changed_files_json, 'backend/') || contains(github.event.pull_request.changed_files_json, '.gitea/workflows/ci.yml') }} container: image: "cimg/openjdk:23.0-node" steps: @@ -32,6 +37,7 @@ jobs: eslint: name: eslint + if: ${{ contains(github.event.pull_request.changed_files_json, 'frontend/') || contains(github.event.pull_request.changed_files_json, '.gitea/workflows/ci.yml') }} container: image: catthehacker/ubuntu:act-latest steps: @@ -58,6 +64,7 @@ jobs: prettier: name: prettier + if: ${{ contains(github.event.pull_request.changed_files_json, 'frontend/') || contains(github.event.pull_request.changed_files_json, '.gitea/workflows/ci.yml') }} container: image: catthehacker/ubuntu:act-latest steps: @@ -84,6 +91,7 @@ jobs: test-build: name: test-build + if: ${{ contains(github.event.pull_request.changed_files_json, 'frontend/') || contains(github.event.pull_request.changed_files_json, '.gitea/workflows/ci.yml') }} container: image: catthehacker/ubuntu:act-latest steps: diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 596c53d..ab95401 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -3,6 +3,11 @@ on: push: branches: - "main" + paths: + - 'backend/**' + - 'frontend/**' + - '.gitea/workflows/release.yml' + - 'release.config.cjs' env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} From db37f0de35f8b2b20e18e4e5fcdc6f2fec8bf2eb Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 12 Mar 2025 21:05:03 +0100 Subject: [PATCH 2/4] chore: add new file a to the backend directory --- backend/a | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 backend/a diff --git a/backend/a b/backend/a new file mode 100644 index 0000000..e69de29 From fd7c92ebb161049764313fd1148171eb3e7a8a51 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 12 Mar 2025 21:06:25 +0100 Subject: [PATCH 3/4] ci: update CI workflow to check for changed files --- .gitea/workflows/ci.yml | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 0a64d78..792fca9 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -2,15 +2,33 @@ name: CI on: pull_request: - paths: - - 'backend/**' - - 'frontend/**' - - '.gitea/workflows/ci.yml' jobs: + changed_files: + name: Get Changed Files + runs-on: ubuntu-latest + outputs: + backend: ${{ steps.filter.outputs.backend }} + frontend: ${{ steps.filter.outputs.frontend }} + workflow: ${{ steps.filter.outputs.workflow }} + steps: + - uses: actions/checkout@v4 + - name: Check for file changes + uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + backend: + - 'backend/**' + frontend: + - 'frontend/**' + workflow: + - '.gitea/workflows/**' + checkstyle: name: "Checkstyle Main" - if: ${{ contains(github.event.pull_request.changed_files_json, 'backend/') || contains(github.event.pull_request.changed_files_json, '.gitea/workflows/ci.yml') }} + needs: changed_files + if: ${{ needs.changed_files.outputs.backend == 'true' || needs.changed_files.outputs.workflow == 'true' }} container: image: "cimg/openjdk:23.0-node" steps: @@ -37,7 +55,8 @@ jobs: eslint: name: eslint - if: ${{ contains(github.event.pull_request.changed_files_json, 'frontend/') || contains(github.event.pull_request.changed_files_json, '.gitea/workflows/ci.yml') }} + needs: changed_files + if: ${{ needs.changed_files.outputs.frontend == 'true' || needs.changed_files.outputs.workflow == 'true' }} container: image: catthehacker/ubuntu:act-latest steps: @@ -64,7 +83,8 @@ jobs: prettier: name: prettier - if: ${{ contains(github.event.pull_request.changed_files_json, 'frontend/') || contains(github.event.pull_request.changed_files_json, '.gitea/workflows/ci.yml') }} + needs: changed_files + if: ${{ needs.changed_files.outputs.frontend == 'true' || needs.changed_files.outputs.workflow == 'true' }} container: image: catthehacker/ubuntu:act-latest steps: @@ -91,7 +111,8 @@ jobs: test-build: name: test-build - if: ${{ contains(github.event.pull_request.changed_files_json, 'frontend/') || contains(github.event.pull_request.changed_files_json, '.gitea/workflows/ci.yml') }} + needs: changed_files + if: ${{ needs.changed_files.outputs.frontend == 'true' || needs.changed_files.outputs.workflow == 'true' }} container: image: catthehacker/ubuntu:act-latest steps: From 0227146da79a9973ae3c7234f0c50eb387fc9852 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 12 Mar 2025 21:08:49 +0100 Subject: [PATCH 4/4] ci: improve checkstyle report caching in CI workflow --- .gitea/workflows/ci.yml | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 792fca9..b0b2c79 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -40,16 +40,36 @@ jobs: path: | ~/.gradle/caches ~/.gradle/wrapper - key: gradle-${{ runner.os }}-common + backend/build/reports/checkstyle + key: gradle-${{ runner.os }}-${{ hashFiles('backend/**/*.java', 'backend/config/checkstyle/checkstyle.xml') }} restore-keys: | gradle-${{ runner.os }}- - - name: "Prepare Gradle" + - name: "Check cache for checkstyle reports" + id: check-cache + run: | + if [ -d "backend/build/reports/checkstyle" ] && [ -f "backend/build/reports/checkstyle/main.xml" ]; then + echo "Cache hit! Using cached checkstyle results" + echo "cache-hit=true" >> $GITHUB_OUTPUT + else + echo "Cache miss! Running checkstyle check" + echo "cache-hit=false" >> $GITHUB_OUTPUT + fi + + - name: "Run checkstyle" + if: steps.check-cache.outputs.cache-hit != 'true' working-directory: ./backend - run: gradle clean - - name: "Check" - working-directory: ./backend - run: gradle checkstyleMain + run: | + gradle checkstyleMain + + - name: "Cache checkstyle results" + if: steps.check-cache.outputs.cache-hit != 'true' + uses: actions/upload-artifact@v4 + with: + name: checkstyle-results + path: backend/build/reports/checkstyle + - name: "Stop Gradle" + if: steps.check-cache.outputs.cache-hit != 'true' working-directory: ./backend run: gradle --stop