@@ -226,6 +226,97 @@ jobs:
226226 with :
227227 name : build-scan-data-${{ matrix.rdbms }}
228228 path : ~/.gradle/build-scan-data
229+ - name : Upload test reports (if Gradle failed)
230+ uses : actions/upload-artifact@v4
231+ if : failure()
232+ with :
233+ name : test-reports-java11-${{ matrix.rdbms }}
234+ path : |
235+ ./**/target/reports/tests/
236+ - name : Omit produced artifacts from build cache
237+ run : ./ci/before-cache.sh
238+
239+ # Static code analysis check
240+ format_checks :
241+ permissions :
242+ contents : read
243+ name : Static code analysis
244+ runs-on : ubuntu-latest
245+ strategy :
246+ fail-fast : false
247+ steps :
248+ - uses : actions/checkout@v4
249+ with :
250+ persist-credentials : false
251+ - name : Reclaim disk space and sanitize user home
252+ run : .github/ci-prerequisites-atlas.sh
253+ - name : Set up Java 17
254+ uses : actions/setup-java@v4
255+ with :
256+ distribution : ' temurin'
257+ java-version : ' 17'
258+
259+ - name : Generate cache key
260+ id : cache-key
261+ run : |
262+ CURRENT_BRANCH="${{ github.repository != 'hibernate/hibernate-orm' && 'fork' || github.base_ref || github.ref_name }}"
263+ CURRENT_MONTH=$(/bin/date -u "+%Y-%m")
264+ CURRENT_DAY=$(/bin/date -u "+%d")
265+ ROOT_CACHE_KEY="buildtool-cache-atlas"
266+ echo "buildtool-monthly-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}" >> $GITHUB_OUTPUT
267+ echo "buildtool-monthly-branch-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}-${CURRENT_BRANCH}" >> $GITHUB_OUTPUT
268+ echo "buildtool-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}-${CURRENT_BRANCH}-${CURRENT_DAY}" >> $GITHUB_OUTPUT
269+ - name : Cache Maven/Gradle Dependency/Dist Caches
270+ id : cache-maven
271+ uses : actions/cache@v4
272+ # if it's not a pull request, we restore and save the cache
273+ if : github.event_name != 'pull_request'
274+ with :
275+ path : |
276+ ~/.m2/repository/
277+ ~/.m2/wrapper/
278+ ~/.gradle/caches/modules-2
279+ ~/.gradle/wrapper/
280+ # A new cache will be stored daily. After that first store of the day, cache save actions will fail because the cache is immutable but it's not a problem.
281+ # The whole cache is dropped monthly to prevent unlimited growth.
282+ # The cache is per branch but in case we don't find a branch for a given branch, we will get a cache from another branch.
283+ key : ${{ steps.cache-key.outputs.buildtool-cache-key }}
284+ restore-keys : |
285+ ${{ steps.cache-key.outputs.buildtool-monthly-branch-cache-key }}-
286+ ${{ steps.cache-key.outputs.buildtool-monthly-cache-key }}-
287+ - name : Restore Maven/Gradle Dependency/Dist Caches
288+ uses : actions/cache/restore@v4
289+ # if it a pull request, we restore the cache but we don't save it
290+ if : github.event_name == 'pull_request'
291+ with :
292+ path : |
293+ ~/.m2/repository/
294+ ~/.m2/wrapper/
295+ ~/.gradle/caches/modules-2
296+ ~/.gradle/wrapper/
297+ key : ${{ steps.cache-key.outputs.buildtool-cache-key }}
298+ restore-keys : |
299+ ${{ steps.cache-key.outputs.buildtool-monthly-branch-cache-key }}-
300+ ${{ steps.cache-key.outputs.buildtool-monthly-cache-key }}-
301+
302+ - name : Run build script
303+ run : ./gradlew formatChecks
304+ env :
305+ # For jobs running on 'push', publish build scan and cache immediately.
306+ # This won't work for pull requests, since they don't have access to secrets.
307+ POPULATE_REMOTE_GRADLE_CACHE : ${{ github.event_name == 'push' && github.repository == 'hibernate/hibernate-orm' && 'true' || 'false' }}
308+ DEVELOCITY_ACCESS_KEY : " ${{ secrets.DEVELOCITY_ACCESS_KEY }}"
309+
310+ # For jobs running on 'pull_request', upload build scan data.
311+ # The actual publishing must be done in a separate job (see ci-report.yml).
312+ # We don't write to the remote cache as that would be unsafe.
313+ - name : Upload GitHub Actions artifact for the Develocity build scan
314+ uses : actions/upload-artifact@v4
315+ if : " ${{ github.event_name == 'pull_request' && !cancelled() }}"
316+ with :
317+ name : build-scan-data-${{ matrix.rdbms }}
318+ path : ~/.gradle/build-scan-data
319+
229320 - name : Upload test reports (if Gradle failed)
230321 uses : actions/upload-artifact@v4
231322 if : failure()
0 commit comments