Merge branch 'dd/cache-cleanup-test-fix'

Disable cache-cleanup on Windows
  Fix OSX by avoiding GNU-specific touch options
This commit is contained in:
Daz DeBoer 2022-08-25 20:21:59 -06:00
commit 535b494721
No known key found for this signature in database
GPG Key ID: DD6B9F0B06683D5D
8 changed files with 32 additions and 14 deletions

View File

@ -7,7 +7,7 @@ on:
type: string
runner-os:
type: string
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
default: '["ubuntu-latest", "macos-latest"]' # Windows is not yet supported
download-dist:
type: boolean
default: false
@ -34,7 +34,7 @@ jobs:
cache-read-only: false # For testing, allow writing cache entries on non-default branches
- name: Build with 3.1
working-directory: test/jest/resources/cache-cleanup
run: gradle --no-daemon --build-cache -Dcommons_math3_version=3.1 build
run: gradle --no-daemon --build-cache -Dcommons_math3_version="3.1" build
# Second build will use the cache from the first build, but cleanup should remove unused artifacts
assemble-build:
@ -55,7 +55,7 @@ jobs:
gradle-home-cache-cleanup: true
- name: Build with 3.1.1
working-directory: test/jest/resources/cache-cleanup
run: gradle --no-daemon --build-cache -Dcommons_math3_version=3.1.1 build
run: gradle --no-daemon --build-cache -Dcommons_math3_version="3.1.1" build
check-clean-cache:
needs: assemble-build
@ -75,6 +75,7 @@ jobs:
- name: Report Gradle User Home
run: du -hc ~/.gradle/caches/modules-2
- name: Verify cleaned cache
shell: bash
run: |
if [ ! -e ~/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-math3/3.1.1 ]; then
echo "::error ::Should find commons-math3 3.1.1 in cache"

9
dist/main/index.js vendored
View File

@ -65896,7 +65896,7 @@ class CacheCleaner {
}
ageAllFiles(fileName = '*') {
return __awaiter(this, void 0, void 0, function* () {
yield exec.exec('find', [this.gradleUserHome, '-name', fileName, '-exec', 'touch', '-m', '-d', '1970-01-01', '{}', '+'], {});
yield exec.exec('find', [this.gradleUserHome, '-name', fileName, '-exec', 'touch', '-m', '-t', '197001010000', '{}', '+'], {});
});
}
touchAllFiles(fileName = '*') {
@ -66494,7 +66494,12 @@ function isCacheDebuggingEnabled() {
}
exports.isCacheDebuggingEnabled = isCacheDebuggingEnabled;
function isCacheCleanupEnabled() {
return core.getBooleanInput(CACHE_CLEANUP_ENABLED_PARAMETER);
const userEnabled = core.getBooleanInput(CACHE_CLEANUP_ENABLED_PARAMETER);
if (userEnabled && process.platform === 'win32') {
core.warning('Cache cleanup is not yet supported on Windows');
return false;
}
return userEnabled;
}
exports.isCacheCleanupEnabled = isCacheCleanupEnabled;
class CacheKey {

File diff suppressed because one or more lines are too long

9
dist/post/index.js vendored
View File

@ -64947,7 +64947,7 @@ class CacheCleaner {
}
ageAllFiles(fileName = '*') {
return __awaiter(this, void 0, void 0, function* () {
yield exec.exec('find', [this.gradleUserHome, '-name', fileName, '-exec', 'touch', '-m', '-d', '1970-01-01', '{}', '+'], {});
yield exec.exec('find', [this.gradleUserHome, '-name', fileName, '-exec', 'touch', '-m', '-t', '197001010000', '{}', '+'], {});
});
}
touchAllFiles(fileName = '*') {
@ -65545,7 +65545,12 @@ function isCacheDebuggingEnabled() {
}
exports.isCacheDebuggingEnabled = isCacheDebuggingEnabled;
function isCacheCleanupEnabled() {
return core.getBooleanInput(CACHE_CLEANUP_ENABLED_PARAMETER);
const userEnabled = core.getBooleanInput(CACHE_CLEANUP_ENABLED_PARAMETER);
if (userEnabled && process.platform === 'win32') {
core.warning('Cache cleanup is not yet supported on Windows');
return false;
}
return userEnabled;
}
exports.isCacheCleanupEnabled = isCacheCleanupEnabled;
class CacheKey {

File diff suppressed because one or more lines are too long

View File

@ -48,7 +48,7 @@ export class CacheCleaner {
private async ageAllFiles(fileName = '*'): Promise<void> {
await exec.exec(
'find',
[this.gradleUserHome, '-name', fileName, '-exec', 'touch', '-m', '-d', '1970-01-01', '{}', '+'],
[this.gradleUserHome, '-name', fileName, '-exec', 'touch', '-m', '-t', '197001010000', '{}', '+'],
{}
)
}

View File

@ -48,7 +48,14 @@ export function isCacheDebuggingEnabled(): boolean {
}
export function isCacheCleanupEnabled(): boolean {
return core.getBooleanInput(CACHE_CLEANUP_ENABLED_PARAMETER)
const userEnabled = core.getBooleanInput(CACHE_CLEANUP_ENABLED_PARAMETER)
if (userEnabled && process.platform === 'win32') {
core.warning('Cache cleanup is not yet supported on Windows')
return false
}
return userEnabled
}
/**

View File

@ -63,17 +63,17 @@ test('will cleanup unused gradle versions', async () => {
})
async function runGradleBuild(projectRoot: string, args: string, version: string = '3.1'): Promise<void> {
const status31 = await exec.exec(`gradle -g HOME --no-daemon --build-cache -Dcommons_math3_version=${version} ${args}`, [], {
const status31 = await exec.exec(`gradle -g HOME --no-daemon --build-cache -Dcommons_math3_version="${version}" ${args}`, [], {
cwd: projectRoot
})
console.log(`Gradle User Home initialized with commons_math3_version=${version} ${args}`)
}
async function runGradleWrapperBuild(projectRoot: string, args: string, version: string = '3.1'): Promise<void> {
const status31 = await exec.exec(`./gradlew -g HOME --no-daemon --build-cache -Dcommons_math3_version=${version} ${args}`, [], {
const status31 = await exec.exec(`./gradlew -g HOME --no-daemon --build-cache -Dcommons_math3_version="${version}" ${args}`, [], {
cwd: projectRoot
})
console.log(`Gradle User Home initialized with commons_math3_version=${version} ${args}`)
console.log(`Gradle User Home initialized with commons_math3_version="${version}" ${args}`)
}
function prepareTestProject(): string {