Compare commits

..

8 Commits

Author SHA1 Message Date
Daz DeBoer
6c7537229b Merge pull request #1026 from gradle/dd/java-toolchains
Use Maven toolchains.xml to register pre-installed JDKs as java toolchains
2024-01-04 05:34:34 +01:00
daz
650620f9f9 Build outputs 2024-01-03 21:12:13 -07:00
daz
d4e24dfc10 Register pre-installed JDKs in .m2/toolchains.xml
Since adding these to the `org.gradle.java.installations.fromEnv` property
is problematic (#1024), this mechanism allows the default toolchains to
be discovered by Gradle via a different mechanism.

The default JDK installations are added to `~/.m2/toolchains.xml` such that
they are discoverable by Gradle toolchain support.
The `setup-java` action also writes to this file, so we merge with any existing
content: this allows both pre-installed and "setup" JDKs to be automatically
detected by Gradle.
2024-01-03 21:08:40 -07:00
daz
7c57ba1136 Remove writing value to gradle.properties in setup
The written property will override any project-level setting, which
can lead to confusing behaviour.

Fixes #1024
2024-01-03 18:49:57 -07:00
Daz DeBoer
32bab5b15a Allow entries with same Job ID to match in different workflows
Previously, the workflow name was always included when matching a cache entry for the current job.
This can be overly restrictive when job definitions are shared between different workflows. 
The workflow name is still encoded in the cache entry key, but not in the restore key searching for entries with a matching job.

Fixes #1017
2024-01-03 18:38:36 -07:00
daz
270f30ba56 Always initialize encryption key 2024-01-02 14:28:29 -07:00
daz
c00a847f3f Enable config-cache tests
- Enable in full-build
- Pass encryption key secret to test workflow
2024-01-02 11:31:06 -07:00
daz
e2aa3f332c Test with Gradle 8.6-rc-1 2024-01-01 19:29:46 -07:00
16 changed files with 248 additions and 237 deletions

View File

@@ -58,10 +58,12 @@ jobs:
with:
cache-key-prefix: ${{github.run_number}}-
# restore-configuration-cache:
# uses: ./.github/workflows/integ-test-restore-configuration-cache.yml
# with:
# cache-key-prefix: ${{github.run_number}}-
restore-configuration-cache:
uses: ./.github/workflows/integ-test-restore-configuration-cache.yml
with:
cache-key-prefix: ${{github.run_number}}-
secrets:
GRADLE_ENCRYPTION_KEY: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
restore-custom-gradle-home:
uses: ./.github/workflows/integ-test-restore-custom-gradle-home.yml

View File

@@ -95,6 +95,8 @@ jobs:
with:
runner-os: '["ubuntu-latest"]'
download-dist: true
secrets:
GRADLE_ENCRYPTION_KEY: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
restore-containerized-gradle-home:
needs: build-distribution

View File

@@ -21,6 +21,7 @@ jobs:
# Test that pre-installed runner JDKs are detected
pre-installed-toolchains:
strategy:
fail-fast: false
matrix:
os: ${{fromJSON(inputs.runner-os)}}
runs-on: ${{ matrix.os }}
@@ -35,7 +36,7 @@ jobs:
shell: bash
working-directory: .github/workflow-samples/groovy-dsl
run: |
gradle -q javaToolchains > output.txt
gradle --info javaToolchains > output.txt
cat output.txt
- name: Verify detected toolchains
shell: bash
@@ -44,10 +45,12 @@ jobs:
grep -q 'Eclipse Temurin JDK 1.8' output.txt || (echo "::error::Did not detect preinstalled JDK 1.8" && exit 1)
grep -q 'Eclipse Temurin JDK 11' output.txt || (echo "::error::Did not detect preinstalled JDK 11" && exit 1)
grep -q 'Eclipse Temurin JDK 17' output.txt || (echo "::error::Did not detect preinstalled JDK 17" && exit 1)
grep -q 'Eclipse Temurin JDK 21' output.txt || (echo "::error::Did not detect preinstalled JDK 21" && exit 1)
# Test that JDKs provisioned by setup-java are detected
setup-java-installed-toolchain:
strategy:
fail-fast: false
matrix:
os: ${{fromJSON(inputs.runner-os)}}
runs-on: ${{ matrix.os }}
@@ -72,42 +75,19 @@ jobs:
shell: bash
working-directory: .github/workflow-samples/groovy-dsl
run: |
gradle -q javaToolchains > output.txt
gradle --info javaToolchains > output.txt
cat output.txt
- name: Verify detected toolchains
- name: Verify setup JDKs are detected
shell: bash
working-directory: .github/workflow-samples/groovy-dsl
run: |
grep -q 'Eclipse Temurin JDK 16' output.txt || (echo "::error::Did not detect setup-java installed JDK 16" && exit 1)
grep -q 'Eclipse Temurin JDK 20' output.txt || (echo "::error::Did not detect setup-java installed JDK 20" && exit 1)
# Test that predefined JDK detection property is not overwritten by action
check-no-overwrite:
strategy:
matrix:
os: ${{fromJSON(inputs.runner-os)}}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Download distribution if required
uses: ./.github/actions/download-dist
- name: Configure java installations env var in Gradle User Home
- name: Verify pre-installed toolchains are detected
shell: bash
working-directory: .github/workflow-samples/groovy-dsl
run: |
mkdir -p ~/.gradle
echo "org.gradle.java.installations.fromEnv=XXXXX" > ~/.gradle/gradle.properties
- name: Setup Gradle
uses: ./
- name: Check gradle.properties
shell: bash
run: |
cat ~/.gradle/gradle.properties
if grep -q 'org.gradle.java.installations.fromEnv=JAVA_HOME' ~/.gradle/gradle.properties ; then
echo 'Found overwritten fromEnv'
exit 1
fi
if ! grep -q 'org.gradle.java.installations.fromEnv=XXXXX' ~/.gradle/gradle.properties ; then
echo 'Did NOT find original fromEnv'
exit 1
fi
grep -q 'Eclipse Temurin JDK 1.8' output.txt || (echo "::error::Did not detect preinstalled JDK 1.8" && exit 1)
grep -q 'Eclipse Temurin JDK 11' output.txt || (echo "::error::Did not detect preinstalled JDK 11" && exit 1)
grep -q 'Eclipse Temurin JDK 17' output.txt || (echo "::error::Did not detect preinstalled JDK 17" && exit 1)
grep -q 'Eclipse Temurin JDK 21' output.txt || (echo "::error::Did not detect preinstalled JDK 21" && exit 1)

View File

@@ -11,6 +11,9 @@ on:
download-dist:
type: boolean
default: false
secrets:
GRADLE_ENCRYPTION_KEY:
required: true
env:
DOWNLOAD_DIST: ${{ inputs.download-dist }}
@@ -34,8 +37,8 @@ jobs:
uses: ./
with:
cache-read-only: false # For testing, allow writing cache entries on non-default branches
cache-encryption-key: Da25KUVSE5jbGds2zXmfXw==
gradle-version: release-nightly
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
gradle-version: 8.6-rc-1
- name: Groovy build with configuration-cache enabled
working-directory: .github/workflow-samples/groovy-dsl
run: gradle test --configuration-cache
@@ -57,8 +60,8 @@ jobs:
uses: ./
with:
cache-read-only: true
cache-encryption-key: Da25KUVSE5jbGds2zXmfXw==
gradle-version: release-nightly
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
gradle-version: 8.6-rc-1
- name: Groovy build with configuration-cache enabled
id: execute
working-directory: .github/workflow-samples/groovy-dsl
@@ -92,8 +95,8 @@ jobs:
GRADLE_BUILD_ACTION_SKIP_RESTORE: "generated-gradle-jars|wrapper-zips|java-toolchains|instrumented-jars|dependencies|kotlin-dsl"
with:
cache-read-only: true
cache-encryption-key: Da25KUVSE5jbGds2zXmfXw==
gradle-version: release-nightly
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
gradle-version: 8.6-rc-1
- name: Check execute Gradle build with configuration cache enabled (but not restored)
working-directory: .github/workflow-samples/groovy-dsl
run: gradle test --configuration-cache
@@ -114,8 +117,8 @@ jobs:
uses: ./
with:
cache-read-only: false # For testing, allow writing cache entries on non-default branches
cache-encryption-key: Da25KUVSE5jbGds2zXmfXw==
gradle-version: release-nightly
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
gradle-version: 8.6-rc-1
- name: Execute 'help' with configuration-cache enabled
working-directory: .github/workflow-samples/kotlin-dsl
run: gradle help --configuration-cache
@@ -137,8 +140,8 @@ jobs:
uses: ./
with:
cache-read-only: false # For testing, allow writing cache entries on non-default branches
cache-encryption-key: Da25KUVSE5jbGds2zXmfXw==
gradle-version: release-nightly
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
gradle-version: 8.6-rc-1
- name: Execute 'test' with configuration-cache enabled
working-directory: .github/workflow-samples/kotlin-dsl
run: gradle test --configuration-cache
@@ -161,8 +164,8 @@ jobs:
uses: ./
with:
cache-read-only: true
cache-encryption-key: Da25KUVSE5jbGds2zXmfXw==
gradle-version: release-nightly
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
gradle-version: 8.6-rc-1
- name: Execute 'test' again with configuration-cache enabled
id: execute
working-directory: .github/workflow-samples/kotlin-dsl

View File

@@ -259,9 +259,9 @@ This allows the most recent state to always be available in the GitHub actions c
### Finding a matching cache entry
In most cases, no exact match will exist for the cache key. Instead, the Gradle User Home will be restored for the closest matching cache entry, using a set of "restore keys". The entries will be matched with the following precedence:
- An exact match on OS, workflow, job, matrix and Git SHA
- The most recent entry saved for the same OS, workflow, job and matrix values
- The most recent entry saved for the same OS, workflow and job
- An exact match on OS, workflow name, job id, matrix and Git SHA
- The most recent entry saved for the same OS, workflow name, job id and matrix values
- The most recent entry saved for the same OS and job id
- The most recent entry saved for the same OS
Due to branch scoping of cache entries, the above match will be first performed for entries from the same branch, and then for the default ('main') branch.

106
dist/main/index.js vendored
View File

@@ -138599,17 +138599,18 @@ const cache_extract_entries_1 = __nccwpck_require__(76161);
const RESTORED_CACHE_KEY_KEY = 'restored-cache-key';
exports.META_FILE_DIR = '.gradle-build-action';
class GradleStateCache {
constructor(gradleUserHome) {
constructor(userHome, gradleUserHome) {
this.userHome = userHome;
this.gradleUserHome = gradleUserHome;
this.cacheName = 'gradle';
this.cacheDescription = 'Gradle User Home';
}
init() {
const actionCacheDir = path_1.default.resolve(this.gradleUserHome, '.gradle-build-action');
fs_1.default.mkdirSync(actionCacheDir, { recursive: true });
const initScriptsDir = path_1.default.resolve(this.gradleUserHome, 'init.d');
fs_1.default.mkdirSync(initScriptsDir, { recursive: true });
this.initializeGradleUserHome(this.gradleUserHome, initScriptsDir);
this.initializeGradleUserHome();
const encryptionKey = params.getCacheEncryptionKey();
if (encryptionKey) {
core.exportVariable('GRADLE_ENCRYPTION_KEY', encryptionKey);
}
}
cacheOutputExists() {
const cachesDir = path_1.default.resolve(this.gradleUserHome, 'caches');
@@ -138721,17 +138722,15 @@ class GradleStateCache {
}
return path_1.default.resolve(this.gradleUserHome, rawPath);
}
initializeGradleUserHome(gradleUserHome, initScriptsDir) {
const gradleProperties = path_1.default.resolve(gradleUserHome, 'gradle.properties');
const existingGradleProperties = fs_1.default.existsSync(gradleProperties)
? fs_1.default.readFileSync(gradleProperties, 'utf8')
: '';
if (!existingGradleProperties.includes('org.gradle.java.installations.fromEnv=')) {
fs_1.default.appendFileSync(gradleProperties, `
# Auto-detect pre-installed JDKs
org.gradle.java.installations.fromEnv=JAVA_HOME_8_X64,JAVA_HOME_11_X64,JAVA_HOME_17_X64
`);
}
initializeGradleUserHome() {
const actionCacheDir = path_1.default.resolve(this.gradleUserHome, '.gradle-build-action');
fs_1.default.mkdirSync(actionCacheDir, { recursive: true });
this.copyInitScripts();
this.registerToolchains();
}
copyInitScripts() {
const initScriptsDir = path_1.default.resolve(this.gradleUserHome, 'init.d');
fs_1.default.mkdirSync(initScriptsDir, { recursive: true });
const initScriptFilenames = [
'gradle-build-action.build-result-capture.init.gradle',
'gradle-build-action.build-result-capture-service.plugin.groovy',
@@ -138740,13 +138739,30 @@ org.gradle.java.installations.fromEnv=JAVA_HOME_8_X64,JAVA_HOME_11_X64,JAVA_HOME
'gradle-build-action.inject-gradle-enterprise.init.gradle'
];
for (const initScriptFilename of initScriptFilenames) {
const initScriptContent = this.readInitScriptAsString(initScriptFilename);
const initScriptContent = this.readResourceFileAsString('init-scripts', initScriptFilename);
const initScriptPath = path_1.default.resolve(initScriptsDir, initScriptFilename);
fs_1.default.writeFileSync(initScriptPath, initScriptContent);
}
}
readInitScriptAsString(resource) {
const absolutePath = path_1.default.resolve(__dirname, '..', '..', 'src', 'resources', 'init-scripts', resource);
registerToolchains() {
const preInstalledToolchains = this.readResourceFileAsString('toolchains.xml');
const m2dir = path_1.default.resolve(this.userHome, '.m2');
const toolchainXmlTarget = path_1.default.resolve(m2dir, 'toolchains.xml');
if (!fs_1.default.existsSync(toolchainXmlTarget)) {
fs_1.default.mkdirSync(m2dir, { recursive: true });
fs_1.default.writeFileSync(toolchainXmlTarget, preInstalledToolchains);
core.info(`Wrote default JDK locations to ${toolchainXmlTarget}`);
}
else {
const existingToolchainContent = fs_1.default.readFileSync(toolchainXmlTarget, 'utf8');
const appendedContent = preInstalledToolchains.split('<toolchains>').pop();
const mergedContent = existingToolchainContent.replace('</toolchains>', appendedContent);
fs_1.default.writeFileSync(toolchainXmlTarget, mergedContent);
core.info(`Merged default JDK locations into ${toolchainXmlTarget}`);
}
}
readResourceFileAsString(...paths) {
const absolutePath = path_1.default.resolve(__dirname, '..', '..', 'src', 'resources', ...paths);
return fs_1.default.readFileSync(absolutePath, 'utf8');
}
debugReportGradleUserHomeSize(label) {
@@ -138946,7 +138962,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ConfigurationCacheEntryExtractor = exports.GradleHomeEntryExtractor = void 0;
const path_1 = __importDefault(__nccwpck_require__(71017));
const fs_1 = __importDefault(__nccwpck_require__(57147));
const crypto_1 = __importDefault(__nccwpck_require__(6113));
const core = __importStar(__nccwpck_require__(42186));
const glob = __importStar(__nccwpck_require__(28090));
const semver = __importStar(__nccwpck_require__(11383));
@@ -139184,8 +139199,6 @@ class ConfigurationCacheEntryExtractor extends AbstractEntryExtractor {
this.markNotRestored(listener, 'Encryption Key was not provided');
return;
}
const encryptionKey = this.getAESEncryptionKey();
core.exportVariable('GRADLE_ENCRYPTION_KEY', encryptionKey);
return yield _super.restore.call(this, listener);
});
}
@@ -139217,11 +139230,6 @@ class ConfigurationCacheEntryExtractor extends AbstractEntryExtractor {
yield _super.extract.call(this, listener);
});
}
getAESEncryptionKey() {
const secret = params.getCacheEncryptionKey();
const key = crypto_1.default.pbkdf2Sync(secret, '', 1000, 16, 'sha256');
return key.toString('base64');
}
getExtractedCacheEntryDefinitions() {
const groupedResults = this.getConfigCacheDirectoriesWithAssociatedBuildResults();
return Object.entries(groupedResults).map(([configCachePath, pathResults]) => {
@@ -139509,7 +139517,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.tryDelete = exports.handleCacheFailure = exports.cacheDebug = exports.saveCache = exports.restoreCache = exports.hashStrings = exports.hashFileNames = exports.getUniqueLabelForJobInstanceValues = exports.getUniqueLabelForJobInstance = exports.getCacheKeyForJob = exports.getCacheKeyPrefix = exports.generateCacheKey = exports.CacheKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
exports.tryDelete = exports.handleCacheFailure = exports.cacheDebug = exports.saveCache = exports.restoreCache = exports.hashStrings = exports.hashFileNames = exports.getCacheKeyPrefix = exports.generateCacheKey = exports.CacheKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
const core = __importStar(__nccwpck_require__(42186));
const cache = __importStar(__nccwpck_require__(27799));
const github = __importStar(__nccwpck_require__(95438));
@@ -139581,34 +139589,16 @@ function getCacheKeyEnvironment() {
return process.env[CACHE_KEY_OS_VAR] || runnerOs;
}
function getCacheKeyJob() {
return process.env[CACHE_KEY_JOB_VAR] || getCacheKeyForJob(github.context.workflow, github.context.job);
return process.env[CACHE_KEY_JOB_VAR] || github.context.job;
}
function getCacheKeyForJob(workflowName, jobId) {
const sanitizedWorkflow = workflowName.replace(/,/g, '').toLowerCase();
return `${sanitizedWorkflow}-${jobId}`;
}
exports.getCacheKeyForJob = getCacheKeyForJob;
function getCacheKeyJobInstance() {
const override = process.env[CACHE_KEY_JOB_INSTANCE_VAR];
if (override) {
return override;
}
const workflowName = github.context.workflow;
const workflowJobContext = params.getJobMatrix();
return hashStrings([workflowJobContext]);
}
function getUniqueLabelForJobInstance() {
return getUniqueLabelForJobInstanceValues(github.context.workflow, github.context.job, params.getJobMatrix());
}
exports.getUniqueLabelForJobInstance = getUniqueLabelForJobInstance;
function getUniqueLabelForJobInstanceValues(workflow, jobId, matrixJson) {
const matrix = JSON.parse(matrixJson);
const matrixString = Object.values(matrix).join('-');
const label = matrixString ? `${workflow}-${jobId}-${matrixString}` : `${workflow}-${jobId}`;
return sanitize(label);
}
exports.getUniqueLabelForJobInstanceValues = getUniqueLabelForJobInstanceValues;
function sanitize(value) {
return value.replace(/[^a-zA-Z0-9_-]/g, '').toLowerCase();
return hashStrings([workflowName, workflowJobContext]);
}
function getCacheKeyJobExecution() {
return process.env[CACHE_KEY_JOB_EXECUTION_VAR] || github.context.sha;
@@ -139780,14 +139770,14 @@ const cache_utils_1 = __nccwpck_require__(41678);
const cache_base_1 = __nccwpck_require__(47591);
const cache_cleaner_1 = __nccwpck_require__(57);
const CACHE_RESTORED_VAR = 'GRADLE_BUILD_ACTION_CACHE_RESTORED';
function restore(gradleUserHome, cacheListener) {
function restore(userHome, gradleUserHome, cacheListener) {
return __awaiter(this, void 0, void 0, function* () {
if (process.env[CACHE_RESTORED_VAR]) {
core.info('Cache only restored on first action step.');
return;
}
core.exportVariable(CACHE_RESTORED_VAR, true);
const gradleStateCache = new cache_base_1.GradleStateCache(gradleUserHome);
const gradleStateCache = new cache_base_1.GradleStateCache(userHome, gradleUserHome);
if ((0, cache_utils_1.isCacheDisabled)()) {
core.info('Cache is disabled: will not restore state from previous builds.');
gradleStateCache.init();
@@ -139822,7 +139812,7 @@ function restore(gradleUserHome, cacheListener) {
});
}
exports.restore = restore;
function save(gradleUserHome, cacheListener, daemonController) {
function save(userHome, gradleUserHome, cacheListener, daemonController) {
return __awaiter(this, void 0, void 0, function* () {
if ((0, cache_utils_1.isCacheDisabled)()) {
core.info('Cache is disabled: will not save state for later builds.');
@@ -139849,7 +139839,7 @@ function save(gradleUserHome, cacheListener, daemonController) {
}
}
yield core.group('Caching Gradle state', () => __awaiter(this, void 0, void 0, function* () {
return new cache_base_1.GradleStateCache(gradleUserHome).save(cacheListener);
return new cache_base_1.GradleStateCache(userHome, gradleUserHome).save(cacheListener);
}));
});
}
@@ -141074,10 +141064,12 @@ const build_results_1 = __nccwpck_require__(82107);
const cache_reporting_1 = __nccwpck_require__(66674);
const daemon_controller_1 = __nccwpck_require__(85146);
const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED';
const USER_HOME = 'USER_HOME';
const GRADLE_USER_HOME = 'GRADLE_USER_HOME';
const CACHE_LISTENER = 'CACHE_LISTENER';
function setup() {
return __awaiter(this, void 0, void 0, function* () {
const userHome = yield determineUserHome();
const gradleUserHome = yield determineGradleUserHome();
if (process.env[GRADLE_SETUP_VAR]) {
core.info('Gradle setup only performed on first gradle-build-action step in workflow.');
@@ -141085,9 +141077,10 @@ function setup() {
}
core.exportVariable(GRADLE_SETUP_VAR, true);
core.saveState(GRADLE_SETUP_VAR, true);
core.saveState(USER_HOME, userHome);
core.saveState(GRADLE_USER_HOME, gradleUserHome);
const cacheListener = new cache_reporting_1.CacheListener();
yield caches.restore(gradleUserHome, cacheListener);
yield caches.restore(userHome, gradleUserHome, cacheListener);
core.saveState(CACHE_LISTENER, cacheListener.stringify());
yield dependencyGraph.setup(params.getDependencyGraphOption());
});
@@ -141101,10 +141094,11 @@ function complete() {
}
core.info('In post-action step');
const buildResults = (0, build_results_1.loadBuildResults)();
const userHome = core.getState(USER_HOME);
const gradleUserHome = core.getState(GRADLE_USER_HOME);
const cacheListener = cache_reporting_1.CacheListener.rehydrate(core.getState(CACHE_LISTENER));
const daemonController = new daemon_controller_1.DaemonController(buildResults);
yield caches.save(gradleUserHome, cacheListener, daemonController);
yield caches.save(userHome, gradleUserHome, cacheListener, daemonController);
yield jobSummary.generateJobSummary(buildResults, cacheListener);
yield dependencyGraph.complete(params.getDependencyGraphOption());
core.info('Completed post-action step');

File diff suppressed because one or more lines are too long

106
dist/post/index.js vendored
View File

@@ -136052,17 +136052,18 @@ const cache_extract_entries_1 = __nccwpck_require__(76161);
const RESTORED_CACHE_KEY_KEY = 'restored-cache-key';
exports.META_FILE_DIR = '.gradle-build-action';
class GradleStateCache {
constructor(gradleUserHome) {
constructor(userHome, gradleUserHome) {
this.userHome = userHome;
this.gradleUserHome = gradleUserHome;
this.cacheName = 'gradle';
this.cacheDescription = 'Gradle User Home';
}
init() {
const actionCacheDir = path_1.default.resolve(this.gradleUserHome, '.gradle-build-action');
fs_1.default.mkdirSync(actionCacheDir, { recursive: true });
const initScriptsDir = path_1.default.resolve(this.gradleUserHome, 'init.d');
fs_1.default.mkdirSync(initScriptsDir, { recursive: true });
this.initializeGradleUserHome(this.gradleUserHome, initScriptsDir);
this.initializeGradleUserHome();
const encryptionKey = params.getCacheEncryptionKey();
if (encryptionKey) {
core.exportVariable('GRADLE_ENCRYPTION_KEY', encryptionKey);
}
}
cacheOutputExists() {
const cachesDir = path_1.default.resolve(this.gradleUserHome, 'caches');
@@ -136174,17 +136175,15 @@ class GradleStateCache {
}
return path_1.default.resolve(this.gradleUserHome, rawPath);
}
initializeGradleUserHome(gradleUserHome, initScriptsDir) {
const gradleProperties = path_1.default.resolve(gradleUserHome, 'gradle.properties');
const existingGradleProperties = fs_1.default.existsSync(gradleProperties)
? fs_1.default.readFileSync(gradleProperties, 'utf8')
: '';
if (!existingGradleProperties.includes('org.gradle.java.installations.fromEnv=')) {
fs_1.default.appendFileSync(gradleProperties, `
# Auto-detect pre-installed JDKs
org.gradle.java.installations.fromEnv=JAVA_HOME_8_X64,JAVA_HOME_11_X64,JAVA_HOME_17_X64
`);
}
initializeGradleUserHome() {
const actionCacheDir = path_1.default.resolve(this.gradleUserHome, '.gradle-build-action');
fs_1.default.mkdirSync(actionCacheDir, { recursive: true });
this.copyInitScripts();
this.registerToolchains();
}
copyInitScripts() {
const initScriptsDir = path_1.default.resolve(this.gradleUserHome, 'init.d');
fs_1.default.mkdirSync(initScriptsDir, { recursive: true });
const initScriptFilenames = [
'gradle-build-action.build-result-capture.init.gradle',
'gradle-build-action.build-result-capture-service.plugin.groovy',
@@ -136193,13 +136192,30 @@ org.gradle.java.installations.fromEnv=JAVA_HOME_8_X64,JAVA_HOME_11_X64,JAVA_HOME
'gradle-build-action.inject-gradle-enterprise.init.gradle'
];
for (const initScriptFilename of initScriptFilenames) {
const initScriptContent = this.readInitScriptAsString(initScriptFilename);
const initScriptContent = this.readResourceFileAsString('init-scripts', initScriptFilename);
const initScriptPath = path_1.default.resolve(initScriptsDir, initScriptFilename);
fs_1.default.writeFileSync(initScriptPath, initScriptContent);
}
}
readInitScriptAsString(resource) {
const absolutePath = path_1.default.resolve(__dirname, '..', '..', 'src', 'resources', 'init-scripts', resource);
registerToolchains() {
const preInstalledToolchains = this.readResourceFileAsString('toolchains.xml');
const m2dir = path_1.default.resolve(this.userHome, '.m2');
const toolchainXmlTarget = path_1.default.resolve(m2dir, 'toolchains.xml');
if (!fs_1.default.existsSync(toolchainXmlTarget)) {
fs_1.default.mkdirSync(m2dir, { recursive: true });
fs_1.default.writeFileSync(toolchainXmlTarget, preInstalledToolchains);
core.info(`Wrote default JDK locations to ${toolchainXmlTarget}`);
}
else {
const existingToolchainContent = fs_1.default.readFileSync(toolchainXmlTarget, 'utf8');
const appendedContent = preInstalledToolchains.split('<toolchains>').pop();
const mergedContent = existingToolchainContent.replace('</toolchains>', appendedContent);
fs_1.default.writeFileSync(toolchainXmlTarget, mergedContent);
core.info(`Merged default JDK locations into ${toolchainXmlTarget}`);
}
}
readResourceFileAsString(...paths) {
const absolutePath = path_1.default.resolve(__dirname, '..', '..', 'src', 'resources', ...paths);
return fs_1.default.readFileSync(absolutePath, 'utf8');
}
debugReportGradleUserHomeSize(label) {
@@ -136399,7 +136415,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ConfigurationCacheEntryExtractor = exports.GradleHomeEntryExtractor = void 0;
const path_1 = __importDefault(__nccwpck_require__(71017));
const fs_1 = __importDefault(__nccwpck_require__(57147));
const crypto_1 = __importDefault(__nccwpck_require__(6113));
const core = __importStar(__nccwpck_require__(42186));
const glob = __importStar(__nccwpck_require__(28090));
const semver = __importStar(__nccwpck_require__(11383));
@@ -136637,8 +136652,6 @@ class ConfigurationCacheEntryExtractor extends AbstractEntryExtractor {
this.markNotRestored(listener, 'Encryption Key was not provided');
return;
}
const encryptionKey = this.getAESEncryptionKey();
core.exportVariable('GRADLE_ENCRYPTION_KEY', encryptionKey);
return yield _super.restore.call(this, listener);
});
}
@@ -136670,11 +136683,6 @@ class ConfigurationCacheEntryExtractor extends AbstractEntryExtractor {
yield _super.extract.call(this, listener);
});
}
getAESEncryptionKey() {
const secret = params.getCacheEncryptionKey();
const key = crypto_1.default.pbkdf2Sync(secret, '', 1000, 16, 'sha256');
return key.toString('base64');
}
getExtractedCacheEntryDefinitions() {
const groupedResults = this.getConfigCacheDirectoriesWithAssociatedBuildResults();
return Object.entries(groupedResults).map(([configCachePath, pathResults]) => {
@@ -136962,7 +136970,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.tryDelete = exports.handleCacheFailure = exports.cacheDebug = exports.saveCache = exports.restoreCache = exports.hashStrings = exports.hashFileNames = exports.getUniqueLabelForJobInstanceValues = exports.getUniqueLabelForJobInstance = exports.getCacheKeyForJob = exports.getCacheKeyPrefix = exports.generateCacheKey = exports.CacheKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
exports.tryDelete = exports.handleCacheFailure = exports.cacheDebug = exports.saveCache = exports.restoreCache = exports.hashStrings = exports.hashFileNames = exports.getCacheKeyPrefix = exports.generateCacheKey = exports.CacheKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
const core = __importStar(__nccwpck_require__(42186));
const cache = __importStar(__nccwpck_require__(27799));
const github = __importStar(__nccwpck_require__(95438));
@@ -137034,34 +137042,16 @@ function getCacheKeyEnvironment() {
return process.env[CACHE_KEY_OS_VAR] || runnerOs;
}
function getCacheKeyJob() {
return process.env[CACHE_KEY_JOB_VAR] || getCacheKeyForJob(github.context.workflow, github.context.job);
return process.env[CACHE_KEY_JOB_VAR] || github.context.job;
}
function getCacheKeyForJob(workflowName, jobId) {
const sanitizedWorkflow = workflowName.replace(/,/g, '').toLowerCase();
return `${sanitizedWorkflow}-${jobId}`;
}
exports.getCacheKeyForJob = getCacheKeyForJob;
function getCacheKeyJobInstance() {
const override = process.env[CACHE_KEY_JOB_INSTANCE_VAR];
if (override) {
return override;
}
const workflowName = github.context.workflow;
const workflowJobContext = params.getJobMatrix();
return hashStrings([workflowJobContext]);
}
function getUniqueLabelForJobInstance() {
return getUniqueLabelForJobInstanceValues(github.context.workflow, github.context.job, params.getJobMatrix());
}
exports.getUniqueLabelForJobInstance = getUniqueLabelForJobInstance;
function getUniqueLabelForJobInstanceValues(workflow, jobId, matrixJson) {
const matrix = JSON.parse(matrixJson);
const matrixString = Object.values(matrix).join('-');
const label = matrixString ? `${workflow}-${jobId}-${matrixString}` : `${workflow}-${jobId}`;
return sanitize(label);
}
exports.getUniqueLabelForJobInstanceValues = getUniqueLabelForJobInstanceValues;
function sanitize(value) {
return value.replace(/[^a-zA-Z0-9_-]/g, '').toLowerCase();
return hashStrings([workflowName, workflowJobContext]);
}
function getCacheKeyJobExecution() {
return process.env[CACHE_KEY_JOB_EXECUTION_VAR] || github.context.sha;
@@ -137233,14 +137223,14 @@ const cache_utils_1 = __nccwpck_require__(41678);
const cache_base_1 = __nccwpck_require__(47591);
const cache_cleaner_1 = __nccwpck_require__(57);
const CACHE_RESTORED_VAR = 'GRADLE_BUILD_ACTION_CACHE_RESTORED';
function restore(gradleUserHome, cacheListener) {
function restore(userHome, gradleUserHome, cacheListener) {
return __awaiter(this, void 0, void 0, function* () {
if (process.env[CACHE_RESTORED_VAR]) {
core.info('Cache only restored on first action step.');
return;
}
core.exportVariable(CACHE_RESTORED_VAR, true);
const gradleStateCache = new cache_base_1.GradleStateCache(gradleUserHome);
const gradleStateCache = new cache_base_1.GradleStateCache(userHome, gradleUserHome);
if ((0, cache_utils_1.isCacheDisabled)()) {
core.info('Cache is disabled: will not restore state from previous builds.');
gradleStateCache.init();
@@ -137275,7 +137265,7 @@ function restore(gradleUserHome, cacheListener) {
});
}
exports.restore = restore;
function save(gradleUserHome, cacheListener, daemonController) {
function save(userHome, gradleUserHome, cacheListener, daemonController) {
return __awaiter(this, void 0, void 0, function* () {
if ((0, cache_utils_1.isCacheDisabled)()) {
core.info('Cache is disabled: will not save state for later builds.');
@@ -137302,7 +137292,7 @@ function save(gradleUserHome, cacheListener, daemonController) {
}
}
yield core.group('Caching Gradle state', () => __awaiter(this, void 0, void 0, function* () {
return new cache_base_1.GradleStateCache(gradleUserHome).save(cacheListener);
return new cache_base_1.GradleStateCache(userHome, gradleUserHome).save(cacheListener);
}));
});
}
@@ -138159,10 +138149,12 @@ const build_results_1 = __nccwpck_require__(82107);
const cache_reporting_1 = __nccwpck_require__(66674);
const daemon_controller_1 = __nccwpck_require__(85146);
const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED';
const USER_HOME = 'USER_HOME';
const GRADLE_USER_HOME = 'GRADLE_USER_HOME';
const CACHE_LISTENER = 'CACHE_LISTENER';
function setup() {
return __awaiter(this, void 0, void 0, function* () {
const userHome = yield determineUserHome();
const gradleUserHome = yield determineGradleUserHome();
if (process.env[GRADLE_SETUP_VAR]) {
core.info('Gradle setup only performed on first gradle-build-action step in workflow.');
@@ -138170,9 +138162,10 @@ function setup() {
}
core.exportVariable(GRADLE_SETUP_VAR, true);
core.saveState(GRADLE_SETUP_VAR, true);
core.saveState(USER_HOME, userHome);
core.saveState(GRADLE_USER_HOME, gradleUserHome);
const cacheListener = new cache_reporting_1.CacheListener();
yield caches.restore(gradleUserHome, cacheListener);
yield caches.restore(userHome, gradleUserHome, cacheListener);
core.saveState(CACHE_LISTENER, cacheListener.stringify());
yield dependencyGraph.setup(params.getDependencyGraphOption());
});
@@ -138186,10 +138179,11 @@ function complete() {
}
core.info('In post-action step');
const buildResults = (0, build_results_1.loadBuildResults)();
const userHome = core.getState(USER_HOME);
const gradleUserHome = core.getState(GRADLE_USER_HOME);
const cacheListener = cache_reporting_1.CacheListener.rehydrate(core.getState(CACHE_LISTENER));
const daemonController = new daemon_controller_1.DaemonController(buildResults);
yield caches.save(gradleUserHome, cacheListener, daemonController);
yield caches.save(userHome, gradleUserHome, cacheListener, daemonController);
yield jobSummary.generateJobSummary(buildResults, cacheListener);
yield dependencyGraph.complete(params.getDependencyGraphOption());
core.info('Completed post-action step');

File diff suppressed because one or more lines are too long

View File

@@ -17,22 +17,24 @@ export class GradleStateCache {
private cacheName: string
private cacheDescription: string
protected readonly userHome: string
protected readonly gradleUserHome: string
constructor(gradleUserHome: string) {
constructor(userHome: string, gradleUserHome: string) {
this.userHome = userHome
this.gradleUserHome = gradleUserHome
this.cacheName = 'gradle'
this.cacheDescription = 'Gradle User Home'
}
init(): void {
const actionCacheDir = path.resolve(this.gradleUserHome, '.gradle-build-action')
fs.mkdirSync(actionCacheDir, {recursive: true})
this.initializeGradleUserHome()
const initScriptsDir = path.resolve(this.gradleUserHome, 'init.d')
fs.mkdirSync(initScriptsDir, {recursive: true})
this.initializeGradleUserHome(this.gradleUserHome, initScriptsDir)
// Export the GRADLE_ENCRYPTION_KEY variable if provided
const encryptionKey = params.getCacheEncryptionKey()
if (encryptionKey) {
core.exportVariable('GRADLE_ENCRYPTION_KEY', encryptionKey)
}
}
cacheOutputExists(): boolean {
@@ -181,23 +183,21 @@ export class GradleStateCache {
return path.resolve(this.gradleUserHome, rawPath)
}
private initializeGradleUserHome(gradleUserHome: string, initScriptsDir: string): void {
// Ensure that pre-installed java versions are detected. Only add property if it isn't already defined.
const gradleProperties = path.resolve(gradleUserHome, 'gradle.properties')
const existingGradleProperties = fs.existsSync(gradleProperties)
? fs.readFileSync(gradleProperties, 'utf8')
: ''
if (!existingGradleProperties.includes('org.gradle.java.installations.fromEnv=')) {
fs.appendFileSync(
gradleProperties,
`
# Auto-detect pre-installed JDKs
org.gradle.java.installations.fromEnv=JAVA_HOME_8_X64,JAVA_HOME_11_X64,JAVA_HOME_17_X64
`
)
}
private initializeGradleUserHome(): void {
// Create a directory for storing action metadata
const actionCacheDir = path.resolve(this.gradleUserHome, '.gradle-build-action')
fs.mkdirSync(actionCacheDir, {recursive: true})
// Copy init scripts from src/resources
this.copyInitScripts()
// Copy the default toolchain definitions to `~/.m2/toolchains.xml`
this.registerToolchains()
}
private copyInitScripts(): void {
// Copy init scripts from src/resources to Gradle UserHome
const initScriptsDir = path.resolve(this.gradleUserHome, 'init.d')
fs.mkdirSync(initScriptsDir, {recursive: true})
const initScriptFilenames = [
'gradle-build-action.build-result-capture.init.gradle',
'gradle-build-action.build-result-capture-service.plugin.groovy',
@@ -206,15 +206,36 @@ org.gradle.java.installations.fromEnv=JAVA_HOME_8_X64,JAVA_HOME_11_X64,JAVA_HOME
'gradle-build-action.inject-gradle-enterprise.init.gradle'
]
for (const initScriptFilename of initScriptFilenames) {
const initScriptContent = this.readInitScriptAsString(initScriptFilename)
const initScriptContent = this.readResourceFileAsString('init-scripts', initScriptFilename)
const initScriptPath = path.resolve(initScriptsDir, initScriptFilename)
fs.writeFileSync(initScriptPath, initScriptContent)
}
}
private readInitScriptAsString(resource: string): string {
private registerToolchains(): void {
const preInstalledToolchains = this.readResourceFileAsString('toolchains.xml')
const m2dir = path.resolve(this.userHome, '.m2')
const toolchainXmlTarget = path.resolve(m2dir, 'toolchains.xml')
if (!fs.existsSync(toolchainXmlTarget)) {
// Write a new toolchains.xml file if it doesn't exist
fs.mkdirSync(m2dir, {recursive: true})
fs.writeFileSync(toolchainXmlTarget, preInstalledToolchains)
core.info(`Wrote default JDK locations to ${toolchainXmlTarget}`)
} else {
// Merge into an existing toolchains.xml file
const existingToolchainContent = fs.readFileSync(toolchainXmlTarget, 'utf8')
const appendedContent = preInstalledToolchains.split('<toolchains>').pop()!
const mergedContent = existingToolchainContent.replace('</toolchains>', appendedContent)
fs.writeFileSync(toolchainXmlTarget, mergedContent)
core.info(`Merged default JDK locations into ${toolchainXmlTarget}`)
}
}
private readResourceFileAsString(...paths: string[]): string {
// Resolving relative to __dirname will allow node to find the resource at runtime
const absolutePath = path.resolve(__dirname, '..', '..', 'src', 'resources', 'init-scripts', resource)
const absolutePath = path.resolve(__dirname, '..', '..', 'src', 'resources', ...paths)
return fs.readFileSync(absolutePath, 'utf8')
}

View File

@@ -1,6 +1,5 @@
import path from 'path'
import fs from 'fs'
import crypto from 'crypto'
import * as core from '@actions/core'
import * as glob from '@actions/glob'
import * as semver from 'semver'
@@ -383,8 +382,6 @@ export class ConfigurationCacheEntryExtractor extends AbstractEntryExtractor {
return
}
const encryptionKey = this.getAESEncryptionKey()
core.exportVariable('GRADLE_ENCRYPTION_KEY', encryptionKey)
return await super.restore(listener)
}
@@ -416,12 +413,6 @@ export class ConfigurationCacheEntryExtractor extends AbstractEntryExtractor {
await super.extract(listener)
}
private getAESEncryptionKey(): string | undefined {
const secret = params.getCacheEncryptionKey()
const key = crypto.pbkdf2Sync(secret, '', 1000, 16, 'sha256')
return key.toString('base64')
}
/**
* Extract cache entries for the configuration cache in each project.
*/

View File

@@ -86,10 +86,10 @@ export function generateCacheKey(cacheName: string): CacheKey {
// At the most general level, share caches for all executions on the same OS
const cacheKeyForEnvironment = `${cacheKeyBase}|${getCacheKeyEnvironment()}`
// Prefer caches that run this job
// Then prefer caches that run job with the same ID
const cacheKeyForJob = `${cacheKeyForEnvironment}|${getCacheKeyJob()}`
// Prefer (even more) jobs that run this job with the same context (matrix)
// Prefer (even more) jobs that run this job in the same workflow with the same context (matrix)
const cacheKeyForJobContext = `${cacheKeyForJob}[${getCacheKeyJobInstance()}]`
// Exact match on Git SHA
@@ -113,12 +113,7 @@ function getCacheKeyEnvironment(): string {
}
function getCacheKeyJob(): string {
return process.env[CACHE_KEY_JOB_VAR] || getCacheKeyForJob(github.context.workflow, github.context.job)
}
export function getCacheKeyForJob(workflowName: string, jobId: string): string {
const sanitizedWorkflow = workflowName.replace(/,/g, '').toLowerCase()
return `${sanitizedWorkflow}-${jobId}`
return process.env[CACHE_KEY_JOB_VAR] || github.context.job
}
function getCacheKeyJobInstance(): string {
@@ -127,25 +122,11 @@ function getCacheKeyJobInstance(): string {
return override
}
// By default, we hash the full `matrix` data for the run, to uniquely identify this job invocation
// By default, we hash the workflow name and the full `matrix` data for the run, to uniquely identify this job invocation
// The only way we can obtain the `matrix` data is via the `workflow-job-context` parameter in action.yml.
const workflowName = github.context.workflow
const workflowJobContext = params.getJobMatrix()
return hashStrings([workflowJobContext])
}
export function getUniqueLabelForJobInstance(): string {
return getUniqueLabelForJobInstanceValues(github.context.workflow, github.context.job, params.getJobMatrix())
}
export function getUniqueLabelForJobInstanceValues(workflow: string, jobId: string, matrixJson: string): string {
const matrix = JSON.parse(matrixJson)
const matrixString = Object.values(matrix).join('-')
const label = matrixString ? `${workflow}-${jobId}-${matrixString}` : `${workflow}-${jobId}`
return sanitize(label)
}
function sanitize(value: string): string {
return value.replace(/[^a-zA-Z0-9_-]/g, '').toLowerCase()
return hashStrings([workflowName, workflowJobContext])
}
function getCacheKeyJobExecution(): string {

View File

@@ -13,7 +13,7 @@ import {CacheCleaner} from './cache-cleaner'
const CACHE_RESTORED_VAR = 'GRADLE_BUILD_ACTION_CACHE_RESTORED'
export async function restore(gradleUserHome: string, cacheListener: CacheListener): Promise<void> {
export async function restore(userHome: string, gradleUserHome: string, cacheListener: CacheListener): Promise<void> {
// Bypass restore cache on all but first action step in workflow.
if (process.env[CACHE_RESTORED_VAR]) {
core.info('Cache only restored on first action step.')
@@ -21,7 +21,7 @@ export async function restore(gradleUserHome: string, cacheListener: CacheListen
}
core.exportVariable(CACHE_RESTORED_VAR, true)
const gradleStateCache = new GradleStateCache(gradleUserHome)
const gradleStateCache = new GradleStateCache(userHome, gradleUserHome)
if (isCacheDisabled()) {
core.info('Cache is disabled: will not restore state from previous builds.')
@@ -65,6 +65,7 @@ export async function restore(gradleUserHome: string, cacheListener: CacheListen
}
export async function save(
userHome: string,
gradleUserHome: string,
cacheListener: CacheListener,
daemonController: DaemonController
@@ -98,6 +99,6 @@ export async function save(
}
await core.group('Caching Gradle state', async () => {
return new GradleStateCache(gradleUserHome).save(cacheListener)
return new GradleStateCache(userHome, gradleUserHome).save(cacheListener)
})
}

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<toolchains>
<!-- JDK Toolchains installed by default on GitHub-hosted runners -->
<toolchain>
<type>jdk</type>
<provides>
<version>8</version>
<vendor>Eclipse Temurin</vendor>
</provides>
<configuration>
<jdkHome>${env.JAVA_HOME_8_X64}</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>11</version>
<vendor>Eclipse Temurin</vendor>
</provides>
<configuration>
<jdkHome>${env.JAVA_HOME_11_X64}</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>17</version>
<vendor>Eclipse Temurin</vendor>
</provides>
<configuration>
<jdkHome>${env.JAVA_HOME_17_X64}</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>21</version>
<vendor>Eclipse Temurin</vendor>
</provides>
<configuration>
<jdkHome>${env.JAVA_HOME_21_X64}</jdkHome>
</configuration>
</toolchain>
</toolchains>

View File

@@ -13,10 +13,12 @@ import {CacheListener} from './cache-reporting'
import {DaemonController} from './daemon-controller'
const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED'
const USER_HOME = 'USER_HOME'
const GRADLE_USER_HOME = 'GRADLE_USER_HOME'
const CACHE_LISTENER = 'CACHE_LISTENER'
export async function setup(): Promise<void> {
const userHome = await determineUserHome()
const gradleUserHome = await determineGradleUserHome()
// Bypass setup on all but first action step in workflow.
@@ -29,11 +31,12 @@ export async function setup(): Promise<void> {
// Record setup complete: visible in post-action, to control action completion
core.saveState(GRADLE_SETUP_VAR, true)
// Save the Gradle User Home for use in the post-action step.
// Save the User Home and Gradle User Home for use in the post-action step.
core.saveState(USER_HOME, userHome)
core.saveState(GRADLE_USER_HOME, gradleUserHome)
const cacheListener = new CacheListener()
await caches.restore(gradleUserHome, cacheListener)
await caches.restore(userHome, gradleUserHome, cacheListener)
core.saveState(CACHE_LISTENER, cacheListener.stringify())
@@ -49,11 +52,12 @@ export async function complete(): Promise<void> {
const buildResults = loadBuildResults()
const userHome = core.getState(USER_HOME)
const gradleUserHome = core.getState(GRADLE_USER_HOME)
const cacheListener: CacheListener = CacheListener.rehydrate(core.getState(CACHE_LISTENER))
const daemonController = new DaemonController(buildResults)
await caches.save(gradleUserHome, cacheListener, daemonController)
await caches.save(userHome, gradleUserHome, cacheListener, daemonController)
await jobSummary.generateJobSummary(buildResults, cacheListener)

View File

@@ -17,10 +17,4 @@ describe('cacheUtils-utils', () => {
expect(posixHash).toBe(windowsHash)
})
})
describe('sanitizes workflow name in cache key', () => {
it('with comma', () => {
const cacheKey = cacheUtils.getCacheKeyForJob("Workflow, with,commas", "JOB_ID")
expect(cacheKey).toBe('workflow withcommas-JOB_ID')
})
})
})