mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-06-07 16:56:12 +02:00
Truncate Gradle args when constructing cache key (#71)
Cache keys have a hard limit of 512 characters, so we need to ensure that we don't generate a key longer than this. - Remove excess whitespace - Truncate to 400 characters Fixes #70
This commit is contained in:
parent
e0c2736e35
commit
b3afdc78a7
6 changed files with 45 additions and 13 deletions
17
src/cache-utils.ts
Normal file
17
src/cache-utils.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import * as path from 'path'
|
||||
import * as glob from '@actions/glob'
|
||||
|
||||
export async function hashFiles(
|
||||
baseDir: string,
|
||||
patterns: string[] = ['**'],
|
||||
followSymbolicLinks = false
|
||||
): Promise<string | null> {
|
||||
const combinedPatterns = patterns
|
||||
.map(pattern => `${baseDir}${path.sep}${pattern}`)
|
||||
.join('\n')
|
||||
return glob.hashFiles(combinedPatterns, {followSymbolicLinks})
|
||||
}
|
||||
|
||||
export function truncateArgs(args: string): string {
|
||||
return args.trim().replace(/\s+/g, ' ').substr(0, 400)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue