Skip to content

Commit

Permalink
Don't upload for generate-and-submit
Browse files Browse the repository at this point in the history
  • Loading branch information
bigdaz committed Dec 24, 2023
1 parent 3a94da6 commit f4ce846
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/integ-test-dependency-graph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
21 changes: 11 additions & 10 deletions src/dependency-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,33 +42,34 @@ export async function complete(option: DependencyGraphOption): Promise<void> {
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<string[]> {
async function findGeneratedDependencyGraphFiles(): Promise<string[]> {
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<void> {
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<void> {
Expand Down
1 change: 1 addition & 0 deletions src/input-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,6 @@ export enum DependencyGraphOption {
Disabled = "disabled",
Generate = "generate",
GenerateAndSubmit = "generate-and-submit",
GenerateAndUpload = "generate-and-upload",
DownloadAndSubmit = "download-and-submit"
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ if (isTopLevelBuild) {
new File(githubOutput) << "dependency-graph-file=${reportFile.absolutePath}\n"
}


println "Generating dependency graph into '${reportFile}'"
}

Expand Down

0 comments on commit f4ce846

Please sign in to comment.