Skip to content

Commit 648cfd2

Browse files
committed
output cache key
1 parent 7242f1d commit 648cfd2

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

.github/actions/install-dependencies/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ outputs:
55
cache_key:
66
description: 'The dependency cache key'
77
value: ${{ steps.compute_lockfile_hash.outputs.hash }}
8+
cache_key_all:
9+
description: 'The dependency cache key without hashing'
10+
value: ${{ steps.compute_lockfile_hash.outputs.nohash }}
811

912
runs:
1013
using: 'composite'
@@ -20,6 +23,7 @@ runs:
2023
with:
2124
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
2225
key: ${{ steps.compute_lockfile_hash.outputs.hash }}
26+
key-nohash: ${{ steps.compute_lockfile_hash.outputs.nohash }}
2327

2428
- name: Install dependencies
2529
if: steps.cache_dependencies.outputs.cache-hit != 'true'

scripts/dependency-hash-key.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,17 @@ function outputDependencyCacheKey() {
3232
hashParts.push(getNormalizedDependencies(packageJson, workspacePackageNames));
3333
});
3434

35-
const hash = crypto.createHash('md5').update(hashParts.join('\n')).digest('hex');
36-
// We log the output in a way that the GitHub Actions can append it to the output
37-
// We prefix it with `dependencies-` so it is easier to identify in the logs
38-
// eslint-disable-next-line no-console
35+
// Create a truncated version of the raw data for debugging
36+
// We don't want to output the full content as it could be very large
37+
const rawData = hashParts.join('\n');
38+
const truncatedRawData =
39+
rawData.length > 500 ? rawData.substring(0, 250) + '...' + rawData.substring(rawData.length - 250) : rawData;
40+
41+
const hash = crypto.createHash('md5').update(rawData).digest('hex');
42+
43+
// Output both the hash and the raw data (truncated)
3944
console.log(`hash=dependencies-${hash}`);
45+
console.log(`nohash=${encodeURIComponent(truncatedRawData)}`);
4046
}
4147

4248
function getNormalizedDependencies(packageJson, workspacePackageNames) {

0 commit comments

Comments
 (0)