Skip to content

Commit

Permalink
Improve compat with dependency-review-action
Browse files Browse the repository at this point in the history
When using 'download-and-submit' for dependency graphs, we now run the
submission immediately instead of waiting until the post-action.
This allows a single job to both submit the graph and run the dependency
review action.
  • Loading branch information
bigdaz committed Sep 30, 2023
1 parent d1b726d commit f92e7c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,8 @@ jobs:
steps:
- name: Retrieve dependency graph artifact and submit
uses: gradle/gradle-build-action@v2
with:
dependency-graph: download-and-submit
with:
dependency-graph: download-and-submit
```

## Gradle version compatibility
Expand Down
12 changes: 8 additions & 4 deletions src/dependency-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ import {DependencyGraphOption, getJobMatrix} from './input-params'

const DEPENDENCY_GRAPH_ARTIFACT = 'dependency-graph'

export function setup(option: DependencyGraphOption): void {
if (option === DependencyGraphOption.Disabled || option === DependencyGraphOption.DownloadAndSubmit) {
export async function setup(option: DependencyGraphOption): Promise<void> {
if (option === DependencyGraphOption.Disabled) {
return
}
// Download and submit early, for compatability with dependency review.
if (option === DependencyGraphOption.DownloadAndSubmit) {
await downloadAndSubmitDependencyGraphs()
return
}

Expand All @@ -35,15 +40,14 @@ export function setup(option: DependencyGraphOption): void {
export async function complete(option: DependencyGraphOption): Promise<void> {
switch (option) {
case DependencyGraphOption.Disabled:
case DependencyGraphOption.DownloadAndSubmit: // Performed in setup
return
case DependencyGraphOption.Generate:
await uploadDependencyGraphs()
return
case DependencyGraphOption.GenerateAndSubmit:
await submitDependencyGraphs(await uploadDependencyGraphs())
return
case DependencyGraphOption.DownloadAndSubmit:
await downloadAndSubmitDependencyGraphs()
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/setup-gradle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function setup(): Promise<void> {

core.saveState(CACHE_LISTENER, cacheListener.stringify())

dependencyGraph.setup(params.getDependencyGraphOption())
await dependencyGraph.setup(params.getDependencyGraphOption())
}

export async function complete(): Promise<void> {
Expand All @@ -62,7 +62,7 @@ export async function complete(): Promise<void> {
logJobSummary(buildResults, cacheListener)
}

dependencyGraph.complete(params.getDependencyGraphOption())
await dependencyGraph.complete(params.getDependencyGraphOption())
}

async function determineGradleUserHome(): Promise<string> {
Expand Down

0 comments on commit f92e7c3

Please sign in to comment.