Seed the cache key with workflow id in CI

This will eliminate cache entries from previous workflow runs, allowing
us to test cache functionality in isolation. If the `CACHE_KEY_SEED` environment
variable is not set, this will have no impact.
This commit is contained in:
Daz DeBoer 2021-08-26 16:56:06 -06:00
parent fa0c026e07
commit b85ac67c9a
No known key found for this signature in database
GPG Key ID: DD6B9F0B06683D5D
3 changed files with 7 additions and 2 deletions

View File

@ -6,6 +6,9 @@ on:
push:
workflow_dispatch:
env:
CACHE_KEY_SEED: ${{github.workflow}}#${{github.run_number}}-
jobs:
basic-build:
strategy:

View File

@ -28,8 +28,9 @@ export async function restore(): Promise<void> {
return
}
const cacheKeySeed = process.env[`CACHE_KEY_SEED`] || ''
const runnerOs = process.env[`RUNNER_OS`] || ''
const cacheKeyPrefix = `${runnerOs}-gradle|`
const cacheKeyPrefix = `${cacheKeySeed}${runnerOs}|gradle|`
const args = truncateArgs(core.getInput('arguments'))
const cacheKeyWithArgs = `${cacheKeyPrefix}${args}|`

View File

@ -27,8 +27,9 @@ export async function restore(rootDir: string): Promise<void> {
return
}
const cacheKeySeed = process.env[`CACHE_KEY_SEED`] || ''
const runnerOs = process.env[`RUNNER_OS`] || ''
const cacheKeyPrefix = `${runnerOs}-project|`
const cacheKeyPrefix = `${cacheKeySeed}${runnerOs}|project|`
const args = truncateArgs(core.getInput('arguments'))
const cacheKeyWithArgs = `${cacheKeyPrefix}${args}|`