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 type: string
runner-os: runner-os:
type: string type: string
default: '["ubuntu-latest", "windows-latest", "macos-latest"]' default: '["ubuntu-latest", "macos-latest"]' # Windows is not yet supported
download-dist: download-dist:
type: boolean type: boolean
default: false default: false
@ -34,7 +34,7 @@ jobs:
cache-read-only: false # For testing, allow writing cache entries on non-default branches cache-read-only: false # For testing, allow writing cache entries on non-default branches
- name: Build with 3.1 - name: Build with 3.1
working-directory: test/jest/resources/cache-cleanup 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 # Second build will use the cache from the first build, but cleanup should remove unused artifacts
assemble-build: assemble-build:
@ -55,7 +55,7 @@ jobs:
gradle-home-cache-cleanup: true gradle-home-cache-cleanup: true
- name: Build with 3.1.1 - name: Build with 3.1.1
working-directory: test/jest/resources/cache-cleanup 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: check-clean-cache:
needs: assemble-build needs: assemble-build
@ -75,6 +75,7 @@ jobs:
- name: Report Gradle User Home - name: Report Gradle User Home
run: du -hc ~/.gradle/caches/modules-2 run: du -hc ~/.gradle/caches/modules-2
- name: Verify cleaned cache - name: Verify cleaned cache
shell: bash
run: | run: |
if [ ! -e ~/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-math3/3.1.1 ]; then 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" 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 = '*') { ageAllFiles(fileName = '*') {
return __awaiter(this, void 0, void 0, function* () { 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 = '*') { touchAllFiles(fileName = '*') {
@ -66494,7 +66494,12 @@ function isCacheDebuggingEnabled() {
} }
exports.isCacheDebuggingEnabled = isCacheDebuggingEnabled; exports.isCacheDebuggingEnabled = isCacheDebuggingEnabled;
function isCacheCleanupEnabled() { 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; exports.isCacheCleanupEnabled = isCacheCleanupEnabled;
class CacheKey { 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 = '*') { ageAllFiles(fileName = '*') {
return __awaiter(this, void 0, void 0, function* () { 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 = '*') { touchAllFiles(fileName = '*') {
@ -65545,7 +65545,12 @@ function isCacheDebuggingEnabled() {
} }
exports.isCacheDebuggingEnabled = isCacheDebuggingEnabled; exports.isCacheDebuggingEnabled = isCacheDebuggingEnabled;
function isCacheCleanupEnabled() { 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; exports.isCacheCleanupEnabled = isCacheCleanupEnabled;
class CacheKey { 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> { private async ageAllFiles(fileName = '*'): Promise<void> {
await exec.exec( await exec.exec(
'find', '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 { 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> { 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 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}`)
} }
async function runGradleWrapperBuild(projectRoot: string, args: string, version: string = '3.1'): Promise<void> { 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 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 { function prepareTestProject(): string {