|
| 1 | +name: Main |
| 2 | + |
| 3 | +# Runs only on push to main (i.e. when a PR is merged or someone pushes |
| 4 | +# directly). This is where the full forward-compat JDK matrix runs and |
| 5 | +# where we record the coverage baseline that PR runs compare against. |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: ['main'] |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + |
| 13 | +# Don't cancel main runs against each other — we want every merge to |
| 14 | +# produce a coverage baseline. Sequential is fine; main pushes are rare. |
| 15 | +concurrency: |
| 16 | + group: main |
| 17 | + cancel-in-progress: false |
| 18 | + |
| 19 | +jobs: |
| 20 | + verify: |
| 21 | + name: Verify (JDK ${{ matrix.java }}) |
| 22 | + runs-on: ubuntu-latest |
| 23 | + strategy: |
| 24 | + # Don't cancel siblings: if JDK 21 fails, we still want to know |
| 25 | + # whether 17 and 25 pass. |
| 26 | + fail-fast: false |
| 27 | + matrix: |
| 28 | + # ADR-002: tests run on JDK 17, 21, 25 to catch forward-compat |
| 29 | + # regressions. Compilation is always pinned to --release 17. |
| 30 | + java: ['17', '21', '25'] |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Checkout |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + # Install both JDK 17 (for compilation) and the matrix JDK (for |
| 37 | + # test execution). setup-java exports JAVA_HOME_<version>_<arch>; |
| 38 | + # Gradle's toolchain auto-detection picks them up. |
| 39 | + - name: Set up JDKs (compile=17, test=${{ matrix.java }}) |
| 40 | + uses: actions/setup-java@v4 |
| 41 | + with: |
| 42 | + distribution: temurin |
| 43 | + java-version: | |
| 44 | + 17 |
| 45 | + ${{ matrix.java }} |
| 46 | +
|
| 47 | + - name: Set up Gradle |
| 48 | + uses: gradle/actions/setup-gradle@v4 |
| 49 | + |
| 50 | + - name: Build, test, lint, coverage |
| 51 | + run: ./gradlew build -PtestJdk=${{ matrix.java }} --stacktrace |
| 52 | + |
| 53 | + - name: Upload test reports on failure |
| 54 | + if: failure() |
| 55 | + uses: actions/upload-artifact@v4 |
| 56 | + with: |
| 57 | + name: test-reports-jdk${{ matrix.java }} |
| 58 | + path: | |
| 59 | + build/reports/tests/ |
| 60 | + build/test-results/ |
| 61 | + retention-days: 14 |
| 62 | + |
| 63 | + # The JDK 17 entry of the matrix is the canonical run for coverage |
| 64 | + # baseline purposes — its JaCoCo XML is what PR runs compare against. |
| 65 | + - name: Extract coverage baseline (JDK 17 only) |
| 66 | + if: success() && matrix.java == '17' |
| 67 | + run: | |
| 68 | + python3 .github/scripts/extract-coverage.py > coverage-baseline.txt |
| 69 | + echo "Baseline coverage: $(cat coverage-baseline.txt)" |
| 70 | +
|
| 71 | + - name: Save coverage baseline to cache (JDK 17 only) |
| 72 | + if: success() && matrix.java == '17' |
| 73 | + uses: actions/cache/save@v4 |
| 74 | + with: |
| 75 | + path: coverage-baseline.txt |
| 76 | + # Unique per commit so each main run produces a fresh entry; |
| 77 | + # PR workflow restores via prefix-match on `coverage-baseline-main-`. |
| 78 | + key: coverage-baseline-main-${{ github.sha }} |
| 79 | + |
| 80 | + - name: Upload coverage report (JDK 17 only) |
| 81 | + if: success() && matrix.java == '17' |
| 82 | + uses: actions/upload-artifact@v4 |
| 83 | + with: |
| 84 | + name: jacoco-report |
| 85 | + path: build/reports/jacoco/test/ |
| 86 | + retention-days: 14 |
| 87 | + |
| 88 | + # Integration-tests job is intentionally not wired up yet: |
| 89 | + # SDK requirements §13 says they run on PRs and release pipelines, but |
| 90 | + # they hit the live API and require a MARKETDATA_TOKEN secret. Add this |
| 91 | + # job (gated on `if: ${{ secrets.MARKETDATA_TOKEN != '' }}`) once the |
| 92 | + # token is configured in the repo's GitHub Actions secrets. |
0 commit comments