mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-28 11:10:59 -05:00
Update to latest plugin version
This commit is contained in:
parent
fa27d06744
commit
9f977db2d8
6 changed files with 14 additions and 40 deletions
|
@ -82,12 +82,12 @@ jobs:
|
||||||
run: ./gradlew assemble
|
run: ./gradlew assemble
|
||||||
working-directory: .github/workflow-samples/groovy-dsl
|
working-directory: .github/workflow-samples/groovy-dsl
|
||||||
env:
|
env:
|
||||||
GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR: job-correlator
|
GITHUB_JOB_CORRELATOR: job-correlator
|
||||||
- name: Run build
|
- name: Run build
|
||||||
run: ./gradlew build
|
run: ./gradlew build
|
||||||
working-directory: .github/workflow-samples/groovy-dsl
|
working-directory: .github/workflow-samples/groovy-dsl
|
||||||
env:
|
env:
|
||||||
GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR: job-correlator
|
GITHUB_JOB_CORRELATOR: job-correlator
|
||||||
- name: Check generated dependency graphs
|
- name: Check generated dependency graphs
|
||||||
run: |
|
run: |
|
||||||
ls -l dependency-graph-reports
|
ls -l dependency-graph-reports
|
||||||
|
|
26
README.md
26
README.md
|
@ -456,32 +456,6 @@ jobs:
|
||||||
run: ./gradlew build
|
run: ./gradlew build
|
||||||
```
|
```
|
||||||
|
|
||||||
### Running multiple builds in a single Job
|
|
||||||
|
|
||||||
GitHub tracks dependency snapshots based on the `job.correlator` value that is embedded in the snapshot. When a newer snapshot for an existing correlator is submitted, the previous snapshot is replaced. Snapshots with different `job.correlator` values are additive to the overall dependency graph for the repository.
|
|
||||||
|
|
||||||
The `gradle-build-action` will generate a `job.correlator` value based on the workflow name, job id and matrix values. However, if your job steps contains multiple Gradle invocations, then a unique correlator value must be assigned to each. You assign a correlator by setting the `GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR` environment variable.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
name: dependency-graph
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Setup Gradle to generate and submit dependency graphs
|
|
||||||
uses: gradle/gradle-build-action@dependency-graph
|
|
||||||
with:
|
|
||||||
dependency-graph: generate-and-submit
|
|
||||||
- name: Run first build using the default job correlator 'dependency-graph-build'
|
|
||||||
run: ./gradlew build
|
|
||||||
- name: Run second build providing a unique job correlator
|
|
||||||
run: ./gradlew test
|
|
||||||
env:
|
|
||||||
GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR: dependency-graph-test
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
### Dependency snapshots generated for pull requests
|
### Dependency snapshots generated for pull requests
|
||||||
|
|
||||||
This `contents: write` permission is not available for any workflow that is triggered by a pull request submitted from a forked repository, since it would permit a malicious pull request to make repository changes.
|
This `contents: write` permission is not available for any workflow that is triggered by a pull request submitted from a forked repository, since it would permit a malicious pull request to make repository changes.
|
||||||
|
|
|
@ -21,10 +21,10 @@ 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_DEPENDENCY_GRAPH_JOB_CORRELATOR', jobCorrelator)
|
core.exportVariable('GITHUB_JOB_CORRELATOR', jobCorrelator)
|
||||||
core.exportVariable('GITHUB_DEPENDENCY_GRAPH_JOB_ID', github.context.runId)
|
core.exportVariable('GITHUB_JOB_ID', github.context.runId)
|
||||||
core.exportVariable(
|
core.exportVariable(
|
||||||
'GITHUB_DEPENDENCY_GRAPH_REPORT_DIR',
|
'DEPENDENCY_GRAPH_REPORT_DIR',
|
||||||
path.resolve(layout.workspaceDirectory(), 'dependency-graph-reports')
|
path.resolve(layout.workspaceDirectory(), 'dependency-graph-reports')
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.0.6"
|
classpath "org.gradle:github-dependency-graph-gradle-plugin:0.0.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
apply plugin: org.gradle.github.GitHubDependencyGraphPlugin
|
apply plugin: org.gradle.github.GitHubDependencyGraphPlugin
|
||||||
|
|
|
@ -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 jobCorrelator = ensureUniqueJobCorrelator(System.env.GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR)
|
def jobCorrelator = ensureUniqueJobCorrelator(System.env.GITHUB_JOB_CORRELATOR)
|
||||||
|
|
||||||
if (jobCorrelator == null) {
|
if (jobCorrelator == null) {
|
||||||
println "::warning::No dependency snapshot 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."
|
println "::warning::No dependency snapshot generated for step: report file for '${jobCorrelator}' created in earlier step. Each build invocation requires a unique job correlator: specify GITHUB_JOB_CORRELATOR var for this step."
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ apply from: 'github-dependency-graph-gradle-plugin-apply.groovy'
|
||||||
* - When found, this value is set as a System property override.
|
* - When found, this value is set as a System property override.
|
||||||
*/
|
*/
|
||||||
String ensureUniqueJobCorrelator(String jobCorrelator) {
|
String ensureUniqueJobCorrelator(String jobCorrelator) {
|
||||||
def reportDir = System.env.GITHUB_DEPENDENCY_GRAPH_REPORT_DIR
|
def reportDir = System.env.DEPENDENCY_GRAPH_REPORT_DIR
|
||||||
def reportFile = new File(reportDir, jobCorrelator + ".json")
|
def reportFile = new File(reportDir, jobCorrelator + ".json")
|
||||||
if (!reportFile.exists()) return jobCorrelator
|
if (!reportFile.exists()) return jobCorrelator
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ String ensureUniqueJobCorrelator(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['org.gradle.github.env.GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR'] = candidateCorrelator
|
System.properties['GITHUB_JOB_CORRELATOR'] = candidateCorrelator
|
||||||
return candidateCorrelator
|
return candidateCorrelator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,12 +109,12 @@ class TestDependencyGraph extends BaseInitScriptTest {
|
||||||
def getEnvVars() {
|
def getEnvVars() {
|
||||||
return [
|
return [
|
||||||
GITHUB_DEPENDENCY_GRAPH_ENABLED: "true",
|
GITHUB_DEPENDENCY_GRAPH_ENABLED: "true",
|
||||||
GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR: "CORRELATOR",
|
GITHUB_JOB_CORRELATOR: "CORRELATOR",
|
||||||
GITHUB_DEPENDENCY_GRAPH_JOB_ID: "1",
|
GITHUB_JOB_ID: "1",
|
||||||
GITHUB_DEPENDENCY_GRAPH_REPORT_DIR: reportsDir.absolutePath,
|
|
||||||
GITHUB_REF: "main",
|
GITHUB_REF: "main",
|
||||||
GITHUB_SHA: "123456",
|
GITHUB_SHA: "123456",
|
||||||
GITHUB_WORKSPACE: testProjectDir.absolutePath
|
GITHUB_WORKSPACE: testProjectDir.absolutePath,
|
||||||
|
DEPENDENCY_GRAPH_REPORT_DIR: reportsDir.absolutePath
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue