mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-25 15:06:19 +08:00
Make artifact retention configurable
- Added a new `artifact-retention-days` input parameter to control retention of uploaded artifacts - Artifacts retention will use repository settings if not overridden.
This commit is contained in:
parent
f757bcfd86
commit
9bca466e27
13
action.yml
13
action.yml
@ -54,6 +54,11 @@ inputs:
|
|||||||
# gradle-home-cache-excludes: |
|
# gradle-home-cache-excludes: |
|
||||||
# caches/build-cache-1
|
# caches/build-cache-1
|
||||||
|
|
||||||
|
gradle-home-cache-cleanup:
|
||||||
|
description: When 'true', the action will attempt to remove any stale/unused entries from the Gradle User Home prior to saving to the GitHub Actions cache.
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
|
||||||
arguments:
|
arguments:
|
||||||
description: Gradle command line arguments (supports multi-line input)
|
description: Gradle command line arguments (supports multi-line input)
|
||||||
required: false
|
required: false
|
||||||
@ -68,6 +73,10 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: 'disabled'
|
default: 'disabled'
|
||||||
|
|
||||||
|
artifact-retention-days:
|
||||||
|
description: Specifies the number of days to retain any artifacts generated by the action. If not set, the default retention settings for the repository will apply.
|
||||||
|
required: false
|
||||||
|
|
||||||
# EXPERIMENTAL & INTERNAL ACTION INPUTS
|
# EXPERIMENTAL & INTERNAL ACTION INPUTS
|
||||||
# The following action properties allow fine-grained tweaking of the action caching behaviour.
|
# The following action properties allow fine-grained tweaking of the action caching behaviour.
|
||||||
# These properties are experimental and not (yet) designed for production use, and may change without notice in a subsequent release of `gradle-build-action`.
|
# These properties are experimental and not (yet) designed for production use, and may change without notice in a subsequent release of `gradle-build-action`.
|
||||||
@ -80,10 +89,6 @@ inputs:
|
|||||||
description: Used to uniquely identify the current job invocation. Defaults to the matrix values for this job; this should not be overridden by users (INTERNAL).
|
description: Used to uniquely identify the current job invocation. Defaults to the matrix values for this job; this should not be overridden by users (INTERNAL).
|
||||||
required: false
|
required: false
|
||||||
default: ${{ toJSON(matrix) }}
|
default: ${{ toJSON(matrix) }}
|
||||||
gradle-home-cache-cleanup:
|
|
||||||
description: When 'true', the action will attempt to remove any stale/unused entries from the Gradle User Home prior to saving to the GitHub Actions cache.
|
|
||||||
required: false
|
|
||||||
default: false
|
|
||||||
|
|
||||||
github-token:
|
github-token:
|
||||||
description: The GitHub token used to authenticate when submitting via the Dependency Submission API.
|
description: The GitHub token used to authenticate when submitting via the Dependency Submission API.
|
||||||
|
22
dist/main/index.js
vendored
22
dist/main/index.js
vendored
@ -93671,7 +93671,9 @@ function uploadDependencyGraphs() {
|
|||||||
const relativeGraphFiles = graphFiles.map(x => getRelativePathFromWorkspace(x));
|
const relativeGraphFiles = graphFiles.map(x => getRelativePathFromWorkspace(x));
|
||||||
core.info(`Uploading dependency graph files: ${relativeGraphFiles}`);
|
core.info(`Uploading dependency graph files: ${relativeGraphFiles}`);
|
||||||
const artifactClient = artifact.create();
|
const artifactClient = artifact.create();
|
||||||
artifactClient.uploadArtifact(DEPENDENCY_GRAPH_ARTIFACT, graphFiles, workspaceDirectory);
|
artifactClient.uploadArtifact(DEPENDENCY_GRAPH_ARTIFACT, graphFiles, workspaceDirectory, {
|
||||||
|
retentionDays: (0, input_params_1.getArtifactRetentionDays)()
|
||||||
|
});
|
||||||
return graphFiles;
|
return graphFiles;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -93979,7 +93981,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.DependencyGraphOption = exports.getDependencyGraphOption = exports.isDependencyGraphEnabled = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleExecutable = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
|
exports.DependencyGraphOption = exports.parseNumericInput = exports.getArtifactRetentionDays = exports.getDependencyGraphOption = exports.isDependencyGraphEnabled = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleExecutable = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const string_argv_1 = __nccwpck_require__(9663);
|
const string_argv_1 = __nccwpck_require__(9663);
|
||||||
function isCacheDisabled() {
|
function isCacheDisabled() {
|
||||||
@ -94066,6 +94068,22 @@ function getDependencyGraphOption() {
|
|||||||
throw TypeError(`The value '${val} is not valid for 'dependency-graph. Valid values are: [disabled, generate-and-upload, generate-and-submit, download-and-submit]. The default value is 'disabled'.`);
|
throw TypeError(`The value '${val} is not valid for 'dependency-graph. Valid values are: [disabled, generate-and-upload, generate-and-submit, download-and-submit]. The default value is 'disabled'.`);
|
||||||
}
|
}
|
||||||
exports.getDependencyGraphOption = getDependencyGraphOption;
|
exports.getDependencyGraphOption = getDependencyGraphOption;
|
||||||
|
function getArtifactRetentionDays() {
|
||||||
|
const val = core.getInput('artifact-retention-days');
|
||||||
|
return parseNumericInput('artifact-retention-days', val, 0);
|
||||||
|
}
|
||||||
|
exports.getArtifactRetentionDays = getArtifactRetentionDays;
|
||||||
|
function parseNumericInput(paramName, paramValue, paramDefault) {
|
||||||
|
if (paramValue.length === 0) {
|
||||||
|
return paramDefault;
|
||||||
|
}
|
||||||
|
const numericValue = parseInt(paramValue);
|
||||||
|
if (isNaN(numericValue)) {
|
||||||
|
throw TypeError(`The value '${paramValue}' is not a valid numeric value for '${paramName}'.`);
|
||||||
|
}
|
||||||
|
return numericValue;
|
||||||
|
}
|
||||||
|
exports.parseNumericInput = parseNumericInput;
|
||||||
function getBooleanInput(paramName, paramDefault = false) {
|
function getBooleanInput(paramName, paramDefault = false) {
|
||||||
const paramValue = core.getInput(paramName);
|
const paramValue = core.getInput(paramName);
|
||||||
switch (paramValue.toLowerCase().trim()) {
|
switch (paramValue.toLowerCase().trim()) {
|
||||||
|
2
dist/main/index.js.map
vendored
2
dist/main/index.js.map
vendored
File diff suppressed because one or more lines are too long
22
dist/post/index.js
vendored
22
dist/post/index.js
vendored
@ -93671,7 +93671,9 @@ function uploadDependencyGraphs() {
|
|||||||
const relativeGraphFiles = graphFiles.map(x => getRelativePathFromWorkspace(x));
|
const relativeGraphFiles = graphFiles.map(x => getRelativePathFromWorkspace(x));
|
||||||
core.info(`Uploading dependency graph files: ${relativeGraphFiles}`);
|
core.info(`Uploading dependency graph files: ${relativeGraphFiles}`);
|
||||||
const artifactClient = artifact.create();
|
const artifactClient = artifact.create();
|
||||||
artifactClient.uploadArtifact(DEPENDENCY_GRAPH_ARTIFACT, graphFiles, workspaceDirectory);
|
artifactClient.uploadArtifact(DEPENDENCY_GRAPH_ARTIFACT, graphFiles, workspaceDirectory, {
|
||||||
|
retentionDays: (0, input_params_1.getArtifactRetentionDays)()
|
||||||
|
});
|
||||||
return graphFiles;
|
return graphFiles;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -93847,7 +93849,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.DependencyGraphOption = exports.getDependencyGraphOption = exports.isDependencyGraphEnabled = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleExecutable = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
|
exports.DependencyGraphOption = exports.parseNumericInput = exports.getArtifactRetentionDays = exports.getDependencyGraphOption = exports.isDependencyGraphEnabled = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleExecutable = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const string_argv_1 = __nccwpck_require__(9663);
|
const string_argv_1 = __nccwpck_require__(9663);
|
||||||
function isCacheDisabled() {
|
function isCacheDisabled() {
|
||||||
@ -93934,6 +93936,22 @@ function getDependencyGraphOption() {
|
|||||||
throw TypeError(`The value '${val} is not valid for 'dependency-graph. Valid values are: [disabled, generate-and-upload, generate-and-submit, download-and-submit]. The default value is 'disabled'.`);
|
throw TypeError(`The value '${val} is not valid for 'dependency-graph. Valid values are: [disabled, generate-and-upload, generate-and-submit, download-and-submit]. The default value is 'disabled'.`);
|
||||||
}
|
}
|
||||||
exports.getDependencyGraphOption = getDependencyGraphOption;
|
exports.getDependencyGraphOption = getDependencyGraphOption;
|
||||||
|
function getArtifactRetentionDays() {
|
||||||
|
const val = core.getInput('artifact-retention-days');
|
||||||
|
return parseNumericInput('artifact-retention-days', val, 0);
|
||||||
|
}
|
||||||
|
exports.getArtifactRetentionDays = getArtifactRetentionDays;
|
||||||
|
function parseNumericInput(paramName, paramValue, paramDefault) {
|
||||||
|
if (paramValue.length === 0) {
|
||||||
|
return paramDefault;
|
||||||
|
}
|
||||||
|
const numericValue = parseInt(paramValue);
|
||||||
|
if (isNaN(numericValue)) {
|
||||||
|
throw TypeError(`The value '${paramValue}' is not a valid numeric value for '${paramName}'.`);
|
||||||
|
}
|
||||||
|
return numericValue;
|
||||||
|
}
|
||||||
|
exports.parseNumericInput = parseNumericInput;
|
||||||
function getBooleanInput(paramName, paramDefault = false) {
|
function getBooleanInput(paramName, paramDefault = false) {
|
||||||
const paramValue = core.getInput(paramName);
|
const paramValue = core.getInput(paramName);
|
||||||
switch (paramValue.toLowerCase().trim()) {
|
switch (paramValue.toLowerCase().trim()) {
|
||||||
|
2
dist/post/index.js.map
vendored
2
dist/post/index.js.map
vendored
File diff suppressed because one or more lines are too long
@ -11,7 +11,7 @@ import * as path from 'path'
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
|
|
||||||
import * as layout from './repository-layout'
|
import * as layout from './repository-layout'
|
||||||
import {DependencyGraphOption, getJobMatrix} from './input-params'
|
import {DependencyGraphOption, getJobMatrix, getArtifactRetentionDays} from './input-params'
|
||||||
|
|
||||||
const DEPENDENCY_GRAPH_ARTIFACT = 'dependency-graph'
|
const DEPENDENCY_GRAPH_ARTIFACT = 'dependency-graph'
|
||||||
|
|
||||||
@ -60,7 +60,9 @@ async function uploadDependencyGraphs(): Promise<string[]> {
|
|||||||
core.info(`Uploading dependency graph files: ${relativeGraphFiles}`)
|
core.info(`Uploading dependency graph files: ${relativeGraphFiles}`)
|
||||||
|
|
||||||
const artifactClient = artifact.create()
|
const artifactClient = artifact.create()
|
||||||
artifactClient.uploadArtifact(DEPENDENCY_GRAPH_ARTIFACT, graphFiles, workspaceDirectory)
|
artifactClient.uploadArtifact(DEPENDENCY_GRAPH_ARTIFACT, graphFiles, workspaceDirectory, {
|
||||||
|
retentionDays: getArtifactRetentionDays()
|
||||||
|
})
|
||||||
|
|
||||||
return graphFiles
|
return graphFiles
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,23 @@ export function getDependencyGraphOption(): DependencyGraphOption {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getArtifactRetentionDays(): number {
|
||||||
|
const val = core.getInput('artifact-retention-days')
|
||||||
|
return parseNumericInput('artifact-retention-days', val, 0)
|
||||||
|
// Zero indicates that the default repository settings should be used
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parseNumericInput(paramName: string, paramValue: string, paramDefault: number): number {
|
||||||
|
if (paramValue.length === 0) {
|
||||||
|
return paramDefault
|
||||||
|
}
|
||||||
|
const numericValue = parseInt(paramValue)
|
||||||
|
if (isNaN(numericValue)) {
|
||||||
|
throw TypeError(`The value '${paramValue}' is not a valid numeric value for '${paramName}'.`)
|
||||||
|
}
|
||||||
|
return numericValue
|
||||||
|
}
|
||||||
|
|
||||||
function getBooleanInput(paramName: string, paramDefault = false): boolean {
|
function getBooleanInput(paramName: string, paramDefault = false): boolean {
|
||||||
const paramValue = core.getInput(paramName)
|
const paramValue = core.getInput(paramName)
|
||||||
switch (paramValue.toLowerCase().trim()) {
|
switch (paramValue.toLowerCase().trim()) {
|
||||||
|
22
test/jest/input-params.test.ts
Normal file
22
test/jest/input-params.test.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import * as inputParams from '../../src/input-params'
|
||||||
|
|
||||||
|
describe('input params', () => {
|
||||||
|
describe('parses numeric input', () => {
|
||||||
|
it('uses default value', () => {
|
||||||
|
const val = inputParams.parseNumericInput('param-name', '', 88)
|
||||||
|
expect(val).toBe(88)
|
||||||
|
})
|
||||||
|
it('parses numeric input', () => {
|
||||||
|
const val = inputParams.parseNumericInput('param-name', '34', 88)
|
||||||
|
expect(val).toBe(34)
|
||||||
|
})
|
||||||
|
it('fails on non-numeric input', () => {
|
||||||
|
const t = () => {
|
||||||
|
inputParams.parseNumericInput('param-name', 'xyz', 88)
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(t).toThrow(TypeError)
|
||||||
|
expect(t).toThrow("The value 'xyz' is not a valid numeric value for 'param-name'.")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
Loading…
x
Reference in New Issue
Block a user