Support multiple invocations in dependency-graph init script

If an existing dependency graph file is present for the configured job correlator,
we now generate a unique correlator value for the invocation. This allows the action
to submit dependency snapshots for a series of Gradle invocations within the same Job.

This commit updates to `github-dependency-graph-gradle-plugin@v0.0.6`, which reduces
redundancy in the mapping of resolved Gradle dependencies to the GitHub Dependency Graph.
This commit is contained in:
daz 2023-07-15 18:06:38 -06:00
parent 3c11eee5f9
commit b69de5f2a9
No known key found for this signature in database
4 changed files with 100 additions and 10 deletions

View file

@ -49,18 +49,46 @@ class TestDependencyGraph extends BaseInitScriptTest {
testGradleVersion << NO_DEPENDENCY_GRAPH_VERSIONS
}
def "warns and does not overwrite existing report file"() {
def "constructs unique job correlator for each build invocation"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm
def reportFile1 = new File(reportsDir, "CORRELATOR-1.json")
def reportFile2 = new File(reportsDir, "CORRELATOR-2.json")
buildFile << """
task firstTask {
doLast {
println "First"
}
}
task secondTask {
doLast {
println "Second"
}
}
"""
when:
reportsDir.mkdirs()
reportFile << "DUMMY CONTENT"
def result = run(['help'], initScript, testGradleVersion.gradleVersion, [], envVars)
run(['help'], initScript, testGradleVersion.gradleVersion, [], envVars)
then:
assert reportFile.text == "DUMMY CONTENT"
assert result.output.contains("::warning::No dependency snapshot generated for step")
assert reportFile.exists()
when:
run(['first'], initScript, testGradleVersion.gradleVersion, [], envVars)
then:
assert reportFile.exists()
assert reportFile1.exists()
when:
run(['second'], initScript, testGradleVersion.gradleVersion, [], envVars)
then:
assert reportFile.exists()
assert reportFile1.exists()
assert reportFile2.exists()
where:
testGradleVersion << DEPENDENCY_GRAPH_VERSIONS
}