Skip to content

Commit 04d2594

Browse files
claudeAndriyKalashnykov
authored andcommitted
perf: optimize CI workflow for speed and concurrency
- Run docker job in parallel with build-and-test (no dependency) - Add concurrency group to cancel superseded runs - Remove redundant actions/cache (gradle/actions/setup-gradle handles it) - Remove sdkman setup (JDK from setup-java, Gradle from wrapper) - Consolidate 5 Gradle invocations into single ./gradlew clean build jacocoTestCoverageVerification (build task already runs lint + tests) - Update ci-validator agent and CLAUDE.md to match
1 parent 476b848 commit 04d2594

3 files changed

Lines changed: 27 additions & 48 deletions

File tree

.claude/agents/ci-validator.md

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,17 @@ Validate CI pipeline steps locally before pushing to prevent CI failures. Mirror
1313

1414
## GitHub Actions Workflow (`.github/workflows/ci.yml`)
1515

16-
The CI pipeline runs on push/PR to `main` with these steps:
16+
The CI pipeline runs on push/PR to `main`. Uses `concurrency` to cancel superseded runs. Two jobs run **in parallel**:
1717

1818
### Job: build-and-test
1919
1. Checkout repository
2020
2. Set up JDK 21 (IBM Semeru)
21-
3. Setup Gradle
22-
4. Cache Gradle dependencies
23-
5. Validate Gradle wrapper
24-
6. Setup sdkman
25-
7. **Build**: `make clean build`
26-
8. **Lint**: `make lint`
27-
9. **Test**: `make test`
28-
10. **Coverage**: `make coverage-check`
29-
11. **Run**: `make run`
30-
31-
### Job: docker (needs: build-and-test)
21+
3. Setup Gradle (includes caching)
22+
4. Validate Gradle wrapper
23+
5. **Build, lint, test, coverage**: `./gradlew clean build jacocoTestCoverageVerification` (single invocation)
24+
6. **Run**: `./gradlew :app:run --no-configuration-cache`
25+
26+
### Job: docker (runs in parallel)
3227
1. Checkout repository
3328
2. Setup Docker Buildx
3429
3. **Build image**: `make docker-build`
@@ -44,15 +39,16 @@ CI Step 4/5: Coverage -> ./gradlew jacocoTestReport jacocoTestCoverageVerificati
4439
CI Step 5/5: Run -> ./gradlew :app:run
4540
```
4641

42+
Note: `make ci` runs steps individually for clearer output. The GitHub workflow consolidates build+lint+test+coverage into a single Gradle invocation for speed.
43+
4744
## Diagnosing CI Failures
4845

49-
1. **sdkman setup**: ensure `$HOME/.sdkman/bin/sdkman-init.sh` exists
50-
2. **Gradle wrapper validation**: ensure `gradle/wrapper/gradle-wrapper.jar` is genuine
51-
3. **Cache issues**: clean with `make clean` then rebuild
52-
4. **Checkstyle violations**: run `make lint` to see style issues
53-
5. **Test failures**: run `make test` with `--info` for details
54-
6. **Coverage below 60%**: run `make coverage-generate` and check the HTML report
55-
7. **Docker build fails**: check Dockerfile, base image availability
46+
1. **Gradle wrapper validation**: ensure `gradle/wrapper/gradle-wrapper.jar` is genuine
47+
2. **Cache issues**: clean with `make clean` then rebuild
48+
3. **Checkstyle violations**: run `make lint` to see style issues
49+
4. **Test failures**: run `make test` with `--info` for details
50+
5. **Coverage below 60%**: run `make coverage-generate` and check the HTML report
51+
6. **Docker build fails**: check Dockerfile, base image availability
5652

5753
## Workflow
5854

.github/workflows/ci.yml

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
pull_request:
99
branches: [ main ]
1010

11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
1115
jobs:
1216
build-and-test:
1317

@@ -26,36 +30,14 @@ jobs:
2630
- name: Setup Gradle
2731
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5
2832

29-
# Cache Gradle dependencies and build outputs to speed up future builds
30-
- name: Cache Gradle and build outputs
31-
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
32-
with:
33-
path: |
34-
~/.gradle/caches
35-
~/.gradle/wrapper
36-
build
37-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
38-
restore-keys: ${{ runner.os }}-gradle-
39-
4033
- name: Validate Gradle wrapper
4134
uses: gradle/actions/wrapper-validation@0723195856401067f7a2779048b490ace7a47d7c # v5
4235

43-
- uses: sfesenko/setup-sdkman@c360e935fffb3cfa33eddd5748464329240cfd89 # v1
44-
45-
- name: Build
46-
run: make clean build
47-
48-
- name: Lint
49-
run: make lint
50-
51-
- name: Test
52-
run: make test
53-
54-
- name: Verify code coverage meets minimum threshold ( > 60%)
55-
run: make coverage-check
36+
- name: Build, lint, test, and verify coverage
37+
run: ./gradlew clean build jacocoTestCoverageVerification
5638

5739
- name: Run
58-
run: make run
40+
run: ./gradlew :app:run --no-configuration-cache --warning-mode all
5941

6042
- name: Upload test results
6143
if: always()
@@ -77,7 +59,6 @@ jobs:
7759
retention-days: 14
7860

7961
docker:
80-
needs: build-and-test
8162
runs-on: ubuntu-latest
8263

8364
steps:

CLAUDE.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ Configure push target with environment variables:
8383
## CI
8484

8585
GitHub Actions (`.github/workflows/ci.yml`):
86-
- **build-and-test** job: builds, lints, tests, verifies coverage, and runs the app on every push/PR to `main`
87-
- **docker** job: builds Docker image after tests pass, conditionally pushes on main branch merge
86+
- **build-and-test** job: single `./gradlew clean build jacocoTestCoverageVerification` invocation (build + lint + test + coverage), then runs the app
87+
- **docker** job: builds Docker image **in parallel** with build-and-test, conditionally pushes on main branch merge
88+
- **concurrency**: superseded runs on the same branch are automatically cancelled
89+
- No sdkman in CI — JDK via `actions/setup-java`, Gradle via `gradle/actions/setup-gradle` (includes caching)
8890

89-
Run CI locally before pushing: `make ci` (mirrors the build-and-test job exactly)
91+
Run CI locally before pushing: `make ci` (mirrors the build-and-test job)
9092
Run CI with Docker: `make ci-docker`
9193

9294
## Claude Code Agent Team

0 commit comments

Comments
 (0)