Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .github/ci-prerequisites-atlas.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Reclaims disk space and sanitizes user home on Atlas infrastructure

# We use the GitHub cache for the relevant parts of these directories.
# Also, we do not want to keep things like ~/.gradle/build-scan-data.
rm -rf ~/.gradle/
rm -rf ~/.m2/
54 changes: 42 additions & 12 deletions .github/workflows/atlas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ jobs:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Reclaim Disk Space
run: .github/ci-prerequisites.sh
- name: Reclaim disk space and sanitize user home
run: .github/ci-prerequisites-atlas.sh
- name: Start database
env:
RDBMS: ${{ matrix.rdbms }}
Expand All @@ -53,20 +53,50 @@ jobs:
with:
distribution: 'graalvm'
java-version: '21'
- 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@v3

- name: Generate cache key
id: cache-key
run: |
CURRENT_BRANCH="${{ github.repository != 'hibernate/hibernate-orm' && 'fork' || github.base_ref || github.ref_name }}"
CURRENT_MONTH=$(/bin/date -u "+%Y-%m")
CURRENT_DAY=$(/bin/date -u "+%d")
ROOT_CACHE_KEY="buildtool-cache-atlas"
echo "buildtool-monthly-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}" >> $GITHUB_OUTPUT
echo "buildtool-monthly-branch-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}-${CURRENT_BRANCH}" >> $GITHUB_OUTPUT
echo "buildtool-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}-${CURRENT_BRANCH}-${CURRENT_DAY}" >> $GITHUB_OUTPUT
- name: Cache Maven/Gradle Dependency/Dist Caches
id: cache-maven
uses: actions/cache@v4
# if it's not a pull request, we restore and save the cache
if: github.event_name != 'pull_request'
with:
path: |
~/.m2/repository/
~/.m2/wrapper/
~/.gradle/caches/modules-2
~/.gradle/wrapper/
# 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.
# The whole cache is dropped monthly to prevent unlimited growth.
# 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.
key: ${{ steps.cache-key.outputs.buildtool-cache-key }}
restore-keys: |
${{ steps.cache-key.outputs.buildtool-monthly-branch-cache-key }}-
${{ steps.cache-key.outputs.buildtool-monthly-cache-key }}-
- name: Restore Maven/Gradle Dependency/Dist Caches
uses: actions/cache/restore@v3
# if it a pull request, we restore the cache but we don't save it
if: github.event_name == 'pull_request'
with:
path: |
~/.m2/repository
~/.gradle/caches/
~/.m2/repository/
~/.m2/wrapper/
~/.gradle/caches/modules-2
~/.gradle/wrapper/
# refresh cache every month to avoid unlimited growth
key: maven-localrepo-${{ steps.get-date.outputs.yearmonth }}
key: ${{ steps.cache-key.outputs.buildtool-cache-key }}
restore-keys: |
${{ steps.cache-key.outputs.buildtool-monthly-branch-cache-key }}-
${{ steps.cache-key.outputs.buildtool-monthly-cache-key }}-

- name: Run build script
env:
RDBMS: ${{ matrix.rdbms }}
Expand Down
50 changes: 40 additions & 10 deletions .github/workflows/contributor-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,50 @@ jobs:
with:
distribution: 'temurin'
java-version: '11'
- 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@v3

- name: Generate cache key
id: cache-key
run: |
CURRENT_BRANCH="${{ github.repository != 'hibernate/hibernate-orm' && 'fork' || github.base_ref || github.ref_name }}"
CURRENT_MONTH=$(/bin/date -u "+%Y-%m")
CURRENT_DAY=$(/bin/date -u "+%d")
ROOT_CACHE_KEY="buildtool-cache"
echo "buildtool-monthly-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}" >> $GITHUB_OUTPUT
echo "buildtool-monthly-branch-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}-${CURRENT_BRANCH}" >> $GITHUB_OUTPUT
echo "buildtool-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}-${CURRENT_BRANCH}-${CURRENT_DAY}" >> $GITHUB_OUTPUT
- name: Cache Maven/Gradle Dependency/Dist Caches
id: cache-maven
uses: actions/cache@v4
# if it's not a pull request, we restore and save the cache
if: github.event_name != 'pull_request'
with:
path: |
~/.m2/repository/
~/.m2/wrapper/
~/.gradle/caches/modules-2
~/.gradle/wrapper/
# 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.
# The whole cache is dropped monthly to prevent unlimited growth.
# 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.
key: ${{ steps.cache-key.outputs.buildtool-cache-key }}
restore-keys: |
${{ steps.cache-key.outputs.buildtool-monthly-branch-cache-key }}-
${{ steps.cache-key.outputs.buildtool-monthly-cache-key }}-
- name: Restore Maven/Gradle Dependency/Dist Caches
uses: actions/cache/restore@v3
# if it a pull request, we restore the cache but we don't save it
if: github.event_name == 'pull_request'
with:
path: |
~/.m2/repository
~/.gradle/caches/
~/.m2/repository/
~/.m2/wrapper/
~/.gradle/caches/modules-2
~/.gradle/wrapper/
# refresh cache every month to avoid unlimited growth
key: maven-localrepo-${{ steps.get-date.outputs.yearmonth }}
key: ${{ steps.cache-key.outputs.buildtool-cache-key }}
restore-keys: |
${{ steps.cache-key.outputs.buildtool-monthly-branch-cache-key }}-
${{ steps.cache-key.outputs.buildtool-monthly-cache-key }}-

- name: Run build script
env:
RDBMS: ${{ matrix.rdbms }}
Expand Down
11 changes: 9 additions & 2 deletions ci/release/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ pipeline {
// update changelog from JIRA
// tags the version
// changes the version to the provided development version
withEnv(["BRANCH=${env.GIT_BRANCH}"]) {
withEnv([
"BRANCH=${env.GIT_BRANCH}",
"DISABLE_REMOTE_GRADLE_CACHE=true"
]) {
sh ".release/scripts/prepare-release.sh ${env.PROJECT} ${env.RELEASE_VERSION} ${env.DEVELOPMENT_VERSION}"
}
}
Expand All @@ -161,7 +164,11 @@ pipeline {
sshagent(['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net']) {
// performs documentation upload and Sonatype release
// push to github
sh ".release/scripts/publish.sh ${env.SCRIPT_OPTIONS} ${env.PROJECT} ${env.RELEASE_VERSION} ${env.DEVELOPMENT_VERSION} ${env.GIT_BRANCH}"
withEnv([
"DISABLE_REMOTE_GRADLE_CACHE=true"
]) {
sh ".release/scripts/publish.sh ${env.SCRIPT_OPTIONS} ${env.PROJECT} ${env.RELEASE_VERSION} ${env.DEVELOPMENT_VERSION} ${env.GIT_BRANCH}"
}
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion gradle/gradle-enterprise.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

ext {
isCiEnvironment = isJenkins() || isGitHubActions() || isGenericCi()
populateRemoteBuildCache = getSetting( "POPULATE_REMOTE" ).isPresent()
populateRemoteBuildCache = isEnabled( "POPULATE_REMOTE" )
useRemoteCache = !isEnabled( "DISABLE_REMOTE_GRADLE_CACHE" )
}

private static boolean isJenkins() {
Expand All @@ -36,6 +37,14 @@ static java.util.Optional<String> getSetting(String name) {
return java.util.Optional.ofNullable(sysProp);
}

static boolean isEnabled(String setting) {
if ( System.getenv().hasProperty( setting ) ) {
return true
}

return System.hasProperty( setting )
}

gradleEnterprise {
server = 'https://ge.hibernate.org'

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ buildCache {
enabled = !settings.ext.isCiEnvironment
}
remote(HttpBuildCache) {
enabled = true
enabled = settings.ext.useRemoteCache
push = settings.ext.populateRemoteBuildCache
url = 'https://ge.hibernate.org/cache/'
}
Expand Down
Loading