|
| 1 | +name: Build |
| 2 | + |
| 3 | +# `check` runs on every branch push (not just PRs) for ad-hoc debugging; publication is gated |
| 4 | +# to the protected branches (the `publish` job). |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: ["**"] |
| 8 | + pull_request: |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + publish_build_scan: |
| 12 | + description: "Publish a Develocity build scan (scans.gradle.com) for this run" |
| 13 | + type: boolean |
| 14 | + default: false |
| 15 | + |
| 16 | +# Supersede in-flight runs of the same ref. |
| 17 | +concurrency: |
| 18 | + group: build-${{ github.ref }} |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +permissions: |
| 22 | + contents: read |
| 23 | + |
| 24 | +env: |
| 25 | + # Heap budget on linux-arm64-xlarge (16 vCPU / 64 GiB). Concurrent test JVMs are capped at |
| 26 | + # --max-workers — each Test task is maxParallelForks=1 (one fork per task), and junitParallelThreads |
| 27 | + # is in-JVM ForkJoinPool parallelism, not extra JVMs — so the test footprint can't exceed 8 x 4g. |
| 28 | + # Peak: Gradle daemon 12g + Kotlin daemon 6g + 8 test forks x 4g = 50g heap (~60g resident with JVM |
| 29 | + # overhead), leaving room for native Postgres + OS. Native Postgres (no dockerd/DIND) on the 600 GB |
| 30 | + # SSD gives more margin than a tmpfs PGDATA would. If the peak ever OOMs, drop to --max-workers=7. |
| 31 | + GRADLE_FLAGS: >- |
| 32 | + -Dorg.gradle.caching=true |
| 33 | + --max-workers=8 |
| 34 | + -Dorg.gradle.jvmargs=-Xmx12g |
| 35 | + -Pkotlin.daemon.jvmargs=-Xmx6g |
| 36 | + -PtestJvmMaxHeap=4g |
| 37 | + -PjunitParallelThreads=4 |
| 38 | + POSTCHAIN_DB_URL: jdbc:postgresql://localhost:5432/postchain |
| 39 | + JACOCO_REPORT_DIR: coverage-report-aggregate/build/reports/jacoco/testCodeCoverageReport |
| 40 | + |
| 41 | +jobs: |
| 42 | + build: |
| 43 | + name: Check + coverage |
| 44 | + # jacoco-report posts coverage as a PR comment (or a commit comment on push). |
| 45 | + permissions: |
| 46 | + contents: write |
| 47 | + pull-requests: write |
| 48 | + runs-on: linux-arm64-xlarge |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v4 |
| 51 | + - uses: ./.github/actions/gradle-setup |
| 52 | + - uses: ./.github/actions/postgres |
| 53 | + |
| 54 | + # The Develocity plugin is deliberately not committed (so local devs neither pull it nor have |
| 55 | + # its Terms of Use auto-accepted), and termsOfUseAgree can only be expressed from a DSL block — |
| 56 | + # hence appending it at runtime. Manual-dispatch only (the input is empty on push/PR). |
| 57 | + - name: Enable build scan |
| 58 | + if: github.event.inputs.publish_build_scan == 'true' |
| 59 | + run: | |
| 60 | + cat >> settings.gradle.kts <<'EOF' |
| 61 | +
|
| 62 | + plugins { id("com.gradle.develocity") version "4.3.2" } |
| 63 | +
|
| 64 | + develocity { |
| 65 | + buildScan { |
| 66 | + termsOfUseUrl = "https://gradle.com/help/legal-terms-of-use" |
| 67 | + termsOfUseAgree = "yes" |
| 68 | + uploadInBackground = false |
| 69 | + } |
| 70 | + } |
| 71 | + EOF |
| 72 | +
|
| 73 | + - name: Check + aggregate coverage |
| 74 | + run: ./gradlew $GRADLE_FLAGS check :coverage-report-aggregate:testCodeCoverageReport |
| 75 | + |
| 76 | + - name: Coverage report |
| 77 | + if: always() |
| 78 | + uses: madrapps/jacoco-report@v1.7.2 |
| 79 | + with: |
| 80 | + paths: ${{ env.JACOCO_REPORT_DIR }}/testCodeCoverageReport.xml |
| 81 | + token: ${{ github.token }} |
| 82 | + title: Coverage |
| 83 | + |
| 84 | + - name: Upload test results |
| 85 | + if: always() |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: test-results |
| 89 | + path: | |
| 90 | + ${{ env.JACOCO_REPORT_DIR }}/ |
| 91 | + **/build/test-results/**/* |
| 92 | + retention-days: 7 |
| 93 | + if-no-files-found: ignore |
| 94 | + |
| 95 | + # Gated continuation of `build`: runs only after tests+coverage pass, and only on the protected |
| 96 | + # branches. Publishing to the GitLab Package Registry (gitlab.com project 32802097) compiles and |
| 97 | + # assembles the jars but runs no tests, so it needs neither `check` nor Postgres here. |
| 98 | + publish: |
| 99 | + name: Publish to GitLab Packages |
| 100 | + needs: build |
| 101 | + if: >- |
| 102 | + github.event_name == 'push' && |
| 103 | + (github.ref == 'refs/heads/dev' || |
| 104 | + github.ref == 'refs/heads/master' || |
| 105 | + startsWith(github.ref, 'refs/heads/version-')) |
| 106 | + runs-on: linux-arm64-xlarge |
| 107 | + steps: |
| 108 | + - uses: actions/checkout@v4 |
| 109 | + - uses: ./.github/actions/gradle-setup |
| 110 | + |
| 111 | + # Auth via ORG_GRADLE_PROJECT_* (Gradle reads them as the gitlabAuthHeaderName/Value project |
| 112 | + # properties) rather than -P flags, so the token never lands on the command line. |
| 113 | + - name: Publish |
| 114 | + env: |
| 115 | + ORG_GRADLE_PROJECT_gitlabAuthHeaderName: Private-Token |
| 116 | + ORG_GRADLE_PROJECT_gitlabAuthHeaderValue: ${{ secrets.GITLAB_PUBLISH_TOKEN }} |
| 117 | + run: ./gradlew $GRADLE_FLAGS publish |
0 commit comments