Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/contributor-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,67 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request_target' || github.repository != 'hibernate/hibernate-orm' }}

jobs:
# Pre-requisite step that only runs format checks
format_checks:
permissions:
contents: read
name: Java 17
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Check out commit already pushed to branch
if: "! github.event.pull_request.number"
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Check out PR head
uses: actions/checkout@v4
if: github.event.pull_request.number
with:
ref: "refs/pull/${{ github.event.pull_request.number }}/head"
persist-credentials: false
- name: Reclaim Disk Space
run: .github/ci-prerequisites.sh
- name: Set up Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Get year/month for cache key
id: get-date
run: echo "yearmonth=$(/bin/date -u "+%Y-%m")" >> $GITHUB_OUTPUT
shell: bash
- name: Cache Maven local repository
uses: actions/cache@v4
id: cache-maven
with:
path: |
~/.m2/repository
~/.gradle/caches/
~/.gradle/wrapper/
# refresh cache every month to avoid unlimited growth
key: maven-localrepo-${{ steps.get-date.outputs.yearmonth }}
- name: Run format checks
env:
# Don't populate Develocity cache in pull requests as that's potentially dangerous
POPULATE_REMOTE_GRADLE_CACHE: "${{ github.event_name == 'push' }}"
# WARNING: exposes secrets, so must only be passed to a step that doesn't run unapproved code.
DEVELOCITY_ACCESS_KEY: "${{ github.event_name == 'push' && secrets.GRADLE_ENTERPRISE_ACCESS_KEY || '' }}"
run: |
./gradlew formatChecks
- name: Upload test reports (if Gradle failed)
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-reports-java11-${{ matrix.rdbms }}
path: |
./**/target/reports/tests/
- name: Omit produced artifacts from build cache
run: ./ci/before-cache.sh
# Actual build that executes tests
build:
needs: format_checks
permissions:
contents: read
name: Java 17
Expand Down
2 changes: 1 addition & 1 deletion ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ function logAndExec() {
exec "${@}"
}

logAndExec ./gradlew check ${goal} "${@}" -Plog-test-progress=true --stacktrace
logAndExec ./gradlew ciCheck ${goal} "${@}" -Plog-test-progress=true --stacktrace
32 changes: 26 additions & 6 deletions gradle/java-module.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ tasks.copyResourcesToIntelliJOutFolder.mustRunAfter processTestResources
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Report configs

task enforceRules {
tasks.register('enforceRules') {
doLast {
def illegalImport = ~/^import (sun|java.awt|org.slf4j)/
def missingNewline = ~/^\s*}\s*(else|catch|finally)/
Expand Down Expand Up @@ -477,23 +477,23 @@ task enforceRules {
}
if (!line.startsWith("//")) { //ignore commented-out code
if (line =~ equals) {
equalsMinusHashcode ++
equalsMinusHashcode++
}
if (line =~ hashCode) {
equalsMinusHashcode --
equalsMinusHashcode--
}
}
}
if (equalsMinusHashcode>0) {
if (equalsMinusHashcode > 0) {
errors++
logger.error("Equals with missing hash code in ${shortName}")
}
if (equalsMinusHashcode<0) {
if (equalsMinusHashcode < 0) {
errors++
logger.error("Hash code with missing equals in ${shortName}")
}
}
if ( errors>0 ) {
if (errors > 0) {
throw new GradleException("Code rules were violated ($errors problems)")
}
}
Expand All @@ -514,6 +514,26 @@ spotless {

tasks.spotlessApply.dependsOn enforceRules

tasks.register( "ciCheck" ) {
group "verification"
description "Checks for CI environments"
dependsOn tasks.check

spotlessApply {
enabled = false
}
spotlessJavaApply {
enabled = false
}
Comment on lines +522 to +527
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only disabling spotlessApply is not enough apparently as spotlessJavaApply is run separately (run with --info for details).

}

tasks.register( "formatChecks" ) {
group "verification"
description "Code style and formatting checks"

dependsOn tasks.spotlessCheck
dependsOn tasks.enforceRules
}

class CompilerStubsArgumentProvider implements CommandLineArgumentProvider {

Expand Down
Loading