mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-22 09:02:50 +00:00
Add a new option to clear the dependency-graph
When changing workflow names or when changing to the new 'dependency-submission' action, it can be useful to clear existing dependency graph snapshots from previous submissions. While the old graphs will eventually "age out", the 'clear' option will submit an empty dependency graph for an existing Job correlator, ensuring that old dependency graphs don't linger.
This commit is contained in:
parent
79fa674432
commit
49ade81b5d
3 changed files with 13 additions and 3 deletions
|
@ -69,7 +69,7 @@ inputs:
|
||||||
default: 'never'
|
default: 'never'
|
||||||
|
|
||||||
dependency-graph:
|
dependency-graph:
|
||||||
description: Specifies if a GitHub dependency snapshot should be generated for each Gradle build, and if so, how. Valid values are 'disabled' (default), 'generate', 'generate-and-submit', 'generate-and-upload' and 'download-and-submit'.
|
description: Specifies if a GitHub dependency snapshot should be generated for each Gradle build, and if so, how. Valid values are 'disabled' (default), 'generate', 'generate-and-submit', 'generate-and-upload', 'download-and-submit' and 'clear'.
|
||||||
required: false
|
required: false
|
||||||
default: 'disabled'
|
default: 'disabled'
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,12 @@ export async function setup(option: DependencyGraphOption): Promise<void> {
|
||||||
'DEPENDENCY_GRAPH_REPORT_DIR',
|
'DEPENDENCY_GRAPH_REPORT_DIR',
|
||||||
path.resolve(layout.workspaceDirectory(), 'dependency-graph-reports')
|
path.resolve(layout.workspaceDirectory(), 'dependency-graph-reports')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// To clear the dependency graph, we generate an empty graph by excluding all projects and configurations
|
||||||
|
if (option === DependencyGraphOption.Clear) {
|
||||||
|
core.exportVariable('DEPENDENCY_GRAPH_INCLUDE_PROJECTS', '')
|
||||||
|
core.exportVariable('DEPENDENCY_GRAPH_INCLUDE_CONFIGURATIONS', '')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function maybeExportVariable(variableName: string, value: unknown): void {
|
function maybeExportVariable(variableName: string, value: unknown): void {
|
||||||
|
@ -58,6 +64,7 @@ export async function complete(option: DependencyGraphOption): Promise<void> {
|
||||||
case DependencyGraphOption.DownloadAndSubmit: // Performed in setup
|
case DependencyGraphOption.DownloadAndSubmit: // Performed in setup
|
||||||
return
|
return
|
||||||
case DependencyGraphOption.GenerateAndSubmit:
|
case DependencyGraphOption.GenerateAndSubmit:
|
||||||
|
case DependencyGraphOption.Clear: // Submit the empty dependency graph
|
||||||
await submitDependencyGraphs(await findGeneratedDependencyGraphFiles())
|
await submitDependencyGraphs(await findGeneratedDependencyGraphFiles())
|
||||||
return
|
return
|
||||||
case DependencyGraphOption.GenerateAndUpload:
|
case DependencyGraphOption.GenerateAndUpload:
|
||||||
|
|
|
@ -101,9 +101,11 @@ export function getDependencyGraphOption(): DependencyGraphOption {
|
||||||
return DependencyGraphOption.GenerateAndUpload
|
return DependencyGraphOption.GenerateAndUpload
|
||||||
case 'download-and-submit':
|
case 'download-and-submit':
|
||||||
return DependencyGraphOption.DownloadAndSubmit
|
return DependencyGraphOption.DownloadAndSubmit
|
||||||
|
case 'clear':
|
||||||
|
return DependencyGraphOption.Clear
|
||||||
}
|
}
|
||||||
throw TypeError(
|
throw TypeError(
|
||||||
`The value '${val}' is not valid for 'dependency-graph'. Valid values are: [disabled, generate, generate-and-submit, generate-and-upload, download-and-submit]. The default value is 'disabled'.`
|
`The value '${val}' is not valid for 'dependency-graph'. Valid values are: [disabled, generate, generate-and-submit, generate-and-upload, download-and-submit, clear]. The default value is 'disabled'.`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +148,8 @@ export enum DependencyGraphOption {
|
||||||
Generate = 'generate',
|
Generate = 'generate',
|
||||||
GenerateAndSubmit = 'generate-and-submit',
|
GenerateAndSubmit = 'generate-and-submit',
|
||||||
GenerateAndUpload = 'generate-and-upload',
|
GenerateAndUpload = 'generate-and-upload',
|
||||||
DownloadAndSubmit = 'download-and-submit'
|
DownloadAndSubmit = 'download-and-submit',
|
||||||
|
Clear = 'clear'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum JobSummaryOption {
|
export enum JobSummaryOption {
|
||||||
|
|
Loading…
Reference in a new issue