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

@@ -4,8 +4,6 @@ import * as path from 'path'
import * as os from 'os'
import * as caches from './caches'
import * as layout from './repository-layout'
import * as params from './input-params'
import * as dependencyGraph from './dependency-graph'
import * as jobSummary from './job-summary'
import * as buildScan from './build-scan'
@@ -18,14 +16,14 @@ const USER_HOME = 'USER_HOME'
const GRADLE_USER_HOME = 'GRADLE_USER_HOME'
const CACHE_LISTENER = 'CACHE_LISTENER'
export async function setup(): Promise<void> {
export async function setup(): Promise<boolean> {
const userHome = await determineUserHome()
const gradleUserHome = await determineGradleUserHome()
// Bypass setup on all but first action step in workflow.
if (process.env[GRADLE_SETUP_VAR]) {
core.info('Gradle setup only performed on first gradle/actions step in workflow.')
return
return false
}
// Record setup complete: visible to all subsequent actions and prevents duplicate setup
core.exportVariable(GRADLE_SETUP_VAR, true)
@@ -41,15 +39,15 @@ export async function setup(): Promise<void> {
core.saveState(CACHE_LISTENER, cacheListener.stringify())
await dependencyGraph.setup(params.getDependencyGraphOption())
buildScan.setup()
return true
}
export async function complete(): Promise<void> {
export async function complete(): Promise<boolean> {
if (!core.getState(GRADLE_SETUP_VAR)) {
core.info('Gradle setup post-action only performed for first gradle/actions step in workflow.')
return
return false
}
core.info('In post-action step')
@@ -64,9 +62,9 @@ export async function complete(): Promise<void> {
await jobSummary.generateJobSummary(buildResults, cacheListener)
await dependencyGraph.complete(params.getDependencyGraphOption())
core.info('Completed post-action step')
return true
}
async function determineGradleUserHome(): Promise<string> {