mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-26 19:12:10 +00:00
Merge pull request #111 from gradle/dd/cache-report
Add a report to assist with diagnosing and optimizing cache performance
This commit is contained in:
commit
2a57ddf74a
14 changed files with 779 additions and 283 deletions
95
__tests__/cache-base.test.ts
Normal file
95
__tests__/cache-base.test.ts
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
import {CacheEntryListener, CacheListener} from '../src/cache-base'
|
||||||
|
|
||||||
|
describe('caching report', () => {
|
||||||
|
describe('reports not fully restored', () => {
|
||||||
|
it('with one requested entry report', async () => {
|
||||||
|
const report = new CacheListener()
|
||||||
|
report.entry('foo').markRequested('1', ['2'])
|
||||||
|
report.entry('bar').markRequested('3').markRestored('4', 500)
|
||||||
|
expect(report.fullyRestored).toBe(false)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('reports fully restored', () => {
|
||||||
|
it('when empty', async () => {
|
||||||
|
const report = new CacheListener()
|
||||||
|
expect(report.fullyRestored).toBe(true)
|
||||||
|
})
|
||||||
|
it('with empty entry reports', async () => {
|
||||||
|
const report = new CacheListener()
|
||||||
|
report.entry('foo')
|
||||||
|
report.entry('bar')
|
||||||
|
expect(report.fullyRestored).toBe(true)
|
||||||
|
})
|
||||||
|
it('with restored entry report', async () => {
|
||||||
|
const report = new CacheListener()
|
||||||
|
report.entry('bar').markRequested('3').markRestored('4', 300)
|
||||||
|
expect(report.fullyRestored).toBe(true)
|
||||||
|
})
|
||||||
|
it('with multiple restored entry reportss', async () => {
|
||||||
|
const report = new CacheListener()
|
||||||
|
report.entry('foo').markRestored('4', 3300)
|
||||||
|
report.entry('bar').markRequested('3').markRestored('4', 333)
|
||||||
|
expect(report.fullyRestored).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('can be stringified and rehydrated', () => {
|
||||||
|
it('when empty', async () => {
|
||||||
|
const report = new CacheListener()
|
||||||
|
|
||||||
|
const stringRep = report.stringify()
|
||||||
|
const reportClone: CacheListener = CacheListener.rehydrate(stringRep)
|
||||||
|
|
||||||
|
expect(reportClone.cacheEntries).toEqual([])
|
||||||
|
|
||||||
|
// Can call methods on rehydrated
|
||||||
|
expect(reportClone.entry('foo')).toBeInstanceOf(CacheEntryListener)
|
||||||
|
})
|
||||||
|
it('with entry reports', async () => {
|
||||||
|
const report = new CacheListener()
|
||||||
|
report.entry('foo')
|
||||||
|
report.entry('bar')
|
||||||
|
report.entry('baz')
|
||||||
|
|
||||||
|
const stringRep = report.stringify()
|
||||||
|
const reportClone: CacheListener = CacheListener.rehydrate(stringRep)
|
||||||
|
|
||||||
|
expect(reportClone.cacheEntries.length).toBe(3)
|
||||||
|
expect(reportClone.cacheEntries[0].entryName).toBe('foo')
|
||||||
|
expect(reportClone.cacheEntries[1].entryName).toBe('bar')
|
||||||
|
expect(reportClone.cacheEntries[2].entryName).toBe('baz')
|
||||||
|
|
||||||
|
expect(reportClone.entry('foo')).toBe(reportClone.cacheEntries[0])
|
||||||
|
})
|
||||||
|
it('with rehydrated entry report', async () => {
|
||||||
|
const report = new CacheListener()
|
||||||
|
const entryReport = report.entry('foo')
|
||||||
|
entryReport.markRequested('1', ['2', '3'])
|
||||||
|
entryReport.markSaved('4', 100)
|
||||||
|
|
||||||
|
const stringRep = report.stringify()
|
||||||
|
const reportClone: CacheListener = CacheListener.rehydrate(stringRep)
|
||||||
|
const entryClone = reportClone.entry('foo')
|
||||||
|
|
||||||
|
expect(entryClone.requestedKey).toBe('1')
|
||||||
|
expect(entryClone.requestedRestoreKeys).toEqual(['2', '3'])
|
||||||
|
expect(entryClone.savedKey).toBe('4')
|
||||||
|
})
|
||||||
|
it('with live entry report', async () => {
|
||||||
|
const report = new CacheListener()
|
||||||
|
const entryReport = report.entry('foo')
|
||||||
|
entryReport.markRequested('1', ['2', '3'])
|
||||||
|
|
||||||
|
const stringRep = report.stringify()
|
||||||
|
const reportClone: CacheListener = CacheListener.rehydrate(stringRep)
|
||||||
|
const entryClone = reportClone.entry('foo')
|
||||||
|
|
||||||
|
// Check type and call method on rehydrated entry report
|
||||||
|
expect(entryClone).toBeInstanceOf(CacheEntryListener)
|
||||||
|
entryClone.markSaved('4', 100)
|
||||||
|
|
||||||
|
expect(entryClone.requestedKey).toBe('1')
|
||||||
|
expect(entryClone.requestedRestoreKeys).toEqual(['2', '3'])
|
||||||
|
expect(entryClone.savedKey).toBe('4')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
|
@ -1,5 +1,4 @@
|
||||||
import * as cacheUtils from '../src/cache-utils'
|
import * as cacheUtils from '../src/cache-utils'
|
||||||
import * as path from 'path'
|
|
||||||
|
|
||||||
describe('cacheUtils-utils', () => {
|
describe('cacheUtils-utils', () => {
|
||||||
describe('can hash', () => {
|
describe('can hash', () => {
|
||||||
|
|
2
dist/main/index.js
vendored
2
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/main/index.js.map
vendored
2
dist/main/index.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/post/index.js
vendored
2
dist/post/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/post/index.js.map
vendored
2
dist/post/index.js.map
vendored
File diff suppressed because one or more lines are too long
261
package-lock.json
generated
261
package-lock.json
generated
|
@ -3180,6 +3180,11 @@
|
||||||
"eslint-visitor-keys": "^2.0.0"
|
"eslint-visitor-keys": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@yarnpkg/lockfile": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ=="
|
||||||
|
},
|
||||||
"@zeit/ncc": {
|
"@zeit/ncc": {
|
||||||
"version": "0.22.3",
|
"version": "0.22.3",
|
||||||
"resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.22.3.tgz",
|
"resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.22.3.tgz",
|
||||||
|
@ -3403,7 +3408,6 @@
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
|
||||||
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"fill-range": "^7.0.1"
|
"fill-range": "^7.0.1"
|
||||||
}
|
}
|
||||||
|
@ -3760,8 +3764,7 @@
|
||||||
"escape-string-regexp": {
|
"escape-string-regexp": {
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
||||||
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
|
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"eslint": {
|
"eslint": {
|
||||||
"version": "7.30.0",
|
"version": "7.30.0",
|
||||||
|
@ -4280,7 +4283,6 @@
|
||||||
"version": "7.0.1",
|
"version": "7.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||||
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"to-regex-range": "^5.0.1"
|
"to-regex-range": "^5.0.1"
|
||||||
}
|
}
|
||||||
|
@ -4294,6 +4296,14 @@
|
||||||
"locate-path": "^2.0.0"
|
"locate-path": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"find-yarn-workspace-root": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==",
|
||||||
|
"requires": {
|
||||||
|
"micromatch": "^4.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flat-cache": {
|
"flat-cache": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz",
|
||||||
|
@ -4321,11 +4331,20 @@
|
||||||
"integrity": "sha512-XprP7lDrVT+kE2c2YlfiV+IfS9zxukiIOvNamPNsImNhXadSsQEbosItdL9bUQlCZXR13SvPk20BjWSWLA7m4A==",
|
"integrity": "sha512-XprP7lDrVT+kE2c2YlfiV+IfS9zxukiIOvNamPNsImNhXadSsQEbosItdL9bUQlCZXR13SvPk20BjWSWLA7m4A==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"fs-extra": {
|
||||||
|
"version": "7.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz",
|
||||||
|
"integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==",
|
||||||
|
"requires": {
|
||||||
|
"graceful-fs": "^4.1.2",
|
||||||
|
"jsonfile": "^4.0.0",
|
||||||
|
"universalify": "^0.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"fs.realpath": {
|
"fs.realpath": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
|
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"fsevents": {
|
"fsevents": {
|
||||||
"version": "2.3.2",
|
"version": "2.3.2",
|
||||||
|
@ -4385,7 +4404,6 @@
|
||||||
"version": "7.1.4",
|
"version": "7.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz",
|
||||||
"integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==",
|
"integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"fs.realpath": "^1.0.0",
|
"fs.realpath": "^1.0.0",
|
||||||
"inflight": "^1.0.4",
|
"inflight": "^1.0.4",
|
||||||
|
@ -4438,8 +4456,7 @@
|
||||||
"graceful-fs": {
|
"graceful-fs": {
|
||||||
"version": "4.2.2",
|
"version": "4.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz",
|
||||||
"integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==",
|
"integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"has": {
|
"has": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
|
@ -4621,7 +4638,6 @@
|
||||||
"version": "1.0.6",
|
"version": "1.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||||
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"once": "^1.3.0",
|
"once": "^1.3.0",
|
||||||
"wrappy": "1"
|
"wrappy": "1"
|
||||||
|
@ -4630,8 +4646,7 @@
|
||||||
"inherits": {
|
"inherits": {
|
||||||
"version": "2.0.4",
|
"version": "2.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"ip-regex": {
|
"ip-regex": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
|
@ -4665,6 +4680,21 @@
|
||||||
"integrity": "sha512-J1DcMe8UYTBSrKezuIUTUwjXsho29693unXM2YhJUTR2txK/eG47bvNa/wipPFmZFgr/N6f1GA66dv0mEyTIyQ==",
|
"integrity": "sha512-J1DcMe8UYTBSrKezuIUTUwjXsho29693unXM2YhJUTR2txK/eG47bvNa/wipPFmZFgr/N6f1GA66dv0mEyTIyQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"is-ci": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-ci/-/is-ci-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==",
|
||||||
|
"requires": {
|
||||||
|
"ci-info": "^2.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ci-info": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"is-core-module": {
|
"is-core-module": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz",
|
||||||
|
@ -4680,6 +4710,11 @@
|
||||||
"integrity": "sha512-/b4ZVsG7Z5XVtIxs/h9W8nvfLgSAyKYdtGWQLbqy6jA1icmgjf8WCoTKgeS4wy5tYaPePouzFMANbnj94c2Z+A==",
|
"integrity": "sha512-/b4ZVsG7Z5XVtIxs/h9W8nvfLgSAyKYdtGWQLbqy6jA1icmgjf8WCoTKgeS4wy5tYaPePouzFMANbnj94c2Z+A==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"is-docker": {
|
||||||
|
"version": "2.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz",
|
||||||
|
"integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ=="
|
||||||
|
},
|
||||||
"is-extglob": {
|
"is-extglob": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
|
||||||
|
@ -4716,8 +4751,7 @@
|
||||||
"is-number": {
|
"is-number": {
|
||||||
"version": "7.0.0",
|
"version": "7.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
||||||
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"is-number-object": {
|
"is-number-object": {
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
|
@ -4762,11 +4796,18 @@
|
||||||
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
|
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"is-wsl": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
|
||||||
|
"requires": {
|
||||||
|
"is-docker": "^2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"isexe": {
|
"isexe": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||||
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
|
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"istanbul-lib-coverage": {
|
"istanbul-lib-coverage": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
|
@ -7752,6 +7793,22 @@
|
||||||
"minimist": "^1.2.0"
|
"minimist": "^1.2.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"jsonfile": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
|
||||||
|
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
|
||||||
|
"requires": {
|
||||||
|
"graceful-fs": "^4.1.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"klaw-sync": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==",
|
||||||
|
"requires": {
|
||||||
|
"graceful-fs": "^4.1.11"
|
||||||
|
}
|
||||||
|
},
|
||||||
"kleur": {
|
"kleur": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
|
||||||
|
@ -7877,6 +7934,22 @@
|
||||||
"integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
|
"integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"micromatch": {
|
||||||
|
"version": "4.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz",
|
||||||
|
"integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==",
|
||||||
|
"requires": {
|
||||||
|
"braces": "^3.0.1",
|
||||||
|
"picomatch": "^2.2.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"picomatch": {
|
||||||
|
"version": "2.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz",
|
||||||
|
"integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"mime-db": {
|
"mime-db": {
|
||||||
"version": "1.44.0",
|
"version": "1.44.0",
|
||||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz",
|
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz",
|
||||||
|
@ -7907,8 +7980,7 @@
|
||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "1.2.5",
|
"version": "1.2.5",
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
|
||||||
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
|
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"ms": {
|
"ms": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
|
@ -7922,6 +7994,11 @@
|
||||||
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
|
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"nice-try": {
|
||||||
|
"version": "1.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz",
|
||||||
|
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ=="
|
||||||
|
},
|
||||||
"node-fetch": {
|
"node-fetch": {
|
||||||
"version": "2.6.1",
|
"version": "2.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||||
|
@ -8032,6 +8109,15 @@
|
||||||
"mimic-fn": "^2.1.0"
|
"mimic-fn": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"open": {
|
||||||
|
"version": "7.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz",
|
||||||
|
"integrity": "sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==",
|
||||||
|
"requires": {
|
||||||
|
"is-docker": "^2.0.0",
|
||||||
|
"is-wsl": "^2.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"optionator": {
|
"optionator": {
|
||||||
"version": "0.9.1",
|
"version": "0.9.1",
|
||||||
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz",
|
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz",
|
||||||
|
@ -8046,6 +8132,11 @@
|
||||||
"word-wrap": "^1.2.3"
|
"word-wrap": "^1.2.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"os-tmpdir": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
|
||||||
|
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ="
|
||||||
|
},
|
||||||
"p-limit": {
|
"p-limit": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz",
|
||||||
|
@ -8089,6 +8180,128 @@
|
||||||
"json-parse-better-errors": "^1.0.1"
|
"json-parse-better-errors": "^1.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"patch-package": {
|
||||||
|
"version": "6.4.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/patch-package/-/patch-package-6.4.7.tgz",
|
||||||
|
"integrity": "sha512-S0vh/ZEafZ17hbhgqdnpunKDfzHQibQizx9g8yEf5dcVk3KOflOfdufRXQX8CSEkyOQwuM/bNz1GwKvFj54kaQ==",
|
||||||
|
"requires": {
|
||||||
|
"@yarnpkg/lockfile": "^1.1.0",
|
||||||
|
"chalk": "^2.4.2",
|
||||||
|
"cross-spawn": "^6.0.5",
|
||||||
|
"find-yarn-workspace-root": "^2.0.0",
|
||||||
|
"fs-extra": "^7.0.1",
|
||||||
|
"is-ci": "^2.0.0",
|
||||||
|
"klaw-sync": "^6.0.0",
|
||||||
|
"minimist": "^1.2.0",
|
||||||
|
"open": "^7.4.2",
|
||||||
|
"rimraf": "^2.6.3",
|
||||||
|
"semver": "^5.6.0",
|
||||||
|
"slash": "^2.0.0",
|
||||||
|
"tmp": "^0.0.33"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ansi-styles": {
|
||||||
|
"version": "3.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
|
||||||
|
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
|
||||||
|
"requires": {
|
||||||
|
"color-convert": "^1.9.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"chalk": {
|
||||||
|
"version": "2.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
|
||||||
|
"integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
|
||||||
|
"requires": {
|
||||||
|
"ansi-styles": "^3.2.1",
|
||||||
|
"escape-string-regexp": "^1.0.5",
|
||||||
|
"supports-color": "^5.3.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"color-convert": {
|
||||||
|
"version": "1.9.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
|
||||||
|
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
|
||||||
|
"requires": {
|
||||||
|
"color-name": "1.1.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"color-name": {
|
||||||
|
"version": "1.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
|
||||||
|
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
|
||||||
|
},
|
||||||
|
"cross-spawn": {
|
||||||
|
"version": "6.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz",
|
||||||
|
"integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==",
|
||||||
|
"requires": {
|
||||||
|
"nice-try": "^1.0.4",
|
||||||
|
"path-key": "^2.0.1",
|
||||||
|
"semver": "^5.5.0",
|
||||||
|
"shebang-command": "^1.2.0",
|
||||||
|
"which": "^1.2.9"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"has-flag": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
||||||
|
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0="
|
||||||
|
},
|
||||||
|
"path-key": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz",
|
||||||
|
"integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A="
|
||||||
|
},
|
||||||
|
"rimraf": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
|
||||||
|
"requires": {
|
||||||
|
"glob": "^7.1.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"semver": {
|
||||||
|
"version": "5.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
|
||||||
|
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ=="
|
||||||
|
},
|
||||||
|
"shebang-command": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz",
|
||||||
|
"integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=",
|
||||||
|
"requires": {
|
||||||
|
"shebang-regex": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"shebang-regex": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM="
|
||||||
|
},
|
||||||
|
"slash": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A=="
|
||||||
|
},
|
||||||
|
"supports-color": {
|
||||||
|
"version": "5.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
||||||
|
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
|
||||||
|
"requires": {
|
||||||
|
"has-flag": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"which": {
|
||||||
|
"version": "1.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
|
||||||
|
"integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
|
||||||
|
"requires": {
|
||||||
|
"isexe": "^2.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"path-exists": {
|
"path-exists": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
|
||||||
|
@ -8098,8 +8311,7 @@
|
||||||
"path-is-absolute": {
|
"path-is-absolute": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
|
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"path-key": {
|
"path-key": {
|
||||||
"version": "3.1.1",
|
"version": "3.1.1",
|
||||||
|
@ -8671,6 +8883,14 @@
|
||||||
"integrity": "sha512-8hmiGIJMDlwjg7dlJ4yKGLK8EsYqKgPWbG3b4wjJddKNwc7N7Dpn08Df4szr/sZdMVeOstrdYSsqzX6BYbcB+w==",
|
"integrity": "sha512-8hmiGIJMDlwjg7dlJ4yKGLK8EsYqKgPWbG3b4wjJddKNwc7N7Dpn08Df4szr/sZdMVeOstrdYSsqzX6BYbcB+w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"tmp": {
|
||||||
|
"version": "0.0.33",
|
||||||
|
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
|
||||||
|
"integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==",
|
||||||
|
"requires": {
|
||||||
|
"os-tmpdir": "~1.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"tmpl": {
|
"tmpl": {
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz",
|
||||||
|
@ -8687,7 +8907,6 @@
|
||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||||
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"is-number": "^7.0.0"
|
"is-number": "^7.0.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Execute Gradle Build",
|
"description": "Execute Gradle Build",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"postinstall": "patch-package",
|
||||||
"format": "prettier --write **/*.ts",
|
"format": "prettier --write **/*.ts",
|
||||||
"format-check": "prettier --check **/*.ts",
|
"format-check": "prettier --check **/*.ts",
|
||||||
"lint": "eslint src/**/*.ts",
|
"lint": "eslint src/**/*.ts",
|
||||||
|
@ -30,6 +31,7 @@
|
||||||
"@actions/glob": "0.2.0",
|
"@actions/glob": "0.2.0",
|
||||||
"@actions/http-client": "1.0.11",
|
"@actions/http-client": "1.0.11",
|
||||||
"@actions/tool-cache": "1.7.1",
|
"@actions/tool-cache": "1.7.1",
|
||||||
|
"patch-package": "6.4.7",
|
||||||
"string-argv": "0.3.1"
|
"string-argv": "0.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
92
patches/@actions+cache+1.0.7.patch
Normal file
92
patches/@actions+cache+1.0.7.patch
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
diff --git a/node_modules/@actions/cache/lib/cache.d.ts b/node_modules/@actions/cache/lib/cache.d.ts
|
||||||
|
index 805a8e5..d3ab419 100644
|
||||||
|
--- a/node_modules/@actions/cache/lib/cache.d.ts
|
||||||
|
+++ b/node_modules/@actions/cache/lib/cache.d.ts
|
||||||
|
@@ -5,6 +5,11 @@ export declare class ValidationError extends Error {
|
||||||
|
export declare class ReserveCacheError extends Error {
|
||||||
|
constructor(message: string);
|
||||||
|
}
|
||||||
|
+export declare class CacheEntry {
|
||||||
|
+ key: string;
|
||||||
|
+ size?: number;
|
||||||
|
+ constructor(key: string, size?: number);
|
||||||
|
+}
|
||||||
|
/**
|
||||||
|
* Restores cache from keys
|
||||||
|
*
|
||||||
|
@@ -14,7 +19,7 @@ export declare class ReserveCacheError extends Error {
|
||||||
|
* @param downloadOptions cache download options
|
||||||
|
* @returns string returns the key for the cache hit, otherwise returns undefined
|
||||||
|
*/
|
||||||
|
-export declare function restoreCache(paths: string[], primaryKey: string, restoreKeys?: string[], options?: DownloadOptions): Promise<string | undefined>;
|
||||||
|
+export declare function restoreCache(paths: string[], primaryKey: string, restoreKeys?: string[], options?: DownloadOptions): Promise<CacheEntry | undefined>;
|
||||||
|
/**
|
||||||
|
* Saves a list of files with the specified key
|
||||||
|
*
|
||||||
|
@@ -23,4 +28,4 @@ export declare function restoreCache(paths: string[], primaryKey: string, restor
|
||||||
|
* @param options cache upload options
|
||||||
|
* @returns number returns cacheId if the cache was saved successfully and throws an error if save fails
|
||||||
|
*/
|
||||||
|
-export declare function saveCache(paths: string[], key: string, options?: UploadOptions): Promise<number>;
|
||||||
|
+export declare function saveCache(paths: string[], key: string, options?: UploadOptions): Promise<CacheEntry>;
|
||||||
|
diff --git a/node_modules/@actions/cache/lib/cache.js b/node_modules/@actions/cache/lib/cache.js
|
||||||
|
index df78fe0..540114f 100644
|
||||||
|
--- a/node_modules/@actions/cache/lib/cache.js
|
||||||
|
+++ b/node_modules/@actions/cache/lib/cache.js
|
||||||
|
@@ -37,6 +37,13 @@ class ReserveCacheError extends Error {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.ReserveCacheError = ReserveCacheError;
|
||||||
|
+class CacheEntry {
|
||||||
|
+ constructor(key, size) {
|
||||||
|
+ this.key = key;
|
||||||
|
+ this.size = size;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+exports.CacheEntry = CacheEntry;
|
||||||
|
function checkPaths(paths) {
|
||||||
|
if (!paths || paths.length === 0) {
|
||||||
|
throw new ValidationError(`Path Validation Error: At least one directory or file path is required`);
|
||||||
|
@@ -84,6 +91,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
||||||
|
}
|
||||||
|
const archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
|
||||||
|
core.debug(`Archive Path: ${archivePath}`);
|
||||||
|
+ const restoredEntry = new CacheEntry(cacheEntry.cacheKey);
|
||||||
|
try {
|
||||||
|
// Download the cache from the cache entry
|
||||||
|
yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options);
|
||||||
|
@@ -91,6 +99,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
||||||
|
yield tar_1.listTar(archivePath, compressionMethod);
|
||||||
|
}
|
||||||
|
const archiveFileSize = utils.getArchiveFileSizeIsBytes(archivePath);
|
||||||
|
+ restoredEntry.size = archiveFileSize;
|
||||||
|
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||||||
|
yield tar_1.extractTar(archivePath, compressionMethod);
|
||||||
|
core.info('Cache restored successfully');
|
||||||
|
@@ -104,7 +113,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
||||||
|
core.debug(`Failed to delete archive: ${error}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- return cacheEntry.cacheKey;
|
||||||
|
+ return restoredEntry;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.restoreCache = restoreCache;
|
||||||
|
@@ -147,7 +156,7 @@ function saveCache(paths, key, options) {
|
||||||
|
}
|
||||||
|
core.debug(`Saving Cache (ID: ${cacheId})`);
|
||||||
|
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
|
||||||
|
- return cacheId;
|
||||||
|
+ return new CacheEntry(key, archiveFileSize);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.saveCache = saveCache;
|
||||||
|
diff --git a/node_modules/@actions/cache/lib/cache.js.map b/node_modules/@actions/cache/lib/cache.js.map
|
||||||
|
index 05fc369..41b9189 100644
|
||||||
|
--- a/node_modules/@actions/cache/lib/cache.js.map
|
||||||
|
+++ b/node_modules/@actions/cache/lib/cache.js.map
|
||||||
|
@@ -1 +1 @@
|
||||||
|
-{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,oDAAqC;AACrC,2CAA4B;AAC5B,6DAA8C;AAC9C,4EAA6D;AAC7D,wCAA6D;AAG7D,MAAa,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAA;QAC7B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;IACxD,CAAC;CACF;AAND,0CAMC;AAED,MAAa,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;QAC/B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAA;IAC1D,CAAC;CACF;AAND,8CAMC;AAED,SAAS,UAAU,CAAC,KAAe;IACjC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QAChC,MAAM,IAAI,eAAe,CACvB,wEAAwE,CACzE,CAAA;KACF;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,GAAW;IAC3B,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE;QACpB,MAAM,IAAI,eAAe,CACvB,yBAAyB,GAAG,wCAAwC,CACrE,CAAA;KACF;IACD,MAAM,KAAK,GAAG,SAAS,CAAA;IACvB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACpB,MAAM,IAAI,eAAe,CACvB,yBAAyB,GAAG,yBAAyB,CACtD,CAAA;KACF;AACH,CAAC;AAED;;;;;;;;GAQG;AACH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;QAE9D,OAAO,IAAI,UAAU,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA;IAC7C,CAAC;CAAA;AArDD,8BAqDC"}
|
||||||
|
\ No newline at end of file
|
258
src/cache-base.ts
Normal file
258
src/cache-base.ts
Normal file
|
@ -0,0 +1,258 @@
|
||||||
|
import * as core from '@actions/core'
|
||||||
|
import * as cache from '@actions/cache'
|
||||||
|
import * as github from '@actions/github'
|
||||||
|
import {isCacheDebuggingEnabled, getCacheKeyPrefix, hashStrings} from './cache-utils'
|
||||||
|
|
||||||
|
const JOB_CONTEXT_PARAMETER = 'workflow-job-context'
|
||||||
|
|
||||||
|
function generateCacheKey(cacheName: string): CacheKey {
|
||||||
|
const cacheKeyPrefix = getCacheKeyPrefix()
|
||||||
|
|
||||||
|
// At the most general level, share caches for all executions on the same OS
|
||||||
|
const runnerOs = process.env['RUNNER_OS'] || ''
|
||||||
|
const cacheKeyForOs = `${cacheKeyPrefix}${cacheName}|${runnerOs}`
|
||||||
|
|
||||||
|
// Prefer caches that run this job
|
||||||
|
const cacheKeyForJob = `${cacheKeyForOs}|${github.context.job}`
|
||||||
|
|
||||||
|
// Prefer (even more) jobs that run this job with the same context (matrix)
|
||||||
|
const cacheKeyForJobContext = `${cacheKeyForJob}[${determineJobContext()}]`
|
||||||
|
|
||||||
|
// Exact match on Git SHA
|
||||||
|
const cacheKey = `${cacheKeyForJobContext}-${github.context.sha}`
|
||||||
|
|
||||||
|
return new CacheKey(cacheKey, [cacheKeyForJobContext, cacheKeyForJob, cacheKeyForOs])
|
||||||
|
}
|
||||||
|
|
||||||
|
function determineJobContext(): string {
|
||||||
|
// By default, we hash the full `matrix` data for the run, to uniquely identify this job invocation
|
||||||
|
const workflowJobContext = core.getInput(JOB_CONTEXT_PARAMETER)
|
||||||
|
return hashStrings([workflowJobContext])
|
||||||
|
}
|
||||||
|
|
||||||
|
class CacheKey {
|
||||||
|
key: string
|
||||||
|
restoreKeys: string[]
|
||||||
|
|
||||||
|
constructor(key: string, restoreKeys: string[]) {
|
||||||
|
this.key = key
|
||||||
|
this.restoreKeys = restoreKeys
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CacheListener {
|
||||||
|
cacheEntries: CacheEntryListener[] = []
|
||||||
|
|
||||||
|
get fullyRestored(): boolean {
|
||||||
|
return this.cacheEntries.every(x => !x.wasRequestedButNotRestored())
|
||||||
|
}
|
||||||
|
|
||||||
|
entry(name: string): CacheEntryListener {
|
||||||
|
for (const entry of this.cacheEntries) {
|
||||||
|
if (entry.entryName === name) {
|
||||||
|
return entry
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const newEntry = new CacheEntryListener(name)
|
||||||
|
this.cacheEntries.push(newEntry)
|
||||||
|
return newEntry
|
||||||
|
}
|
||||||
|
|
||||||
|
stringify(): string {
|
||||||
|
return JSON.stringify(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
static rehydrate(stringRep: string): CacheListener {
|
||||||
|
const rehydrated: CacheListener = Object.assign(new CacheListener(), JSON.parse(stringRep))
|
||||||
|
const entries = rehydrated.cacheEntries
|
||||||
|
for (let index = 0; index < entries.length; index++) {
|
||||||
|
const rawEntry = entries[index]
|
||||||
|
entries[index] = Object.assign(new CacheEntryListener(rawEntry.entryName), rawEntry)
|
||||||
|
}
|
||||||
|
return rehydrated
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CacheEntryListener {
|
||||||
|
entryName: string
|
||||||
|
requestedKey: string | undefined
|
||||||
|
requestedRestoreKeys: string[] | undefined
|
||||||
|
restoredKey: string | undefined
|
||||||
|
restoredSize: number | undefined
|
||||||
|
|
||||||
|
savedKey: string | undefined
|
||||||
|
savedSize: number | undefined
|
||||||
|
|
||||||
|
constructor(entryName: string) {
|
||||||
|
this.entryName = entryName
|
||||||
|
}
|
||||||
|
|
||||||
|
wasRequestedButNotRestored(): boolean {
|
||||||
|
return this.requestedKey !== undefined && this.restoredKey === undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
markRequested(key: string, restoreKeys: string[] = []): CacheEntryListener {
|
||||||
|
this.requestedKey = key
|
||||||
|
this.requestedRestoreKeys = restoreKeys
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
markRestored(key: string, size: number | undefined): CacheEntryListener {
|
||||||
|
this.restoredKey = key
|
||||||
|
this.restoredSize = size
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
markSaved(key: string, size: number | undefined): CacheEntryListener {
|
||||||
|
this.savedKey = key
|
||||||
|
this.savedSize = size
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export abstract class AbstractCache {
|
||||||
|
private cacheName: string
|
||||||
|
private cacheDescription: string
|
||||||
|
private cacheKeyStateKey: string
|
||||||
|
private cacheResultStateKey: string
|
||||||
|
|
||||||
|
protected readonly cacheDebuggingEnabled: boolean
|
||||||
|
|
||||||
|
constructor(cacheName: string, cacheDescription: string) {
|
||||||
|
this.cacheName = cacheName
|
||||||
|
this.cacheDescription = cacheDescription
|
||||||
|
this.cacheKeyStateKey = `CACHE_KEY_${cacheName}`
|
||||||
|
this.cacheResultStateKey = `CACHE_RESULT_${cacheName}`
|
||||||
|
this.cacheDebuggingEnabled = isCacheDebuggingEnabled()
|
||||||
|
}
|
||||||
|
|
||||||
|
async restore(listener: CacheListener): Promise<void> {
|
||||||
|
if (this.cacheOutputExists()) {
|
||||||
|
core.info(`${this.cacheDescription} already exists. Not restoring from cache.`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const cacheKey = this.prepareCacheKey()
|
||||||
|
const entryReport = listener.entry(this.cacheDescription)
|
||||||
|
entryReport.markRequested(cacheKey.key, cacheKey.restoreKeys)
|
||||||
|
|
||||||
|
this.debug(
|
||||||
|
`Requesting ${this.cacheDescription} with
|
||||||
|
key:${cacheKey.key}
|
||||||
|
restoreKeys:[${cacheKey.restoreKeys}]`
|
||||||
|
)
|
||||||
|
|
||||||
|
const cacheResult = await this.restoreCache(this.getCachePath(), cacheKey.key, cacheKey.restoreKeys)
|
||||||
|
|
||||||
|
if (!cacheResult) {
|
||||||
|
core.info(`${this.cacheDescription} cache not found. Will start with empty.`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
core.saveState(this.cacheResultStateKey, cacheResult)
|
||||||
|
entryReport.markRestored(cacheResult.key, cacheResult.size)
|
||||||
|
core.info(`Restored ${this.cacheDescription} from cache key: ${cacheResult}`)
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.afterRestore(listener)
|
||||||
|
} catch (error) {
|
||||||
|
core.warning(`Restore ${this.cacheDescription} failed in 'afterRestore': ${error}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
prepareCacheKey(): CacheKey {
|
||||||
|
const cacheKey = generateCacheKey(this.cacheName)
|
||||||
|
|
||||||
|
core.saveState(this.cacheKeyStateKey, cacheKey.key)
|
||||||
|
return cacheKey
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async restoreCache(
|
||||||
|
cachePath: string[],
|
||||||
|
cacheKey: string,
|
||||||
|
cacheRestoreKeys: string[] = []
|
||||||
|
): Promise<cache.CacheEntry | undefined> {
|
||||||
|
try {
|
||||||
|
return await cache.restoreCache(cachePath, cacheKey, cacheRestoreKeys)
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof cache.ValidationError) {
|
||||||
|
// Validation errors should fail the build action
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
// Warn about any other error and continue
|
||||||
|
core.warning(`Failed to restore ${cacheKey}: ${error}`)
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async afterRestore(_listener: CacheListener): Promise<void> {}
|
||||||
|
|
||||||
|
async save(listener: CacheListener): Promise<void> {
|
||||||
|
if (!this.cacheOutputExists()) {
|
||||||
|
this.debug(`No ${this.cacheDescription} to cache.`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const cacheKey = core.getState(this.cacheKeyStateKey)
|
||||||
|
const cacheResult = core.getState(this.cacheResultStateKey)
|
||||||
|
|
||||||
|
if (!cacheKey) {
|
||||||
|
this.debug(`${this.cacheDescription} existed prior to cache restore. Not saving.`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cacheResult && cacheKey === cacheResult) {
|
||||||
|
core.info(`Cache hit occurred on the cache key ${cacheKey}, not saving cache.`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.beforeSave(listener)
|
||||||
|
} catch (error) {
|
||||||
|
core.warning(`Save ${this.cacheDescription} failed in 'beforeSave': ${error}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
core.info(`Caching ${this.cacheDescription} with cache key: ${cacheKey}`)
|
||||||
|
const cachePath = this.getCachePath()
|
||||||
|
const savedEntry = await this.saveCache(cachePath, cacheKey)
|
||||||
|
|
||||||
|
if (savedEntry) {
|
||||||
|
listener.entry(this.cacheDescription).markSaved(savedEntry.key, savedEntry.size)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async beforeSave(_listener: CacheListener): Promise<void> {}
|
||||||
|
|
||||||
|
protected async saveCache(cachePath: string[], cacheKey: string): Promise<cache.CacheEntry | undefined> {
|
||||||
|
try {
|
||||||
|
return await cache.saveCache(cachePath, cacheKey)
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof cache.ValidationError) {
|
||||||
|
// Validation errors should fail the build action
|
||||||
|
throw error
|
||||||
|
} else if (error instanceof cache.ReserveCacheError) {
|
||||||
|
// Reserve cache errors are expected if the artifact has been previously cached
|
||||||
|
this.debug(error.message)
|
||||||
|
} else {
|
||||||
|
// Warn about any other error and continue
|
||||||
|
core.warning(String(error))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
protected debug(message: string): void {
|
||||||
|
if (this.cacheDebuggingEnabled) {
|
||||||
|
core.info(message)
|
||||||
|
} else {
|
||||||
|
core.debug(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract cacheOutputExists(): boolean
|
||||||
|
protected abstract getCachePath(): string[]
|
||||||
|
}
|
|
@ -5,14 +5,8 @@ import * as core from '@actions/core'
|
||||||
import * as glob from '@actions/glob'
|
import * as glob from '@actions/glob'
|
||||||
import * as exec from '@actions/exec'
|
import * as exec from '@actions/exec'
|
||||||
|
|
||||||
import {
|
import {AbstractCache, CacheEntryListener, CacheListener} from './cache-base'
|
||||||
AbstractCache,
|
import {getCacheKeyPrefix, hashFileNames, tryDelete} from './cache-utils'
|
||||||
CacheEntryReport,
|
|
||||||
CachingReport,
|
|
||||||
getCacheKeyPrefix,
|
|
||||||
hashFileNames,
|
|
||||||
tryDelete
|
|
||||||
} from './cache-utils'
|
|
||||||
|
|
||||||
const META_FILE_DIR = '.gradle-build-action'
|
const META_FILE_DIR = '.gradle-build-action'
|
||||||
|
|
||||||
|
@ -28,13 +22,13 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||||
this.gradleUserHome = this.determineGradleUserHome(rootDir)
|
this.gradleUserHome = this.determineGradleUserHome(rootDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
async afterRestore(report: CachingReport): Promise<void> {
|
async afterRestore(listener: CacheListener): Promise<void> {
|
||||||
await this.reportGradleUserHomeSize('as restored from cache')
|
await this.reportGradleUserHomeSize('as restored from cache')
|
||||||
await this.restoreArtifactBundles(report)
|
await this.restoreArtifactBundles(listener)
|
||||||
await this.reportGradleUserHomeSize('after restoring common artifacts')
|
await this.reportGradleUserHomeSize('after restoring common artifacts')
|
||||||
}
|
}
|
||||||
|
|
||||||
private async restoreArtifactBundles(report: CachingReport): Promise<void> {
|
private async restoreArtifactBundles(listener: CacheListener): Promise<void> {
|
||||||
const processes: Promise<void>[] = []
|
const processes: Promise<void>[] = []
|
||||||
|
|
||||||
const bundleMetaFiles = await this.getBundleMetaFiles()
|
const bundleMetaFiles = await this.getBundleMetaFiles()
|
||||||
|
@ -43,16 +37,16 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||||
// Iterate over all bundle meta files and try to restore
|
// Iterate over all bundle meta files and try to restore
|
||||||
for (const bundleMetaFile of bundleMetaFiles) {
|
for (const bundleMetaFile of bundleMetaFiles) {
|
||||||
const bundle = path.basename(bundleMetaFile, '.cache')
|
const bundle = path.basename(bundleMetaFile, '.cache')
|
||||||
const bundleEntryReport = report.addEntryReport(bundle)
|
const entryListener = listener.entry(bundle)
|
||||||
const bundlePattern = bundlePatterns.get(bundle)
|
const bundlePattern = bundlePatterns.get(bundle)
|
||||||
|
|
||||||
// Handle case where the 'artifactBundlePatterns' have been changed
|
// Handle case where the 'artifactBundlePatterns' have been changed
|
||||||
if (bundlePattern === undefined) {
|
if (bundlePattern === undefined) {
|
||||||
core.info(`Found bundle metafile for ${bundle} but no such bundle defined`)
|
core.info(`Found bundle metafile for ${bundle} but no such bundle defined`)
|
||||||
bundleEntryReport.markRequested('BUNDLE_NOT_CONFIGURED')
|
entryListener.markRequested('BUNDLE_NOT_CONFIGURED')
|
||||||
tryDelete(bundleMetaFile)
|
tryDelete(bundleMetaFile)
|
||||||
} else {
|
} else {
|
||||||
const p = this.restoreArtifactBundle(bundle, bundlePattern, bundleMetaFile, bundleEntryReport)
|
const p = this.restoreArtifactBundle(bundle, bundlePattern, bundleMetaFile, entryListener)
|
||||||
// Run sequentially when debugging enabled
|
// Run sequentially when debugging enabled
|
||||||
if (this.cacheDebuggingEnabled) {
|
if (this.cacheDebuggingEnabled) {
|
||||||
await p
|
await p
|
||||||
|
@ -68,15 +62,15 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||||
bundle: string,
|
bundle: string,
|
||||||
bundlePattern: string,
|
bundlePattern: string,
|
||||||
bundleMetaFile: string,
|
bundleMetaFile: string,
|
||||||
report: CacheEntryReport
|
listener: CacheEntryListener
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const cacheKey = fs.readFileSync(bundleMetaFile, 'utf-8').trim()
|
const cacheKey = fs.readFileSync(bundleMetaFile, 'utf-8').trim()
|
||||||
report.markRequested(cacheKey)
|
listener.markRequested(cacheKey)
|
||||||
|
|
||||||
const restoredKey = await this.restoreCache([bundlePattern], cacheKey)
|
const restoredEntry = await this.restoreCache([bundlePattern], cacheKey)
|
||||||
if (restoredKey) {
|
if (restoredEntry) {
|
||||||
core.info(`Restored ${bundle} with key ${cacheKey} to ${bundlePattern}`)
|
core.info(`Restored ${bundle} with key ${cacheKey} to ${bundlePattern}`)
|
||||||
report.markRestored(restoredKey)
|
listener.markRestored(restoredEntry.key, restoredEntry.size)
|
||||||
} else {
|
} else {
|
||||||
core.info(`Did not restore ${bundle} with key ${cacheKey} to ${bundlePattern}`)
|
core.info(`Did not restore ${bundle} with key ${cacheKey} to ${bundlePattern}`)
|
||||||
tryDelete(bundleMetaFile)
|
tryDelete(bundleMetaFile)
|
||||||
|
@ -94,10 +88,10 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||||
return bundleFiles
|
return bundleFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
async beforeSave(): Promise<void> {
|
async beforeSave(listener: CacheListener): Promise<void> {
|
||||||
await this.reportGradleUserHomeSize('before saving common artifacts')
|
await this.reportGradleUserHomeSize('before saving common artifacts')
|
||||||
this.removeExcludedPaths()
|
this.removeExcludedPaths()
|
||||||
await this.saveArtifactBundles()
|
await this.saveArtifactBundles(listener)
|
||||||
await this.reportGradleUserHomeSize(
|
await this.reportGradleUserHomeSize(
|
||||||
"after saving common artifacts (only 'caches' and 'notifications' will be stored)"
|
"after saving common artifacts (only 'caches' and 'notifications' will be stored)"
|
||||||
)
|
)
|
||||||
|
@ -113,10 +107,12 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async saveArtifactBundles(): Promise<void> {
|
private async saveArtifactBundles(listener: CacheListener): Promise<void> {
|
||||||
const processes: Promise<void>[] = []
|
const processes: Promise<void>[] = []
|
||||||
for (const [bundle, pattern] of this.getArtifactBundles()) {
|
for (const [bundle, pattern] of this.getArtifactBundles()) {
|
||||||
const p = this.saveArtifactBundle(bundle, pattern)
|
const entryListener = listener.entry(bundle)
|
||||||
|
|
||||||
|
const p = this.saveArtifactBundle(bundle, pattern, entryListener)
|
||||||
// Run sequentially when debugging enabled
|
// Run sequentially when debugging enabled
|
||||||
if (this.cacheDebuggingEnabled) {
|
if (this.cacheDebuggingEnabled) {
|
||||||
await p
|
await p
|
||||||
|
@ -127,7 +123,11 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||||
await Promise.all(processes)
|
await Promise.all(processes)
|
||||||
}
|
}
|
||||||
|
|
||||||
private async saveArtifactBundle(bundle: string, artifactPath: string): Promise<void> {
|
private async saveArtifactBundle(
|
||||||
|
bundle: string,
|
||||||
|
artifactPath: string,
|
||||||
|
listener: CacheEntryListener
|
||||||
|
): Promise<void> {
|
||||||
const bundleMetaFile = this.getBundleMetaFile(bundle)
|
const bundleMetaFile = this.getBundleMetaFile(bundle)
|
||||||
|
|
||||||
const globber = await glob.create(artifactPath, {
|
const globber = await glob.create(artifactPath, {
|
||||||
|
@ -154,8 +154,11 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||||
this.debug(`No change to previously restored ${bundle}. Not caching.`)
|
this.debug(`No change to previously restored ${bundle}. Not caching.`)
|
||||||
} else {
|
} else {
|
||||||
core.info(`Caching ${bundle} with cache key: ${cacheKey}`)
|
core.info(`Caching ${bundle} with cache key: ${cacheKey}`)
|
||||||
await this.saveCache([artifactPath], cacheKey)
|
const savedEntry = await this.saveCache([artifactPath], cacheKey)
|
||||||
this.writeBundleMetaFile(bundleMetaFile, cacheKey)
|
if (savedEntry !== undefined) {
|
||||||
|
this.writeBundleMetaFile(bundleMetaFile, cacheKey)
|
||||||
|
listener.markSaved(savedEntry.key, savedEntry.size)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const file of bundleFiles) {
|
for (const file of bundleFiles) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import {AbstractCache} from './cache-utils'
|
import {AbstractCache} from './cache-base'
|
||||||
|
|
||||||
// TODO: Maybe allow the user to override / tweak this set
|
// TODO: Maybe allow the user to override / tweak this set
|
||||||
const PATHS_TO_CACHE = [
|
const PATHS_TO_CACHE = [
|
||||||
|
@ -10,7 +10,7 @@ const PATHS_TO_CACHE = [
|
||||||
export class ProjectDotGradleCache extends AbstractCache {
|
export class ProjectDotGradleCache extends AbstractCache {
|
||||||
private rootDir: string
|
private rootDir: string
|
||||||
constructor(rootDir: string) {
|
constructor(rootDir: string) {
|
||||||
super('project', 'Project .gradle directory')
|
super('project', 'Project configuration cache')
|
||||||
this.rootDir = rootDir
|
this.rootDir = rootDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as cache from '@actions/cache'
|
|
||||||
import * as github from '@actions/github'
|
|
||||||
import * as crypto from 'crypto'
|
import * as crypto from 'crypto'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
|
@ -9,7 +7,6 @@ const CACHE_PROTOCOL_VERSION = 'v4-'
|
||||||
|
|
||||||
const CACHE_DISABLED_PARAMETER = 'cache-disabled'
|
const CACHE_DISABLED_PARAMETER = 'cache-disabled'
|
||||||
const CACHE_READONLY_PARAMETER = 'cache-read-only'
|
const CACHE_READONLY_PARAMETER = 'cache-read-only'
|
||||||
const JOB_CONTEXT_PARAMETER = 'workflow-job-context'
|
|
||||||
const CACHE_DEBUG_VAR = 'GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED'
|
const CACHE_DEBUG_VAR = 'GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED'
|
||||||
const CACHE_PREFIX_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX'
|
const CACHE_PREFIX_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX'
|
||||||
|
|
||||||
|
@ -30,31 +27,6 @@ export function getCacheKeyPrefix(): string {
|
||||||
return process.env[CACHE_PREFIX_VAR] || CACHE_PROTOCOL_VERSION
|
return process.env[CACHE_PREFIX_VAR] || CACHE_PROTOCOL_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateCacheKey(cacheName: string): CacheKey {
|
|
||||||
const cacheKeyPrefix = getCacheKeyPrefix()
|
|
||||||
|
|
||||||
// At the most general level, share caches for all executions on the same OS
|
|
||||||
const runnerOs = process.env['RUNNER_OS'] || ''
|
|
||||||
const cacheKeyForOs = `${cacheKeyPrefix}${cacheName}|${runnerOs}`
|
|
||||||
|
|
||||||
// Prefer caches that run this job
|
|
||||||
const cacheKeyForJob = `${cacheKeyForOs}|${github.context.job}`
|
|
||||||
|
|
||||||
// Prefer (even more) jobs that run this job with the same context (matrix)
|
|
||||||
const cacheKeyForJobContext = `${cacheKeyForJob}[${determineJobContext()}]`
|
|
||||||
|
|
||||||
// Exact match on Git SHA
|
|
||||||
const cacheKey = `${cacheKeyForJobContext}-${github.context.sha}`
|
|
||||||
|
|
||||||
return new CacheKey(cacheKey, [cacheKeyForJobContext, cacheKeyForJob, cacheKeyForOs])
|
|
||||||
}
|
|
||||||
|
|
||||||
function determineJobContext(): string {
|
|
||||||
// By default, we hash the full `matrix` data for the run, to uniquely identify this job invocation
|
|
||||||
const workflowJobContext = core.getInput(JOB_CONTEXT_PARAMETER)
|
|
||||||
return hashStrings([workflowJobContext])
|
|
||||||
}
|
|
||||||
|
|
||||||
export function hashStrings(values: string[]): string {
|
export function hashStrings(values: string[]): string {
|
||||||
const hash = crypto.createHash('md5')
|
const hash = crypto.createHash('md5')
|
||||||
for (const value of values) {
|
for (const value of values) {
|
||||||
|
@ -94,196 +66,3 @@ export async function tryDelete(file: string): Promise<void> {
|
||||||
async function delay(ms: number): Promise<void> {
|
async function delay(ms: number): Promise<void> {
|
||||||
return new Promise(resolve => setTimeout(resolve, ms))
|
return new Promise(resolve => setTimeout(resolve, ms))
|
||||||
}
|
}
|
||||||
|
|
||||||
class CacheKey {
|
|
||||||
key: string
|
|
||||||
restoreKeys: string[]
|
|
||||||
|
|
||||||
constructor(key: string, restoreKeys: string[]) {
|
|
||||||
this.key = key
|
|
||||||
this.restoreKeys = restoreKeys
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class CachingReport {
|
|
||||||
cacheEntryReports: CacheEntryReport[] = []
|
|
||||||
|
|
||||||
get fullyRestored(): boolean {
|
|
||||||
return this.cacheEntryReports.every(x => !x.wasRequestedButNotRestored())
|
|
||||||
}
|
|
||||||
|
|
||||||
addEntryReport(name: string): CacheEntryReport {
|
|
||||||
const report = new CacheEntryReport(name)
|
|
||||||
this.cacheEntryReports.push(report)
|
|
||||||
return report
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class CacheEntryReport {
|
|
||||||
entryName: string
|
|
||||||
requestedKey: string | undefined
|
|
||||||
requestedRestoreKeys: string[] | undefined
|
|
||||||
restoredKey: string | undefined
|
|
||||||
restoredSize: number | undefined
|
|
||||||
|
|
||||||
savedKey: string | undefined
|
|
||||||
savedSize: number | undefined
|
|
||||||
|
|
||||||
constructor(entryName: string) {
|
|
||||||
this.entryName = entryName
|
|
||||||
}
|
|
||||||
|
|
||||||
wasRequestedButNotRestored(): boolean {
|
|
||||||
return this.requestedKey !== undefined && this.restoredKey === undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
markRequested(key: string, restoreKeys: string[] = []): void {
|
|
||||||
this.requestedKey = key
|
|
||||||
this.requestedRestoreKeys = restoreKeys
|
|
||||||
}
|
|
||||||
|
|
||||||
markRestored(key: string): void {
|
|
||||||
this.restoredKey = key
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export abstract class AbstractCache {
|
|
||||||
private cacheName: string
|
|
||||||
private cacheDescription: string
|
|
||||||
private cacheKeyStateKey: string
|
|
||||||
private cacheResultStateKey: string
|
|
||||||
|
|
||||||
protected readonly cacheDebuggingEnabled: boolean
|
|
||||||
|
|
||||||
constructor(cacheName: string, cacheDescription: string) {
|
|
||||||
this.cacheName = cacheName
|
|
||||||
this.cacheDescription = cacheDescription
|
|
||||||
this.cacheKeyStateKey = `CACHE_KEY_${cacheName}`
|
|
||||||
this.cacheResultStateKey = `CACHE_RESULT_${cacheName}`
|
|
||||||
this.cacheDebuggingEnabled = isCacheDebuggingEnabled()
|
|
||||||
}
|
|
||||||
|
|
||||||
async restore(report: CachingReport): Promise<void> {
|
|
||||||
if (this.cacheOutputExists()) {
|
|
||||||
core.info(`${this.cacheDescription} already exists. Not restoring from cache.`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const cacheKey = this.prepareCacheKey()
|
|
||||||
const entryReport = report.addEntryReport(this.cacheName)
|
|
||||||
entryReport.markRequested(cacheKey.key, cacheKey.restoreKeys)
|
|
||||||
|
|
||||||
this.debug(
|
|
||||||
`Requesting ${this.cacheDescription} with
|
|
||||||
key:${cacheKey.key}
|
|
||||||
restoreKeys:[${cacheKey.restoreKeys}]`
|
|
||||||
)
|
|
||||||
|
|
||||||
const cacheResult = await this.restoreCache(this.getCachePath(), cacheKey.key, cacheKey.restoreKeys)
|
|
||||||
|
|
||||||
if (!cacheResult) {
|
|
||||||
core.info(`${this.cacheDescription} cache not found. Will start with empty.`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
core.saveState(this.cacheResultStateKey, cacheResult)
|
|
||||||
entryReport.markRestored(cacheResult)
|
|
||||||
core.info(`Restored ${this.cacheDescription} from cache key: ${cacheResult}`)
|
|
||||||
|
|
||||||
try {
|
|
||||||
await this.afterRestore(report)
|
|
||||||
} catch (error) {
|
|
||||||
core.warning(`Restore ${this.cacheDescription} failed in 'afterRestore': ${error}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
prepareCacheKey(): CacheKey {
|
|
||||||
const cacheKey = generateCacheKey(this.cacheName)
|
|
||||||
|
|
||||||
core.saveState(this.cacheKeyStateKey, cacheKey.key)
|
|
||||||
return cacheKey
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async restoreCache(
|
|
||||||
cachePath: string[],
|
|
||||||
cacheKey: string,
|
|
||||||
cacheRestoreKeys: string[] = []
|
|
||||||
): Promise<string | undefined> {
|
|
||||||
try {
|
|
||||||
return await cache.restoreCache(cachePath, cacheKey, cacheRestoreKeys)
|
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof cache.ValidationError) {
|
|
||||||
// Validation errors should fail the build action
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
// Warn about any other error and continue
|
|
||||||
core.warning(`Failed to restore ${cacheKey}: ${error}`)
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async afterRestore(_report: CachingReport): Promise<void> {}
|
|
||||||
|
|
||||||
async save(): Promise<void> {
|
|
||||||
if (!this.cacheOutputExists()) {
|
|
||||||
this.debug(`No ${this.cacheDescription} to cache.`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const cacheKey = core.getState(this.cacheKeyStateKey)
|
|
||||||
const cacheResult = core.getState(this.cacheResultStateKey)
|
|
||||||
|
|
||||||
if (!cacheKey) {
|
|
||||||
this.debug(`${this.cacheDescription} existed prior to cache restore. Not saving.`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cacheResult && cacheKey === cacheResult) {
|
|
||||||
core.info(`Cache hit occurred on the cache key ${cacheKey}, not saving cache.`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await this.beforeSave()
|
|
||||||
} catch (error) {
|
|
||||||
core.warning(`Save ${this.cacheDescription} failed in 'beforeSave': ${error}`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
core.info(`Caching ${this.cacheDescription} with cache key: ${cacheKey}`)
|
|
||||||
const cachePath = this.getCachePath()
|
|
||||||
await this.saveCache(cachePath, cacheKey)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async beforeSave(): Promise<void> {}
|
|
||||||
|
|
||||||
protected async saveCache(cachePath: string[], cacheKey: string): Promise<void> {
|
|
||||||
try {
|
|
||||||
await cache.saveCache(cachePath, cacheKey)
|
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof cache.ValidationError) {
|
|
||||||
// Validation errors should fail the build action
|
|
||||||
throw error
|
|
||||||
} else if (error instanceof cache.ReserveCacheError) {
|
|
||||||
// Reserve cache errors are expected if the artifact has been previously cached
|
|
||||||
this.debug(error.message)
|
|
||||||
} else {
|
|
||||||
// Warn about any other error and continue
|
|
||||||
core.warning(String(error))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected debug(message: string): void {
|
|
||||||
if (this.cacheDebuggingEnabled) {
|
|
||||||
core.info(message)
|
|
||||||
} else {
|
|
||||||
core.debug(message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract cacheOutputExists(): boolean
|
|
||||||
protected abstract getCachePath(): string[]
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import {GradleUserHomeCache} from './cache-gradle-user-home'
|
import {GradleUserHomeCache} from './cache-gradle-user-home'
|
||||||
import {ProjectDotGradleCache} from './cache-project-dot-gradle'
|
import {ProjectDotGradleCache} from './cache-project-dot-gradle'
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {CachingReport, isCacheDisabled, isCacheReadOnly} from './cache-utils'
|
import {isCacheDisabled, isCacheReadOnly} from './cache-utils'
|
||||||
|
import {CacheEntryListener, CacheListener} from './cache-base'
|
||||||
|
|
||||||
const BUILD_ROOT_DIR = 'BUILD_ROOT_DIR'
|
const BUILD_ROOT_DIR = 'BUILD_ROOT_DIR'
|
||||||
|
const CACHE_LISTENER = 'CACHE_LISTENER'
|
||||||
|
|
||||||
export async function restore(buildRootDirectory: string): Promise<void> {
|
export async function restore(buildRootDirectory: string): Promise<void> {
|
||||||
if (isCacheDisabled()) {
|
if (isCacheDisabled()) {
|
||||||
|
@ -14,32 +16,79 @@ export async function restore(buildRootDirectory: string): Promise<void> {
|
||||||
await core.group('Restore Gradle state from cache', async () => {
|
await core.group('Restore Gradle state from cache', async () => {
|
||||||
core.saveState(BUILD_ROOT_DIR, buildRootDirectory)
|
core.saveState(BUILD_ROOT_DIR, buildRootDirectory)
|
||||||
|
|
||||||
const cachingReport = new CachingReport()
|
const cacheListener = new CacheListener()
|
||||||
|
await new GradleUserHomeCache(buildRootDirectory).restore(cacheListener)
|
||||||
await new GradleUserHomeCache(buildRootDirectory).restore(cachingReport)
|
|
||||||
|
|
||||||
const projectDotGradleCache = new ProjectDotGradleCache(buildRootDirectory)
|
const projectDotGradleCache = new ProjectDotGradleCache(buildRootDirectory)
|
||||||
if (cachingReport.fullyRestored) {
|
if (cacheListener.fullyRestored) {
|
||||||
// Only restore the configuration-cache if the Gradle Home is fully restored
|
// Only restore the configuration-cache if the Gradle Home is fully restored
|
||||||
await projectDotGradleCache.restore(cachingReport)
|
await projectDotGradleCache.restore(cacheListener)
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, prepare the cache key for later save()
|
// Otherwise, prepare the cache key for later save()
|
||||||
|
core.info('Gradle Home cache not fully restored: not restoring configuration-cache state')
|
||||||
projectDotGradleCache.prepareCacheKey()
|
projectDotGradleCache.prepareCacheKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
core.saveState(CACHE_LISTENER, cacheListener.stringify())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function save(): Promise<void> {
|
export async function save(): Promise<void> {
|
||||||
|
const cacheListener: CacheListener = CacheListener.rehydrate(core.getState(CACHE_LISTENER))
|
||||||
|
|
||||||
if (isCacheReadOnly()) {
|
if (isCacheReadOnly()) {
|
||||||
core.info('Cache is read-only: will not save state for use in subsequent builds.')
|
core.info('Cache is read-only: will not save state for use in subsequent builds.')
|
||||||
|
logCachingReport(cacheListener)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await core.group('Caching Gradle state', async () => {
|
await core.group('Caching Gradle state', async () => {
|
||||||
const buildRootDirectory = core.getState(BUILD_ROOT_DIR)
|
const buildRootDirectory = core.getState(BUILD_ROOT_DIR)
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
new GradleUserHomeCache(buildRootDirectory).save(),
|
new GradleUserHomeCache(buildRootDirectory).save(cacheListener),
|
||||||
new ProjectDotGradleCache(buildRootDirectory).save()
|
new ProjectDotGradleCache(buildRootDirectory).save(cacheListener)
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
logCachingReport(cacheListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
function logCachingReport(listener: CacheListener): void {
|
||||||
|
core.info(`---------- Caching Summary -------------
|
||||||
|
Restored Entries Count: ${getCount(listener.cacheEntries, e => e.restoredSize)}
|
||||||
|
Size: ${getSum(listener.cacheEntries, e => e.restoredSize)}
|
||||||
|
Saved Entries Count: ${getCount(listener.cacheEntries, e => e.savedSize)}
|
||||||
|
Size: ${getSum(listener.cacheEntries, e => e.savedSize)}`)
|
||||||
|
|
||||||
|
core.startGroup('Cache Entry details')
|
||||||
|
for (const entry of listener.cacheEntries) {
|
||||||
|
core.info(`Entry: ${entry.entryName}
|
||||||
|
Requested Key : ${entry.requestedKey ?? ''}
|
||||||
|
Restored Key : ${entry.restoredKey ?? ''}
|
||||||
|
Size: ${formatSize(entry.restoredSize)}
|
||||||
|
Saved Key : ${entry.savedKey ?? ''}
|
||||||
|
Size: ${formatSize(entry.savedSize)}`)
|
||||||
|
}
|
||||||
|
core.endGroup()
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCount(
|
||||||
|
cacheEntries: CacheEntryListener[],
|
||||||
|
predicate: (value: CacheEntryListener) => number | undefined
|
||||||
|
): number {
|
||||||
|
return cacheEntries.filter(e => predicate(e) !== undefined).length
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSum(
|
||||||
|
cacheEntries: CacheEntryListener[],
|
||||||
|
predicate: (value: CacheEntryListener) => number | undefined
|
||||||
|
): string {
|
||||||
|
return formatSize(cacheEntries.map(e => predicate(e) ?? 0).reduce((p, v) => p + v, 0))
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatSize(bytes: number | undefined): string {
|
||||||
|
if (bytes === undefined || bytes === 0) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
return `${Math.round(bytes / (1024 * 1024))} MB (${bytes} B)`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue