mirror of
https://github.com/gradle/actions.git
synced 2025-08-23 18:31:28 +08:00
Revert "Provide default config values for dependency-submission"
This reverts commit b7ef93c7b71dae2439fcb0c4686dbfa7b986cb63.
This commit is contained in:
parent
e40c718900
commit
627fa7627c
@ -34,15 +34,6 @@ inputs:
|
|||||||
Additional arguments to pass to Gradle. For example, `--no-configuration-cache --stacktrace`.
|
Additional arguments to pass to Gradle. For example, `--no-configuration-cache --stacktrace`.
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
add-job-summary:
|
|
||||||
description: Specifies when a Job Summary should be inluded in the action results. Valid values are 'never', 'always' (default), and 'on-failure'.
|
|
||||||
required: false
|
|
||||||
default: 'always'
|
|
||||||
add-job-summary-as-pr-comment:
|
|
||||||
description: Specifies when each Job Summary should be added as a PR comment. Valid values are 'never' (default), 'always', and 'on-failure'. No action will be taken if the workflow was not triggered from a pull request.
|
|
||||||
required: false
|
|
||||||
default: 'never'
|
|
||||||
|
|
||||||
build-scan-publish:
|
build-scan-publish:
|
||||||
description: |
|
description: |
|
||||||
Set to 'true' to automatically publish build results as a Build Scan on scans.gradle.com.
|
Set to 'true' to automatically publish build results as a Build Scan on scans.gradle.com.
|
||||||
@ -56,6 +47,29 @@ inputs:
|
|||||||
description: Indicate that you agree to the Build Scan® terms of use. This input value must be "yes".
|
description: Indicate that you agree to the Build Scan® terms of use. This input value must be "yes".
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
|
# HARD-CODED DEFAULTS - These should be removed from here and set directly in code
|
||||||
|
dependency-graph-continue-on-failure:
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
artifact-retention-days:
|
||||||
|
required: false
|
||||||
|
default: 1
|
||||||
|
add-job-summary:
|
||||||
|
required: false
|
||||||
|
default: 'always'
|
||||||
|
add-job-summary-as-pr-comment:
|
||||||
|
required: false
|
||||||
|
default: 'never'
|
||||||
|
workflow-job-context:
|
||||||
|
required: false
|
||||||
|
default: ${{ toJSON(matrix) }}
|
||||||
|
github-token:
|
||||||
|
default: ${{ github.token }}
|
||||||
|
required: false
|
||||||
|
cache-disabled:
|
||||||
|
required: false
|
||||||
|
default: true
|
||||||
|
|
||||||
# DEPRECATED ACTION INPUTS
|
# DEPRECATED ACTION INPUTS
|
||||||
build-scan-terms-of-service-url:
|
build-scan-terms-of-service-url:
|
||||||
description: The URL to the Build Scan® terms of use. This input must be set to 'https://gradle.com/terms-of-service'.
|
description: The URL to the Build Scan® terms of use. This input must be set to 'https://gradle.com/terms-of-service'.
|
||||||
@ -67,15 +81,6 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
deprecation-message: The input has been renamed to align with the Develocity API. Use 'build-scan-terms-of-use-agree' instead.
|
deprecation-message: The input has been renamed to align with the Develocity API. Use 'build-scan-terms-of-use-agree' instead.
|
||||||
|
|
||||||
# INTERNAL ACTION INPUTS
|
|
||||||
# These inputs should not be configured directly, and are only used to pass environmental information to the action
|
|
||||||
workflow-job-context:
|
|
||||||
required: false
|
|
||||||
default: ${{ toJSON(matrix) }}
|
|
||||||
github-token:
|
|
||||||
default: ${{ github.token }}
|
|
||||||
required: false
|
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node20'
|
||||||
main: '../dist/dependency-submission/main/index.js'
|
main: '../dist/dependency-submission/main/index.js'
|
||||||
|
@ -16,19 +16,20 @@ import {DependencyGraphConfig, DependencyGraphOption, getGithubToken} from './in
|
|||||||
const DEPENDENCY_GRAPH_PREFIX = 'dependency-graph_'
|
const DEPENDENCY_GRAPH_PREFIX = 'dependency-graph_'
|
||||||
|
|
||||||
export async function setup(config: DependencyGraphConfig): Promise<void> {
|
export async function setup(config: DependencyGraphConfig): Promise<void> {
|
||||||
if (config.dependencyGraphOption === DependencyGraphOption.Disabled) {
|
const option = config.getDependencyGraphOption()
|
||||||
|
if (option === DependencyGraphOption.Disabled) {
|
||||||
core.exportVariable('GITHUB_DEPENDENCY_GRAPH_ENABLED', 'false')
|
core.exportVariable('GITHUB_DEPENDENCY_GRAPH_ENABLED', 'false')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Download and submit early, for compatability with dependency review.
|
// Download and submit early, for compatability with dependency review.
|
||||||
if (config.dependencyGraphOption === DependencyGraphOption.DownloadAndSubmit) {
|
if (option === DependencyGraphOption.DownloadAndSubmit) {
|
||||||
await downloadAndSubmitDependencyGraphs(config)
|
await downloadAndSubmitDependencyGraphs(config)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
core.info('Enabling dependency graph generation')
|
core.info('Enabling dependency graph generation')
|
||||||
core.exportVariable('GITHUB_DEPENDENCY_GRAPH_ENABLED', 'true')
|
core.exportVariable('GITHUB_DEPENDENCY_GRAPH_ENABLED', 'true')
|
||||||
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_CONTINUE_ON_FAILURE', config.continueOnFailure)
|
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_CONTINUE_ON_FAILURE', config.getDependencyGraphContinueOnFailure())
|
||||||
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR', config.getJobCorrelator())
|
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_JOB_CORRELATOR', config.getJobCorrelator())
|
||||||
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_JOB_ID', github.context.runId)
|
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_JOB_ID', github.context.runId)
|
||||||
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_REF', github.context.ref)
|
maybeExportVariable('GITHUB_DEPENDENCY_GRAPH_REF', github.context.ref)
|
||||||
@ -40,7 +41,7 @@ export async function setup(config: DependencyGraphConfig): Promise<void> {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// To clear the dependency graph, we generate an empty graph by excluding all projects and configurations
|
// To clear the dependency graph, we generate an empty graph by excluding all projects and configurations
|
||||||
if (config.dependencyGraphOption === DependencyGraphOption.Clear) {
|
if (option === DependencyGraphOption.Clear) {
|
||||||
core.exportVariable('DEPENDENCY_GRAPH_INCLUDE_PROJECTS', '')
|
core.exportVariable('DEPENDENCY_GRAPH_INCLUDE_PROJECTS', '')
|
||||||
core.exportVariable('DEPENDENCY_GRAPH_INCLUDE_CONFIGURATIONS', '')
|
core.exportVariable('DEPENDENCY_GRAPH_INCLUDE_CONFIGURATIONS', '')
|
||||||
}
|
}
|
||||||
@ -58,8 +59,9 @@ export async function complete(config: DependencyGraphConfig): Promise<void> {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const option = config.getDependencyGraphOption()
|
||||||
try {
|
try {
|
||||||
switch (config.dependencyGraphOption) {
|
switch (option) {
|
||||||
case DependencyGraphOption.Disabled:
|
case DependencyGraphOption.Disabled:
|
||||||
case DependencyGraphOption.Generate: // Performed via init-script: nothing to do here
|
case DependencyGraphOption.Generate: // Performed via init-script: nothing to do here
|
||||||
case DependencyGraphOption.DownloadAndSubmit: // Performed in setup
|
case DependencyGraphOption.DownloadAndSubmit: // Performed in setup
|
||||||
@ -72,7 +74,7 @@ export async function complete(config: DependencyGraphConfig): Promise<void> {
|
|||||||
await uploadDependencyGraphs(await findGeneratedDependencyGraphFiles(), config)
|
await uploadDependencyGraphs(await findGeneratedDependencyGraphFiles(), config)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
warnOrFail(config, e)
|
warnOrFail(config, option, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +92,7 @@ async function uploadDependencyGraphs(dependencyGraphFiles: string[], config: De
|
|||||||
core.info(`Uploading dependency graph file: ${relativePath}`)
|
core.info(`Uploading dependency graph file: ${relativePath}`)
|
||||||
const artifactName = `${DEPENDENCY_GRAPH_PREFIX}${path.basename(dependencyGraphFile)}`
|
const artifactName = `${DEPENDENCY_GRAPH_PREFIX}${path.basename(dependencyGraphFile)}`
|
||||||
await artifactClient.uploadArtifact(artifactName, [dependencyGraphFile], workspaceDirectory, {
|
await artifactClient.uploadArtifact(artifactName, [dependencyGraphFile], workspaceDirectory, {
|
||||||
retentionDays: config.artifactRetentionDays
|
retentionDays: config.getArtifactRetentionDays()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,7 +106,7 @@ async function downloadAndSubmitDependencyGraphs(config: DependencyGraphConfig):
|
|||||||
try {
|
try {
|
||||||
await submitDependencyGraphs(await downloadDependencyGraphs())
|
await submitDependencyGraphs(await downloadDependencyGraphs())
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
warnOrFail(config, e)
|
warnOrFail(config, DependencyGraphOption.DownloadAndSubmit, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,12 +188,12 @@ async function findDependencyGraphFiles(dir: string): Promise<string[]> {
|
|||||||
return graphFiles
|
return graphFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
function warnOrFail(config: DependencyGraphConfig, error: unknown): void {
|
function warnOrFail(config: DependencyGraphConfig, option: String, error: unknown): void {
|
||||||
if (!config.continueOnFailure) {
|
if (!config.getDependencyGraphContinueOnFailure()) {
|
||||||
throw new PostActionJobFailure(error)
|
throw new PostActionJobFailure(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
core.warning(`Failed to ${config.dependencyGraphOption} dependency graph. Will continue.\n${String(error)}`)
|
core.warning(`Failed to ${option} dependency graph. Will continue.\n${String(error)}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOctokit(): InstanceType<typeof GitHub> {
|
function getOctokit(): InstanceType<typeof GitHub> {
|
||||||
|
@ -19,12 +19,9 @@ export async function run(): Promise<void> {
|
|||||||
|
|
||||||
// Configure the dependency graph submission
|
// Configure the dependency graph submission
|
||||||
const config = new DependencyGraphConfig()
|
const config = new DependencyGraphConfig()
|
||||||
config.artifactRetentionDays = 1
|
|
||||||
config.continueOnFailure = false
|
|
||||||
|
|
||||||
await dependencyGraph.setup(config)
|
await dependencyGraph.setup(config)
|
||||||
|
|
||||||
if (config.dependencyGraphOption === DependencyGraphOption.DownloadAndSubmit) {
|
if (config.getDependencyGraphOption() === DependencyGraphOption.DownloadAndSubmit) {
|
||||||
// No execution to perform
|
// No execution to perform
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -43,6 +40,7 @@ export async function run(): Promise<void> {
|
|||||||
`
|
`
|
||||||
|
|
||||||
const args: string[] = parseArgsStringToArgv(executionArgs)
|
const args: string[] = parseArgsStringToArgv(executionArgs)
|
||||||
|
core.info(args.join('!!!'))
|
||||||
const buildRootDirectory = layout.buildRootDirectory()
|
const buildRootDirectory = layout.buildRootDirectory()
|
||||||
await execution.executeGradleBuild(executable, buildRootDirectory, args)
|
await execution.executeGradleBuild(executable, buildRootDirectory, args)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -6,11 +6,7 @@ import {SUMMARY_ENV_VAR} from '@actions/core/lib/summary'
|
|||||||
import {parseArgsStringToArgv} from 'string-argv'
|
import {parseArgsStringToArgv} from 'string-argv'
|
||||||
|
|
||||||
export class DependencyGraphConfig {
|
export class DependencyGraphConfig {
|
||||||
dependencyGraphOption = this.getDependencyGraphOption()
|
getDependencyGraphOption(): DependencyGraphOption {
|
||||||
continueOnFailure = this.getDependencyGraphContinueOnFailure()
|
|
||||||
artifactRetentionDays = this.getArtifactRetentionDays()
|
|
||||||
|
|
||||||
private getDependencyGraphOption(): DependencyGraphOption {
|
|
||||||
const val = core.getInput('dependency-graph')
|
const val = core.getInput('dependency-graph')
|
||||||
switch (val.toLowerCase().trim()) {
|
switch (val.toLowerCase().trim()) {
|
||||||
case 'disabled':
|
case 'disabled':
|
||||||
@ -31,11 +27,11 @@ export class DependencyGraphConfig {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDependencyGraphContinueOnFailure(): boolean {
|
getDependencyGraphContinueOnFailure(): boolean {
|
||||||
return getBooleanInput('dependency-graph-continue-on-failure', true)
|
return getBooleanInput('dependency-graph-continue-on-failure', true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private getArtifactRetentionDays(): number {
|
getArtifactRetentionDays(): number {
|
||||||
const val = core.getInput('artifact-retention-days')
|
const val = core.getInput('artifact-retention-days')
|
||||||
return parseNumericInput('artifact-retention-days', val, 0)
|
return parseNumericInput('artifact-retention-days', val, 0)
|
||||||
// Zero indicates that the default repository settings should be used
|
// Zero indicates that the default repository settings should be used
|
||||||
|
Loading…
x
Reference in New Issue
Block a user