Make dependency-submission and setup-gradle play nicely

Now, a `dependency-submission` step will trigger a dependency-graph
generation, even if it follows a `setup-gradle` step in the workflow.

Similarly, a `setup-gradle` step with `dependency-graph` configured
will function as expected even if it follows a `setup-gradle` step.
This commit is contained in:
daz
2024-04-06 19:03:51 -06:00
parent ebf4d13461
commit ed4d086d37
7 changed files with 33 additions and 26 deletions

View File

@@ -5,6 +5,7 @@ import * as execution from '../execution'
import * as provisioner from '../provision'
import * as layout from '../repository-layout'
import * as params from '../input-params'
import * as dependencyGraph from '../dependency-graph'
/**
* The main entry point for the action, called by Github Actions for the step.
@@ -14,6 +15,9 @@ export async function run(): Promise<void> {
// Configure Gradle environment (Gradle User Home)
await setupGradle.setup()
// Configure the dependency graph submission
await dependencyGraph.setup(params.getDependencyGraphOption())
// Download and install Gradle if required
const executable = await provisioner.provisionGradle()

View File

@@ -1,5 +1,8 @@
import * as core from '@actions/core'
import * as setupGradle from '../setup-gradle'
import * as dependencyGraph from '../dependency-graph'
import {getDependencyGraphOption} from '../input-params'
import {PostActionJobFailure} from '../errors'
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
@@ -12,7 +15,10 @@ process.on('uncaughtException', e => handleFailure(e))
*/
export async function run(): Promise<void> {
try {
await setupGradle.complete()
if (await setupGradle.complete()) {
// Only submit the dependency graphs once per job
await dependencyGraph.complete(getDependencyGraphOption())
}
} catch (error) {
if (error instanceof PostActionJobFailure) {
core.setFailed(String(error))