Update to dep-graph plugin 0.4.0

This commit is contained in:
daz 2023-09-25 21:17:05 -06:00 committed by Daz DeBoer
parent b5126f31db
commit 4441c9f9bf
4 changed files with 14 additions and 11 deletions

View File

@ -21,8 +21,11 @@ export function setup(option: DependencyGraphOption): void {
core.info('Enabling dependency graph generation') core.info('Enabling dependency graph generation')
const jobCorrelator = getJobCorrelator() const jobCorrelator = getJobCorrelator()
core.exportVariable('GITHUB_DEPENDENCY_GRAPH_ENABLED', 'true') core.exportVariable('GITHUB_DEPENDENCY_GRAPH_ENABLED', 'true')
core.exportVariable('GITHUB_JOB_CORRELATOR', jobCorrelator) core.exportVariable('GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR', jobCorrelator)
core.exportVariable('GITHUB_JOB_ID', github.context.runId) core.exportVariable('GITHUB_DEPENDENCY_GRAPH_JOB_ID', github.context.runId)
core.exportVariable('GITHUB_DEPENDENCY_GRAPH_REF', github.context.ref)
core.exportVariable('GITHUB_DEPENDENCY_GRAPH_SHA', github.context.sha)
core.exportVariable('GITHUB_DEPENDENCY_GRAPH_WORKSPACE', layout.workspaceDirectory())
core.exportVariable( core.exportVariable(
'DEPENDENCY_GRAPH_REPORT_DIR', 'DEPENDENCY_GRAPH_REPORT_DIR',
path.resolve(layout.workspaceDirectory(), 'dependency-graph-reports') path.resolve(layout.workspaceDirectory(), 'dependency-graph-reports')

View File

@ -3,7 +3,7 @@ buildscript {
maven { url "https://plugins.gradle.org/m2/" } maven { url "https://plugins.gradle.org/m2/" }
} }
dependencies { dependencies {
classpath "org.gradle:github-dependency-graph-gradle-plugin:0.2.0" classpath "org.gradle:github-dependency-graph-gradle-plugin:0.4.0"
} }
} }
apply plugin: org.gradle.github.GitHubDependencyGraphPlugin apply plugin: org.gradle.github.GitHubDependencyGraphPlugin

View File

@ -15,10 +15,10 @@ if (GradleVersion.current().baseVersion < GradleVersion.version("5.0")) {
// This is only required for top-level builds // This is only required for top-level builds
def isTopLevelBuild = gradle.getParent() == null def isTopLevelBuild = gradle.getParent() == null
if (isTopLevelBuild) { if (isTopLevelBuild) {
def reportFile = getUniqueReportFile(System.env.GITHUB_JOB_CORRELATOR) def reportFile = getUniqueReportFile(System.env.GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR)
if (reportFile == null) { if (reportFile == null) {
println "::warning::No dependency snapshot generated for step. Could not determine unique job correlator - specify GITHUB_JOB_CORRELATOR var for this step." println "::warning::No dependency snapshot generated for step. Could not determine unique job correlator - specify GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR var for this step."
return return
} }
@ -49,7 +49,7 @@ File getUniqueReportFile(String jobCorrelator) {
def candidateCorrelator = jobCorrelator + "-" + i def candidateCorrelator = jobCorrelator + "-" + i
def candidateFile = new File(reportDir, candidateCorrelator + ".json") def candidateFile = new File(reportDir, candidateCorrelator + ".json")
if (!candidateFile.exists()) { if (!candidateFile.exists()) {
System.properties['GITHUB_JOB_CORRELATOR'] = candidateCorrelator System.properties['GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR'] = candidateCorrelator
return candidateFile return candidateFile
} }
} }

View File

@ -110,11 +110,11 @@ class TestDependencyGraph extends BaseInitScriptTest {
def getEnvVars() { def getEnvVars() {
return [ return [
GITHUB_DEPENDENCY_GRAPH_ENABLED: "true", GITHUB_DEPENDENCY_GRAPH_ENABLED: "true",
GITHUB_JOB_CORRELATOR: "CORRELATOR", GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR: "CORRELATOR",
GITHUB_JOB_ID: "1", GITHUB_DEPENDENCY_GRAPH_JOB_ID: "1",
GITHUB_REF: "main", GITHUB_DEPENDENCY_GRAPH_REF: "main",
GITHUB_SHA: "123456", GITHUB_DEPENDENCY_GRAPH_SHA: "123456",
GITHUB_WORKSPACE: testProjectDir.absolutePath, GITHUB_DEPENDENCY_GRAPH_WORKSPACE: testProjectDir.absolutePath,
DEPENDENCY_GRAPH_REPORT_DIR: reportsDir.absolutePath, DEPENDENCY_GRAPH_REPORT_DIR: reportsDir.absolutePath,
GITHUB_OUTPUT: gitHubOutputFile.absolutePath GITHUB_OUTPUT: gitHubOutputFile.absolutePath
] ]