Skip to content

Commit

Permalink
Include workflow name in cache key
Browse files Browse the repository at this point in the history
Fixes #699 by avoiding cache key collisions between jobs with the
same name in different workflows.
  • Loading branch information
bigdaz committed May 23, 2023
1 parent d1c4012 commit c20f502
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64395,7 +64395,7 @@ const exec = __importStar(__nccwpck_require__(1514));
const crypto = __importStar(__nccwpck_require__(6113));
const path = __importStar(__nccwpck_require__(1017));
const fs = __importStar(__nccwpck_require__(7147));
const CACHE_PROTOCOL_VERSION = 'v7-';
const CACHE_PROTOCOL_VERSION = 'v8-';
const JOB_CONTEXT_PARAMETER = 'workflow-job-context';
const CACHE_DISABLED_PARAMETER = 'cache-disabled';
const CACHE_READONLY_PARAMETER = 'cache-read-only';
Expand Down Expand Up @@ -64461,7 +64461,7 @@ function getCacheKeyEnvironment() {
return process.env[CACHE_KEY_OS_VAR] || runnerOs;
}
function getCacheKeyJob() {
return process.env[CACHE_KEY_JOB_VAR] || github.context.job;
return process.env[CACHE_KEY_JOB_VAR] || `${github.context.workflow}-${github.context.job}`;
}
function getCacheKeyJobInstance() {
const override = process.env[CACHE_KEY_JOB_INSTANCE_VAR];
Expand Down
2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63498,7 +63498,7 @@ const exec = __importStar(__nccwpck_require__(1514));
const crypto = __importStar(__nccwpck_require__(6113));
const path = __importStar(__nccwpck_require__(1017));
const fs = __importStar(__nccwpck_require__(7147));
const CACHE_PROTOCOL_VERSION = 'v7-';
const CACHE_PROTOCOL_VERSION = 'v8-';
const JOB_CONTEXT_PARAMETER = 'workflow-job-context';
const CACHE_DISABLED_PARAMETER = 'cache-disabled';
const CACHE_READONLY_PARAMETER = 'cache-read-only';
Expand Down Expand Up @@ -63564,7 +63564,7 @@ function getCacheKeyEnvironment() {
return process.env[CACHE_KEY_OS_VAR] || runnerOs;
}
function getCacheKeyJob() {
return process.env[CACHE_KEY_JOB_VAR] || github.context.job;
return process.env[CACHE_KEY_JOB_VAR] || `${github.context.workflow}-${github.context.job}`;
}
function getCacheKeyJobInstance() {
const override = process.env[CACHE_KEY_JOB_INSTANCE_VAR];
Expand Down
2 changes: 1 addition & 1 deletion dist/post/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/cache-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as fs from 'fs'

import {CacheEntryListener} from './cache-reporting'

const CACHE_PROTOCOL_VERSION = 'v7-'
const CACHE_PROTOCOL_VERSION = 'v8-'

const JOB_CONTEXT_PARAMETER = 'workflow-job-context'
const CACHE_DISABLED_PARAMETER = 'cache-disabled'
Expand Down Expand Up @@ -115,7 +115,7 @@ function getCacheKeyEnvironment(): string {
}

function getCacheKeyJob(): string {
return process.env[CACHE_KEY_JOB_VAR] || github.context.job
return process.env[CACHE_KEY_JOB_VAR] || `${github.context.workflow}-${github.context.job}`
}

function getCacheKeyJobInstance(): string {
Expand Down

0 comments on commit c20f502

Please sign in to comment.