Repository navigation
236 lines (206 loc) · 9.47 KB
/
Copy pathci.yml
File metadata and controls
236 lines (206 loc) · 9.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
name: CI
on:
workflow_dispatch:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
schedule:
# 21:13 PST / 22:13 PDT, matching the CodeQL nightly schedule.
- cron: '13 5 * * *'
concurrency:
# Only newer revisions of the same PR supersede an existing run.
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build-checks:
if: github.event_name != 'schedule'
# we want to run ubuntu-latest but we'll pin to a specific version so workflow is reproducable
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Set up JDK 17
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0
with:
java-version: 17
distribution: 'temurin'
- name: Restore Gradle state
id: gradle-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
# Successful PR and default-branch jobs can add dependencies and task results.
key: gradle-ci-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
gradle-ci-v1-${{ runner.os }}-${{ runner.arch }}-
- name: Setup Gradle
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
with:
cache-disabled: true
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run all checks and tests
run: ./gradlew compileTestJava publishToMavenLocal check
- name: Save Gradle state
if: success() && (github.event_name == 'pull_request' || github.ref == format('refs/heads/{0}', github.event.repository.default_branch)) && steps.gradle-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ steps.gradle-cache.outputs.cache-primary-key }}
- name: Show workspace changes after failure
if: failure()
run: |
git status --porcelain
git diff --no-ext-diff
git diff --no-ext-diff --cached
- name: Upload test results
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: always()
with:
name: test-results
path: '**/build/test-results/test/'
build-logic:
name: Build logic tests
if: github.event_name != 'schedule'
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
- name: Set up JDK 17
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0
with:
java-version: 17
distribution: 'temurin'
- name: Restore build-logic Gradle state
id: gradle-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
# Separate ownership: parallel jobs must not compete to save the same key.
key: gradle-build-logic-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
gradle-build-logic-v1-${{ runner.os }}-${{ runner.arch }}-
- name: Setup Gradle
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
with:
cache-disabled: true
- name: Test build logic
# Standalone buildSrc does not inherit the root project's caching setting.
run: ./gradlew -p buildSrc test --build-cache --no-configuration-cache
- name: Save build-logic Gradle state
if: success() && (github.event_name == 'pull_request' || github.ref == format('refs/heads/{0}', github.event.repository.default_branch)) && steps.gradle-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ steps.gradle-cache.outputs.cache-primary-key }}
- name: Upload build-logic test results
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: always()
with:
name: build-logic-test-results
path: 'buildSrc/build/test-results/test/'
# Preserve the existing required status check while the expensive jobs overlap.
build:
needs: [ build-checks, build-logic ]
# A skipped required check can permit merging; cancelled dependencies must fail this gate.
if: always() && github.event_name != 'schedule'
runs-on: ubuntu-24.04
permissions: {}
steps:
- name: Require both build jobs to pass
env:
CHECKS_RESULT: ${{ needs.build-checks.result }}
LOGIC_RESULT: ${{ needs.build-logic.result }}
run: |
if [ "$CHECKS_RESULT" != 'success' ] || [ "$LOGIC_RESULT" != 'success' ]; then
echo "::error::Build checks: $CHECKS_RESULT; build-logic tests: $LOGIC_RESULT"
exit 1
fi
dependency-check:
name: Dependency advisories
if: github.event_name == 'pull_request' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
- name: Set up JDK 17
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0
with:
java-version: 17
distribution: 'temurin'
- name: Restore advisory Gradle downloads
id: gradle-downloads
# Only this job's downloads; never restore the full build's muzzle/task outputs.
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.gradle/caches/modules-2
~/.gradle/caches/*/generated-gradle-jars
~/.gradle/wrapper
key: gradle-advisory-downloads-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/*.gradle', '**/gradle.properties', 'gradle/wrapper/gradle-wrapper.properties', 'buildSrc/src/main/**', '.github/dependency-graph.json') }}
restore-keys: |
gradle-advisory-downloads-v1-${{ runner.os }}-${{ runner.arch }}-
- name: Setup Gradle
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
with:
cache-disabled: true
- name: Check shipped dependencies
id: dependencies
# Fresh batched requests: GITHUB_TOKEN changes each job, invalidating prior ETags.
env:
GH_TOKEN: ${{ github.token }}
run: |
rm -f build/dependency-advisories/complete
./gradlew checkDependencies --refresh-dependencies --console=plain --no-configuration-cache
- name: Identify complete advisory scan
id: advisory-scan
if: always() && (steps.dependencies.outcome == 'success' || steps.dependencies.outcome == 'failure')
run: |
if [ -f build/dependency-advisories/complete ] && [ -f build/dependency-advisories/cache.json ]; then
echo 'scan-complete=true' >> "$GITHUB_OUTPUT"
fi
- name: Save advisory Gradle downloads
# A completed scan with findings may save downloads, but still fails the job.
if: always() && steps.advisory-scan.outputs.scan-complete == 'true' && steps.gradle-downloads.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.gradle/caches/modules-2
~/.gradle/caches/*/generated-gradle-jars
~/.gradle/wrapper
key: ${{ steps.gradle-downloads.outputs.cache-primary-key }}
- name: Report dependency scan outcome
if: always()
env:
SCAN_OUTCOME: ${{ steps.dependencies.outcome }}
SCAN_COMPLETE: ${{ steps.advisory-scan.outputs.scan-complete }}
run: |
echo '## Dependency advisories' >> "$GITHUB_STEP_SUMMARY"
if [ "$SCAN_OUTCOME" = 'success' ] && [ "$SCAN_COMPLETE" = 'true' ]; then
echo 'The live scan completed; no matching GitHub-reviewed advisories were found in shipped dependencies.' >> "$GITHUB_STEP_SUMMARY"
elif [ "$SCAN_COMPLETE" = 'true' ]; then
echo '::error::Dependency scan found advisories. Review the Check shipped dependencies step logs.'
echo 'The live scan completed and found advisories. Review the **Check shipped dependencies** step logs; this is not a clean scan.' >> "$GITHUB_STEP_SUMMARY"
else
echo '::error::Dependency scan could not complete. Review the job logs.'
echo 'The scan could not complete. No new Gradle download snapshot was saved; this is not a clean scan. Review the job logs.' >> "$GITHUB_STEP_SUMMARY"
fi
echo 'This check covers the full shipped dependency graph, not just dependencies changed by this PR. Findings or scan errors fail the check.' >> "$GITHUB_STEP_SUMMARY"
echo 'Every CI run makes fresh batched advisory requests; responses are not cached across jobs because GitHub scopes ETags to the per-job token.' >> "$GITHUB_STEP_SUMMARY"
if [ "$SCAN_OUTCOME" != 'success' ] || [ "$SCAN_COMPLETE" != 'true' ]; then
exit 1
fi