diff --git a/.github/workflows/integ-test-dependency-graph.yml b/.github/workflows/integ-test-dependency-graph.yml index 59036a21..98a7ec65 100644 --- a/.github/workflows/integ-test-dependency-graph.yml +++ b/.github/workflows/integ-test-dependency-graph.yml @@ -31,7 +31,7 @@ jobs: - name: Setup Gradle for dependency-graph generate uses: ./ with: - dependency-graph: generate + dependency-graph: generate-and-upload - name: Run gradle build run: ./gradlew build working-directory: .github/workflow-samples/groovy-dsl @@ -55,7 +55,7 @@ jobs: working-directory: .github/workflow-samples/kotlin-dsl submit: - needs: [groovy-generate, kotlin-generate] + needs: [groovy-generate] runs-on: "ubuntu-latest" steps: - name: Checkout sources @@ -85,7 +85,7 @@ jobs: - name: Setup Gradle for dependency-graph generate uses: ./ with: - dependency-graph: generate + dependency-graph: generate-and-submit - id: gradle-assemble run: ./gradlew assemble working-directory: .github/workflow-samples/groovy-dsl diff --git a/action.yml b/action.yml index 362e8b2c..d5d11599 100644 --- a/action.yml +++ b/action.yml @@ -64,7 +64,7 @@ inputs: default: true dependency-graph: - description: Specifies if a GitHub dependency snapshot should be generated for each Gradle build, and if so, how. Valid values are 'disabled' (default), 'generate', 'generate-and-submit' and 'download-and-submit'. + description: Specifies if a GitHub dependency snapshot should be generated for each Gradle build, and if so, how. Valid values are 'disabled' (default), 'generate', 'generate-and-submit', 'generate-and-upload' and 'download-and-submit'. required: false default: 'disabled' diff --git a/src/dependency-graph.ts b/src/dependency-graph.ts index 2978dbdb..3fac6dd5 100644 --- a/src/dependency-graph.ts +++ b/src/dependency-graph.ts @@ -42,33 +42,34 @@ export async function complete(option: DependencyGraphOption): Promise { try { switch (option) { case DependencyGraphOption.Disabled: + case DependencyGraphOption.Generate: // Performed via init-script: nothing to do here case DependencyGraphOption.DownloadAndSubmit: // Performed in setup return - case DependencyGraphOption.Generate: - await uploadDependencyGraphs() - return case DependencyGraphOption.GenerateAndSubmit: - await submitDependencyGraphs(await uploadDependencyGraphs()) + await submitDependencyGraphs(await findGeneratedDependencyGraphFiles()) return + case DependencyGraphOption.GenerateAndUpload: + await uploadDependencyGraphs(await findGeneratedDependencyGraphFiles()) } } catch (e) { core.warning(`Failed to ${option} dependency graph. Will continue. ${String(e)}`) } } -async function uploadDependencyGraphs(): Promise { +async function findGeneratedDependencyGraphFiles(): Promise { const workspaceDirectory = layout.workspaceDirectory() - const graphFiles = await findDependencyGraphFiles(workspaceDirectory) + return await findDependencyGraphFiles(workspaceDirectory) +} - const relativeGraphFiles = graphFiles.map(x => getRelativePathFromWorkspace(x)) +async function uploadDependencyGraphs(dependencyGraphFiles: string[]): Promise { + const workspaceDirectory = layout.workspaceDirectory() + const relativeGraphFiles = dependencyGraphFiles.map(x => getRelativePathFromWorkspace(x)) core.info(`Uploading dependency graph files: ${relativeGraphFiles}`) const artifactClient = new DefaultArtifactClient() - await artifactClient.uploadArtifact(DEPENDENCY_GRAPH_ARTIFACT, graphFiles, workspaceDirectory, { + await artifactClient.uploadArtifact(DEPENDENCY_GRAPH_ARTIFACT, dependencyGraphFiles, workspaceDirectory, { retentionDays: getArtifactRetentionDays() }) - - return graphFiles } async function downloadAndSubmitDependencyGraphs(): Promise { diff --git a/src/input-params.ts b/src/input-params.ts index 50b8159c..c24cfb0d 100644 --- a/src/input-params.ts +++ b/src/input-params.ts @@ -126,5 +126,6 @@ export enum DependencyGraphOption { Disabled = "disabled", Generate = "generate", GenerateAndSubmit = "generate-and-submit", + GenerateAndUpload = "generate-and-upload", DownloadAndSubmit = "download-and-submit" } diff --git a/src/resources/init-scripts/gradle-build-action.github-dependency-graph.init.gradle b/src/resources/init-scripts/gradle-build-action.github-dependency-graph.init.gradle index 76126bc6..2abdac78 100644 --- a/src/resources/init-scripts/gradle-build-action.github-dependency-graph.init.gradle +++ b/src/resources/init-scripts/gradle-build-action.github-dependency-graph.init.gradle @@ -27,7 +27,6 @@ if (isTopLevelBuild) { new File(githubOutput) << "dependency-graph-file=${reportFile.absolutePath}\n" } - println "Generating dependency graph into '${reportFile}'" }