mirror of
				https://github.com/gradle/gradle-build-action.git
				synced 2025-11-04 09:50:23 +08:00 
			
		
		
		
	Add experimental support for 'strict-match' caching
By default, the action will attempt to restore a Gradle User Home cache entry from a different set of matrix inputs (or a different Job entirely) if an existing entry is not found for the current Job (including matrix inputs). By specifying the experimental `gradle-home-cache-strict-match` parameter, a user can avoid this fuzzy matching and ensure that a job execution starts with an empty Gradle User Home if no entry from a prior execution is found.
This commit is contained in:
		@@ -48,8 +48,12 @@ inputs:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  # EXPERIMENTAL & INTERNAL ACTION INPUTS
 | 
					  # EXPERIMENTAL & INTERNAL ACTION INPUTS
 | 
				
			||||||
  # The following action properties allow fine-grained tweaking of the action caching behaviour.
 | 
					  # The following action properties allow fine-grained tweaking of the action caching behaviour.
 | 
				
			||||||
  # These properties are not designed for production use, and may change without notice in a subsequent release of `gradle-build-action`.
 | 
					  # These properties are experimental and not (yet) designed for production use, and may change without notice in a subsequent release of `gradle-build-action`.
 | 
				
			||||||
  # Use at your own risk!
 | 
					  # Use at your own risk!
 | 
				
			||||||
 | 
					  gradle-home-cache-strict-match:
 | 
				
			||||||
 | 
					    description: When 'true', the action will not attempt to restore the Gradle User Home entries from other Jobs.
 | 
				
			||||||
 | 
					    required: false
 | 
				
			||||||
 | 
					    default: false
 | 
				
			||||||
  workflow-job-context:
 | 
					  workflow-job-context:
 | 
				
			||||||
    description: Used to uniquely identify the current job invocation. Defaults to the matrix values for this job; this should not be overridden by users (INTERNAL).
 | 
					    description: Used to uniquely identify the current job invocation. Defaults to the matrix values for this job; this should not be overridden by users (INTERNAL).
 | 
				
			||||||
    required: false
 | 
					    required: false
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,12 +15,13 @@ import {
 | 
				
			|||||||
} from './cache-utils'
 | 
					} from './cache-utils'
 | 
				
			||||||
import {ConfigurationCacheEntryExtractor, GradleHomeEntryExtractor} from './cache-extract-entries'
 | 
					import {ConfigurationCacheEntryExtractor, GradleHomeEntryExtractor} from './cache-extract-entries'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const CACHE_PROTOCOL_VERSION = 'v5-'
 | 
					const CACHE_PROTOCOL_VERSION = 'v6-'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const META_FILE_DIR = '.gradle-build-action'
 | 
					export const META_FILE_DIR = '.gradle-build-action'
 | 
				
			||||||
export const PROJECT_ROOTS_FILE = 'project-roots.txt'
 | 
					export const PROJECT_ROOTS_FILE = 'project-roots.txt'
 | 
				
			||||||
const INCLUDE_PATHS_PARAMETER = 'gradle-home-cache-includes'
 | 
					const INCLUDE_PATHS_PARAMETER = 'gradle-home-cache-includes'
 | 
				
			||||||
const EXCLUDE_PATHS_PARAMETER = 'gradle-home-cache-excludes'
 | 
					const EXCLUDE_PATHS_PARAMETER = 'gradle-home-cache-excludes'
 | 
				
			||||||
 | 
					const STRICT_CACHE_MATCH_PARAMETER = 'gradle-home-cache-strict-match'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Represents a key used to restore a cache entry.
 | 
					 * Represents a key used to restore a cache entry.
 | 
				
			||||||
@@ -70,6 +71,10 @@ function generateCacheKey(cacheName: string): CacheKey {
 | 
				
			|||||||
    // Exact match on Git SHA
 | 
					    // Exact match on Git SHA
 | 
				
			||||||
    const cacheKey = `${cacheKeyForJobContext}-${github.context.sha}`
 | 
					    const cacheKey = `${cacheKeyForJobContext}-${github.context.sha}`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (core.getBooleanInput(STRICT_CACHE_MATCH_PARAMETER)) {
 | 
				
			||||||
 | 
					        return new CacheKey(cacheKey, [cacheKeyForJobContext])
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return new CacheKey(cacheKey, [cacheKeyForJobContext, cacheKeyForJob, cacheKeyForOs])
 | 
					    return new CacheKey(cacheKey, [cacheKeyForJobContext, cacheKeyForJob, cacheKeyForOs])
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user