mirror of
https://github.com/gradle/actions.git
synced 2026-04-19 18:12:58 +08:00
Add GRADLE_ACTIONS_CACHE_USE_VENDORED env var for test configuration
Add env var that forces the vendored caching module when set to 'true', decoupling module selection from the Develocity access key. Set it centrally in init-integ-test so all tests use the vendored module by default. Add a dedicated legacy caching integration test that overrides the env var to 'false' to verify the legacy module works correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "ALLOWED_GRADLE_WRAPPER_CHECKSUMS=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" >> "$GITHUB_ENV"
|
echo "ALLOWED_GRADLE_WRAPPER_CHECKSUMS=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" >> "$GITHUB_ENV"
|
||||||
|
echo "GRADLE_ACTIONS_CACHE_USE_VENDORED=true" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
# Downloads a 'dist' directory artifact that was uploaded in an earlier 'build-dist' step
|
# Downloads a 'dist' directory artifact that was uploaded in an earlier 'build-dist' step
|
||||||
- name: Download dist
|
- name: Download dist
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
name: Test legacy caching module
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
cache-key-prefix:
|
||||||
|
type: string
|
||||||
|
default: '0'
|
||||||
|
runner-os:
|
||||||
|
type: string
|
||||||
|
default: '["ubuntu-latest"]'
|
||||||
|
skip-dist:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
SKIP_DIST: ${{ inputs.skip-dist }}
|
||||||
|
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: legacy-caching-${{ inputs.cache-key-prefix }}
|
||||||
|
GRADLE_ACTIONS_CACHE_USE_VENDORED: false
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
legacy-caching-seed-build:
|
||||||
|
strategy:
|
||||||
|
max-parallel: 1
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
|
- name: Initialize integ-test
|
||||||
|
uses: ./.github/actions/init-integ-test
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./setup-gradle
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
|
- name: Build kotlin-dsl project
|
||||||
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
|
run: ./gradlew build
|
||||||
|
|
||||||
|
legacy-caching-verify-build:
|
||||||
|
needs: legacy-caching-seed-build
|
||||||
|
strategy:
|
||||||
|
max-parallel: 1
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
|
- name: Initialize integ-test
|
||||||
|
uses: ./.github/actions/init-integ-test
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: ./setup-gradle
|
||||||
|
with:
|
||||||
|
cache-read-only: true
|
||||||
|
- name: Build kotlin-dsl project
|
||||||
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
|
run: ./gradlew build --offline
|
||||||
@@ -45,3 +45,8 @@ jobs:
|
|||||||
uses: ./.github/workflows/integ-test-restore-java-toolchain.yml
|
uses: ./.github/workflows/integ-test-restore-java-toolchain.yml
|
||||||
with:
|
with:
|
||||||
skip-dist: ${{ inputs.skip-dist }}
|
skip-dist: ${{ inputs.skip-dist }}
|
||||||
|
|
||||||
|
legacy-caching:
|
||||||
|
uses: ./.github/workflows/integ-test-legacy-caching.yml
|
||||||
|
with:
|
||||||
|
skip-dist: ${{ inputs.skip-dist }}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export async function getCacheService(cacheConfig: CacheConfig): Promise<CacheSe
|
|||||||
return new NoOpCacheService()
|
return new NoOpCacheService()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cacheConfig.isCacheLicenseAccepted()) {
|
if (useVendoredCacheModule() || cacheConfig.isCacheLicenseAccepted()) {
|
||||||
const vendoredService = await loadVendoredCacheService()
|
const vendoredService = await loadVendoredCacheService()
|
||||||
return new LoggingCacheService(vendoredService, VENDORED_CACHE_LOG_MESSAGE, VENDORED_CACHE_REPORT_NOTICE)
|
return new LoggingCacheService(vendoredService, VENDORED_CACHE_LOG_MESSAGE, VENDORED_CACHE_REPORT_NOTICE)
|
||||||
}
|
}
|
||||||
@@ -68,6 +68,10 @@ export async function getCacheService(cacheConfig: CacheConfig): Promise<CacheSe
|
|||||||
return new LoggingCacheService(legacyService, LEGACY_CACHE_LOG_MESSAGE, LEGACY_CACHE_REPORT_NOTICE)
|
return new LoggingCacheService(legacyService, LEGACY_CACHE_LOG_MESSAGE, LEGACY_CACHE_REPORT_NOTICE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function useVendoredCacheModule(): boolean {
|
||||||
|
return process.env['GRADLE_ACTIONS_CACHE_USE_VENDORED'] === 'true'
|
||||||
|
}
|
||||||
|
|
||||||
export async function loadVendoredCacheService(): Promise<CacheService> {
|
export async function loadVendoredCacheService(): Promise<CacheService> {
|
||||||
const vendoredLibraryPath = findLibraryPath('sources/vendor/gradle-actions-caching/index.js')
|
const vendoredLibraryPath = findLibraryPath('sources/vendor/gradle-actions-caching/index.js')
|
||||||
const moduleUrl = pathToFileURL(vendoredLibraryPath).href
|
const moduleUrl = pathToFileURL(vendoredLibraryPath).href
|
||||||
|
|||||||
Reference in New Issue
Block a user