From f92e7c34281253ab157dc15728e749a7d842fe94 Mon Sep 17 00:00:00 2001 From: daz Date: Fri, 29 Sep 2023 20:36:16 -0600 Subject: [PATCH] Improve compat with dependency-review-action 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. --- README.md | 4 ++-- src/dependency-graph.ts | 12 ++++++++---- src/setup-gradle.ts | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4409789..197a65b 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/dependency-graph.ts b/src/dependency-graph.ts index 1243d6b..6aa8305 100644 --- a/src/dependency-graph.ts +++ b/src/dependency-graph.ts @@ -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 { + if (option === DependencyGraphOption.Disabled) { + return + } + // Download and submit early, for compatability with dependency review. + if (option === DependencyGraphOption.DownloadAndSubmit) { + await downloadAndSubmitDependencyGraphs() return } @@ -35,6 +40,7 @@ export function setup(option: DependencyGraphOption): void { export async function complete(option: DependencyGraphOption): Promise { switch (option) { case DependencyGraphOption.Disabled: + case DependencyGraphOption.DownloadAndSubmit: // Performed in setup return case DependencyGraphOption.Generate: await uploadDependencyGraphs() @@ -42,8 +48,6 @@ export async function complete(option: DependencyGraphOption): Promise { case DependencyGraphOption.GenerateAndSubmit: await submitDependencyGraphs(await uploadDependencyGraphs()) return - case DependencyGraphOption.DownloadAndSubmit: - await downloadAndSubmitDependencyGraphs() } } diff --git a/src/setup-gradle.ts b/src/setup-gradle.ts index 2e376a9..2bd0c01 100644 --- a/src/setup-gradle.ts +++ b/src/setup-gradle.ts @@ -38,7 +38,7 @@ export async function setup(): Promise { core.saveState(CACHE_LISTENER, cacheListener.stringify()) - dependencyGraph.setup(params.getDependencyGraphOption()) + await dependencyGraph.setup(params.getDependencyGraphOption()) } export async function complete(): Promise { @@ -62,7 +62,7 @@ export async function complete(): Promise { logJobSummary(buildResults, cacheListener) } - dependencyGraph.complete(params.getDependencyGraphOption()) + await dependencyGraph.complete(params.getDependencyGraphOption()) } async function determineGradleUserHome(): Promise {