diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 246128ff..3bd5e4b4 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -72,8 +72,8 @@ jobs: run: ./plugin-self-test ForceDependencyResolutionPlugin_resolveAllDependencies env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_JOB_ID: ${{ github.run_id }} - GITHUB_JOB_CORRELATOR: "plugin-self-test" + GITHUB_DEPENDENCY_GRAPH_JOB_ID: ${{ github.run_id }} + GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR: "plugin-self-test" - name: Save plugin JSON report uses: actions/upload-artifact@v3 diff --git a/README.md b/README.md index 27a3fc95..fc659e1b 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,11 @@ This causes 2 separate plugins to be applied, that can be used independently: ### Required environment variables The following environment variables configure the snapshot generated by the `GitHubDependencyExtractorPlugin`. See the [GitHub Dependency Submission API docs](https://docs.github.com/en/rest/dependency-graph/dependency-submission?apiVersion=2022-11-28) for details: -- `GITHUB_JOB_CORRELATOR`: Sets the `job.correlator` value for the dependency submission -- `GITHUB_JOB_ID`: Sets the `job.id` value for the dependency submission -- `GITHUB_REF`: Sets the `ref` value for the dependency submission -- `GITHUB_SHA`: Sets the `sha` value for the dependency submission -- `GITHUB_WORKSPACE`: Sets the root directory of the github repository +- `GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR`: Sets the `job.correlator` value for the dependency submission +- `GITHUB_DEPENDENCY_GRAPH_JOB_ID`: Sets the `job.id` value for the dependency submission +- `GITHUB_DEPENDENCY_GRAPH_REF`: Sets the `ref` value for the commit that generated the dependency graph +- `GITHUB_DEPENDENCY_GRAPH_SHA`: Sets the `sha` value for the commit that generated the dependency graph +- `GITHUB_DEPENDENCY_GRAPH_WORKSPACE`: Sets the root directory of the github repository - `DEPENDENCY_GRAPH_REPORT_DIR` (optional): Specifies where the dependency graph report will be generated Each of these values can also be provided via a system property. diff --git a/plugin-self-test-local b/plugin-self-test-local index f013df5b..dd8a7301 100755 --- a/plugin-self-test-local +++ b/plugin-self-test-local @@ -1,9 +1,9 @@ #!/bin/sh -export GITHUB_JOB_ID="42" -export GITHUB_JOB_CORRELATOR="plugin-self-test" -export GITHUB_REF="refs/heads/main" -export GITHUB_SHA=$( git rev-parse HEAD ) -export GITHUB_WORKSPACE=$( pwd ) +export GITHUB_DEPENDENCY_GRAPH_JOB_ID="42" +export GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR="plugin-self-test" +export GITHUB_DEPENDENCY_GRAPH_REF="refs/heads/main" +export GITHUB_DEPENDENCY_GRAPH_SHA=$( git rev-parse HEAD ) +export GITHUB_DEPENDENCY_GRAPH_WORKSPACE=$( pwd ) ./plugin-self-test $* diff --git a/plugin-test/src/test/groovy/org/gradle/github/dependencygraph/BaseExtractorTest.groovy b/plugin-test/src/test/groovy/org/gradle/github/dependencygraph/BaseExtractorTest.groovy index a6b69037..d0ee6346 100644 --- a/plugin-test/src/test/groovy/org/gradle/github/dependencygraph/BaseExtractorTest.groovy +++ b/plugin-test/src/test/groovy/org/gradle/github/dependencygraph/BaseExtractorTest.groovy @@ -289,12 +289,12 @@ abstract class BaseExtractorTest extends Specification { Map asEnvironmentMap() { return [ - "GITHUB_JOB_ID" : jobId, - "GITHUB_JOB_CORRELATOR": jobCorrelator, + "GITHUB_DEPENDENCY_GRAPH_JOB_ID" : jobId, + "GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR": jobCorrelator, "DEPENDENCY_GRAPH_REPORT_DIR" : reportDir, - "GITHUB_REF" : ref, - "GITHUB_SHA" : sha, - "GITHUB_WORKSPACE" : workspace, + "GITHUB_DEPENDENCY_GRAPH_REF" : ref, + "GITHUB_DEPENDENCY_GRAPH_SHA" : sha, + "GITHUB_DEPENDENCY_GRAPH_WORKSPACE" : workspace, "GITHUB_TOKEN" : gitHubToken ] } diff --git a/plugin-test/src/test/groovy/org/gradle/github/dependencygraph/DependencyExtractorConfigTest.groovy b/plugin-test/src/test/groovy/org/gradle/github/dependencygraph/DependencyExtractorConfigTest.groovy index d08445a2..196fb72a 100644 --- a/plugin-test/src/test/groovy/org/gradle/github/dependencygraph/DependencyExtractorConfigTest.groovy +++ b/plugin-test/src/test/groovy/org/gradle/github/dependencygraph/DependencyExtractorConfigTest.groovy @@ -38,8 +38,8 @@ class DependencyExtractorConfigTest extends BaseExtractorTest { when: executer - .withArgument("-DGITHUB_JOB_CORRELATOR=TEST_CORRELATOR") - .withArgument("-DGITHUB_REF=refs/my-branch/foo") + .withArgument("-DGITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR=TEST_CORRELATOR") + .withArgument("-DGITHUB_DEPENDENCY_GRAPH_REF=refs/my-branch/foo") run() then: @@ -81,11 +81,11 @@ class DependencyExtractorConfigTest extends BaseExtractorTest { def "fails gracefully if configuration values not set"() { when: def envVars = environmentVars.asEnvironmentMap() - envVars.remove("GITHUB_JOB_CORRELATOR") + envVars.remove("GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR") executer.withEnvironmentVars(envVars) def result = executer.runWithFailure() then: - result.output.contains("'GITHUB_JOB_CORRELATOR' must be set") + result.output.contains("'GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR' must be set") } } diff --git a/plugin/src/main/kotlin/org/gradle/github/dependencygraph/GitHubSnapshotParams.kt b/plugin/src/main/kotlin/org/gradle/github/dependencygraph/GitHubSnapshotParams.kt index ff09a3bb..83066c41 100644 --- a/plugin/src/main/kotlin/org/gradle/github/dependencygraph/GitHubSnapshotParams.kt +++ b/plugin/src/main/kotlin/org/gradle/github/dependencygraph/GitHubSnapshotParams.kt @@ -4,15 +4,15 @@ import org.gradle.dependencygraph.util.PluginParameters import java.nio.file.Path import java.nio.file.Paths -const val PARAM_JOB_ID = "GITHUB_JOB_ID" -const val PARAM_JOB_CORRELATOR = "GITHUB_JOB_CORRELATOR" -const val PARAM_GITHUB_REF = "GITHUB_REF" -const val PARAM_GITHUB_SHA = "GITHUB_SHA" +const val PARAM_JOB_ID = "GITHUB_DEPENDENCY_GRAPH_JOB_ID" +const val PARAM_JOB_CORRELATOR = "GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR" +const val PARAM_GITHUB_REF = "GITHUB_DEPENDENCY_GRAPH_REF" +const val PARAM_GITHUB_SHA = "GITHUB_DEPENDENCY_GRAPH_SHA" /** * Environment variable should be set to the workspace directory that the Git repository is checked out in. * This is used to determine relative path to build files referenced in the dependency graph. */ -const val PARAM_GITHUB_WORKSPACE = "GITHUB_WORKSPACE" +const val PARAM_GITHUB_WORKSPACE = "GITHUB_DEPENDENCY_GRAPH_WORKSPACE" class GitHubSnapshotParams(private val pluginParameters: PluginParameters) { val dependencyGraphJobCorrelator: String = pluginParameters.load(PARAM_JOB_CORRELATOR)