Configure Gradle User Home for dependency-graph

Instead of requiring an action step to generate the graph, configure Gradle User Home
so that subsequent Gradle invocations can generate a graph. Any generated graph files
are uploaded as artifacts on job completion.

- Construct job.correlator from workflow/job/matrix
- Export job.correlator as an environment var
- Upload artifacts at job completion in post-action step
- Specify the location of dependency graph report
- Only apply dependency graph init script when explicitly enabled
This commit is contained in:
daz 2023-07-01 19:00:28 -06:00
parent a6ad1901be
commit 4c9c435d2f
No known key found for this signature in database
11 changed files with 153 additions and 65 deletions

View file

@ -0,0 +1,6 @@
buildscript {
dependencies {
classpath files("github-dependency-graph-gradle-plugin-0.0.3.jar")
}
}
apply plugin: org.gradle.github.GitHubDependencyGraphPlugin

View file

@ -1,7 +1,17 @@
// TODO:DAZ This should be conditionally applied, since the script may be present when not required.
initscript {
dependencies {
classpath files("github-dependency-graph-gradle-plugin-0.0.3.jar")
}
if (System.env.GITHUB_DEPENDENCY_GRAPH_ENABLED != "true") {
return
}
apply plugin: org.gradle.github.GitHubDependencyGraphPlugin
def reportDir = System.env.GITHUB_DEPENDENCY_GRAPH_REPORT_DIR
def jobCorrelator = System.env.GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR
def reportFile = new File(reportDir, jobCorrelator + ".json")
if (reportFile.exists()) {
println "::warning::No dependency report generated for step: report file for '${jobCorrelator}' created in earlier step. Each build invocation requires a unique job correlator: specify GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR var for this step."
return
}
println "Generating dependency graph for '${jobCorrelator}'"
// TODO:DAZ This should be conditionally applied, since the script may be present when not required.
apply from: 'github-dependency-graph-gradle-plugin-apply.groovy'