Skip to content

Commit

Permalink
Enable local build caching when tests results are too large for remote
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed May 23, 2022
1 parent d8e8a30 commit fa552a5
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 19 deletions.
47 changes: 35 additions & 12 deletions .github/workflows/build.yml
Expand Up @@ -8,6 +8,7 @@ env:
ALLOWED_ENDPOINTS: >
1k4dacprodeus2file4.blob.core.windows.net:443
artifactcache.actions.githubusercontent.com:443
artifacts.codacy.com:433
api.azul.com:443
api.github.com:443
caffeine.gradle-enterprise.cloud:443
Expand All @@ -18,7 +19,6 @@ env:
coveralls.io:443
fastly.com:443
docs.oracle.com:443
domain artifacts.codacy.com::433
downloads.gradle-dn.com:443
ghcr.io:443
github.com:443
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
continue-on-error: true
if: failure()

test:
tests:
name: Tests
runs-on: ubuntu-latest
needs: compile
Expand Down Expand Up @@ -158,8 +158,23 @@ jobs:
cache: 'gradle'
distribution: 'zulu'
java-version: ${{ matrix.java }}
- name: Remove Gradle Cache
if: >
matrix.suite == 'caffeine:strongKeysAndStrongValuesStatsAsyncCaffeineTest'
|| matrix.suite == 'caffeine:weakKeysAndStrongValuesStatsAsyncCaffeineTest'
|| matrix.suite == 'caffeine:weakKeysAndStrongValuesStatsSyncCaffeineTest'
|| matrix.suite == 'caffeine:strongKeysAndStrongValuesAsyncCaffeineTest'
|| matrix.suite == 'caffeine:weakKeysAndSoftValuesStatsSyncCaffeineTest'
|| matrix.suite == 'caffeine:weakKeysAndWeakValuesStatsSyncCaffeineTest'
|| matrix.suite == 'caffeine:weakKeysAndStrongValuesAsyncCaffeineTest'
|| matrix.suite == 'caffeine:weakKeysAndStrongValuesSyncCaffeineTest'
|| matrix.suite == 'caffeine:weakKeysAndSoftValuesSyncCaffeineTest'
|| matrix.suite == 'caffeine:weakKeysAndWeakValuesSyncCaffeineTest'
run: rm -rf ~/.gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-strict-match: true
- name: Run tests (${{ matrix.suite }})
run: |
stopMarker=$(uuidgen)
Expand Down Expand Up @@ -192,10 +207,10 @@ jobs:
continue-on-error: true
if: failure()

publish:
publish-snapshot:
name: Publish Snapshot
runs-on: ubuntu-latest
needs: test
needs: tests
if: >
github.event_name == 'push'
&& endsWith(github.ref, github.event.repository.default_branch)
Expand Down Expand Up @@ -231,13 +246,13 @@ jobs:
coverage:
name: Coverage
runs-on: ubuntu-latest
needs: test
needs: tests
if: github.event_name == 'push'
steps:
- name: Harden Runner
uses: step-security/harden-runner@248ae51c2e8cc9622ecf50685c8bf7150c6e8813
with:
egress-policy: block
egress-policy: audit
allowed-endpoints: ${{ env.ALLOWED_ENDPOINTS }}
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -253,7 +268,15 @@ jobs:
uses: actions/download-artifact@v3
- name: Decompress
run: find . -type f -name '*.tar.gz' -exec sh -c 'tar -zxf {} --one-top-level' \;
- name: Publish Coverage (Coveralls)
- name: Combine Jacoco Reports
env:
JAVA_VERSION: ${{ env.MAX_JVM }}
run: |
stopMarker=$(uuidgen)
echo "::stop-commands::$stopMarker"
trap "echo '::$stopMarker::'" EXIT
./gradlew --daemon jacocoFullReport
- name: Publish to Coveralls
env:
JAVA_VERSION: ${{ env.MAX_JVM }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
Expand All @@ -263,16 +286,16 @@ jobs:
trap "echo '::$stopMarker::'" EXIT
./gradlew --daemon coveralls
continue-on-error: true
- name: Publish Coverage (Codecov)
uses: codecov/codecov-action@v2
- name: Publish to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Publish Coverage (Codacy)
- name: Publish to Codacy
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
continue-on-error: true
- name: SonarQube
- name: Publish to SonarQube
env:
JAVA_VERSION: ${{ env.MAX_JVM }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -291,7 +314,7 @@ jobs:
test-results:
name: Test Results
runs-on: ubuntu-latest
needs: test
needs: tests
permissions:
checks: write
steps:
Expand Down
2 changes: 0 additions & 2 deletions gradle.properties
Expand Up @@ -3,5 +3,3 @@ org.gradle.configureondemand=true
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.daemon=true
nexusUsername=
nexusPassword=
1 change: 1 addition & 0 deletions gradle/codeQuality.gradle
Expand Up @@ -57,6 +57,7 @@ tasks.named('jar').configure {
metaInf {
from "${rootDir}/LICENSE"
}
outputs.cacheIf { true }
}

checkstyle {
Expand Down
7 changes: 2 additions & 5 deletions settings.gradle
Expand Up @@ -26,18 +26,15 @@ gradleEnterprise {
}
}

def gradleEnterpriseCachePassword = properties.'gradleEnterpriseCachePassword'
buildCache {
local {
enabled = !System.env.'CI'
}
remote(HttpBuildCache) {
url = 'https://caffeine.gradle-enterprise.cloud/cache/'
push = System.env.'CI'
enabled = true
credentials {
username = 'ci'
password = properties.'gradleEnterpriseCachePassword'
?: System.env.'GRADLE_ENTERPRISE_CACHE_PASSWORD'
password = gradleEnterpriseCachePassword ?: System.env.'GRADLE_ENTERPRISE_CACHE_PASSWORD'
}
}
}
Expand Down

0 comments on commit fa552a5

Please sign in to comment.