mirror of
https://github.com/gradle/actions
synced 2024-11-27 11:52:24 +00:00
Allow a task name to be specified for dependency-submission (#135)
Fixes #125
This commit is contained in:
commit
2e02e6624e
17 changed files with 226 additions and 135 deletions
|
@ -112,7 +112,7 @@ jobs:
|
|||
uses: ./dependency-submission
|
||||
with:
|
||||
build-root-directory: .github/workflow-samples/groovy-dsl
|
||||
additional-arguments: --no-build-cache
|
||||
dependency-resolution-task: assemble
|
||||
- name: Check generated dependency graphs
|
||||
shell: bash
|
||||
run: |
|
||||
|
|
|
@ -2,6 +2,7 @@ name: Gradle Dependency Submission
|
|||
description: Generates a dependency graph for a Gradle project and submits it via the Dependency Submission API
|
||||
|
||||
inputs:
|
||||
# Gradle execution configuration
|
||||
gradle-version:
|
||||
description: |
|
||||
Gradle version to use. If specified, this Gradle version will be downloaded, added to the PATH and used for invoking Gradle.
|
||||
|
@ -12,6 +13,12 @@ inputs:
|
|||
description: Path to the root directory of the build. Default is the root of the GitHub workspace.
|
||||
required: false
|
||||
|
||||
dependency-resolution-task:
|
||||
description: |
|
||||
Task(s) that should be executed in order to resolve all project dependencies.
|
||||
By default, the built-in `:ForceDependencyResolutionPlugin_resolveAllDependencies` task is executed.
|
||||
required: false
|
||||
|
||||
additional-arguments:
|
||||
description: |
|
||||
Additional arguments to pass to Gradle when generating the dependency graph.
|
||||
|
|
70
dist/dependency-submission/main/index.js
vendored
70
dist/dependency-submission/main/index.js
vendored
|
@ -141501,16 +141501,18 @@ function run() {
|
|||
if (config.getDependencyGraphOption() === input_params_1.DependencyGraphOption.DownloadAndSubmit) {
|
||||
return;
|
||||
}
|
||||
const additionalArgs = core.getInput('additional-arguments');
|
||||
const executionConfig = new input_params_1.GradleExecutionConfig();
|
||||
const taskList = executionConfig.getDependencyResolutionTask();
|
||||
const additionalArgs = executionConfig.getAdditionalArguments();
|
||||
const executionArgs = `
|
||||
-Dorg.gradle.configureondemand=false
|
||||
-Dorg.gradle.dependency.verification=off
|
||||
-Dorg.gradle.unsafe.isolated-projects=false
|
||||
:ForceDependencyResolutionPlugin_resolveAllDependencies
|
||||
${taskList}
|
||||
${additionalArgs}
|
||||
`;
|
||||
const args = (0, string_argv_1.parseArgsStringToArgv)(executionArgs);
|
||||
yield gradle.provisionAndMaybeExecute(args);
|
||||
yield gradle.provisionAndMaybeExecute(executionConfig.getGradleVersion(), executionConfig.getBuildRootDirectory(), args);
|
||||
yield dependencyGraph.complete(config);
|
||||
}
|
||||
catch (error) {
|
||||
|
@ -141593,16 +141595,13 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|||
exports.provisionAndMaybeExecute = void 0;
|
||||
const core = __importStar(__nccwpck_require__(42186));
|
||||
const exec = __importStar(__nccwpck_require__(71514));
|
||||
const path = __importStar(__nccwpck_require__(71017));
|
||||
const params = __importStar(__nccwpck_require__(23885));
|
||||
const provisioner = __importStar(__nccwpck_require__(14042));
|
||||
const gradlew = __importStar(__nccwpck_require__(46807));
|
||||
const input_params_1 = __nccwpck_require__(23885);
|
||||
function provisionAndMaybeExecute(args) {
|
||||
function provisionAndMaybeExecute(gradleVersion, buildRootDirectory, args) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const executable = yield provisioner.provisionGradle();
|
||||
const executable = yield provisioner.provisionGradle(gradleVersion);
|
||||
if (args.length > 0) {
|
||||
yield executeGradleBuild(executable, buildRootDirectory(), args);
|
||||
yield executeGradleBuild(executable, buildRootDirectory, args);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -141619,14 +141618,6 @@ function executeGradleBuild(executable, root, args) {
|
|||
}
|
||||
});
|
||||
}
|
||||
function buildRootDirectory() {
|
||||
const baseDirectory = (0, input_params_1.getWorkspaceDirectory)();
|
||||
const buildRootDirectoryInput = params.getBuildRootDirectory();
|
||||
const resolvedBuildRootDirectory = buildRootDirectoryInput === ''
|
||||
? path.resolve(baseDirectory)
|
||||
: path.resolve(baseDirectory, buildRootDirectoryInput);
|
||||
return resolvedBuildRootDirectory;
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
@ -141753,13 +141744,11 @@ const core = __importStar(__nccwpck_require__(42186));
|
|||
const cache = __importStar(__nccwpck_require__(27799));
|
||||
const toolCache = __importStar(__nccwpck_require__(27784));
|
||||
const gradlew = __importStar(__nccwpck_require__(46807));
|
||||
const params = __importStar(__nccwpck_require__(23885));
|
||||
const cache_utils_1 = __nccwpck_require__(11044);
|
||||
const input_params_1 = __nccwpck_require__(23885);
|
||||
const gradleVersionsBaseUrl = 'https://services.gradle.org/versions';
|
||||
function provisionGradle() {
|
||||
function provisionGradle(gradleVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const gradleVersion = params.getGradleVersion();
|
||||
if (gradleVersion !== '' && gradleVersion !== 'wrapper') {
|
||||
return addToPath(yield installGradle(gradleVersion));
|
||||
}
|
||||
|
@ -141960,13 +141949,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.parseNumericInput = exports.getWorkspaceDirectory = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getBuildRootDirectory = exports.getGradleVersion = exports.BuildScanConfig = exports.JobSummaryOption = exports.SummaryConfig = exports.CacheConfig = exports.DependencyGraphOption = exports.DependencyGraphConfig = void 0;
|
||||
exports.parseNumericInput = exports.getWorkspaceDirectory = exports.getGithubToken = exports.getJobMatrix = exports.GradleExecutionConfig = exports.BuildScanConfig = exports.JobSummaryOption = exports.SummaryConfig = exports.CacheConfig = exports.DependencyGraphOption = exports.DependencyGraphConfig = void 0;
|
||||
const core = __importStar(__nccwpck_require__(42186));
|
||||
const github = __importStar(__nccwpck_require__(95438));
|
||||
const cache = __importStar(__nccwpck_require__(27799));
|
||||
const summary_1 = __nccwpck_require__(81327);
|
||||
const string_argv_1 = __nccwpck_require__(19663);
|
||||
const path_1 = __importDefault(__nccwpck_require__(71017));
|
||||
class DependencyGraphConfig {
|
||||
getDependencyGraphOption() {
|
||||
const val = core.getInput('dependency-graph');
|
||||
|
@ -142139,19 +142132,30 @@ class BuildScanConfig {
|
|||
}
|
||||
}
|
||||
exports.BuildScanConfig = BuildScanConfig;
|
||||
function getGradleVersion() {
|
||||
return core.getInput('gradle-version');
|
||||
class GradleExecutionConfig {
|
||||
getGradleVersion() {
|
||||
return core.getInput('gradle-version');
|
||||
}
|
||||
getBuildRootDirectory() {
|
||||
const baseDirectory = getWorkspaceDirectory();
|
||||
const buildRootDirectoryInput = core.getInput('build-root-directory');
|
||||
const resolvedBuildRootDirectory = buildRootDirectoryInput === ''
|
||||
? path_1.default.resolve(baseDirectory)
|
||||
: path_1.default.resolve(baseDirectory, buildRootDirectoryInput);
|
||||
return resolvedBuildRootDirectory;
|
||||
}
|
||||
getArguments() {
|
||||
const input = core.getInput('arguments');
|
||||
return (0, string_argv_1.parseArgsStringToArgv)(input);
|
||||
}
|
||||
getDependencyResolutionTask() {
|
||||
return core.getInput('dependency-resolution-task') || ':ForceDependencyResolutionPlugin_resolveAllDependencies';
|
||||
}
|
||||
getAdditionalArguments() {
|
||||
return core.getInput('additional-arguments');
|
||||
}
|
||||
}
|
||||
exports.getGradleVersion = getGradleVersion;
|
||||
function getBuildRootDirectory() {
|
||||
return core.getInput('build-root-directory');
|
||||
}
|
||||
exports.getBuildRootDirectory = getBuildRootDirectory;
|
||||
function getArguments() {
|
||||
const input = core.getInput('arguments');
|
||||
return (0, string_argv_1.parseArgsStringToArgv)(input);
|
||||
}
|
||||
exports.getArguments = getArguments;
|
||||
exports.GradleExecutionConfig = GradleExecutionConfig;
|
||||
function getJobMatrix() {
|
||||
return core.getInput('workflow-job-context');
|
||||
}
|
||||
|
|
2
dist/dependency-submission/main/index.js.map
vendored
2
dist/dependency-submission/main/index.js.map
vendored
File diff suppressed because one or more lines are too long
41
dist/dependency-submission/post/index.js
vendored
41
dist/dependency-submission/post/index.js
vendored
|
@ -92728,13 +92728,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.parseNumericInput = exports.getWorkspaceDirectory = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getBuildRootDirectory = exports.getGradleVersion = exports.BuildScanConfig = exports.JobSummaryOption = exports.SummaryConfig = exports.CacheConfig = exports.DependencyGraphOption = exports.DependencyGraphConfig = void 0;
|
||||
exports.parseNumericInput = exports.getWorkspaceDirectory = exports.getGithubToken = exports.getJobMatrix = exports.GradleExecutionConfig = exports.BuildScanConfig = exports.JobSummaryOption = exports.SummaryConfig = exports.CacheConfig = exports.DependencyGraphOption = exports.DependencyGraphConfig = void 0;
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const github = __importStar(__nccwpck_require__(5438));
|
||||
const cache = __importStar(__nccwpck_require__(7799));
|
||||
const summary_1 = __nccwpck_require__(1327);
|
||||
const string_argv_1 = __nccwpck_require__(9663);
|
||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
class DependencyGraphConfig {
|
||||
getDependencyGraphOption() {
|
||||
const val = core.getInput('dependency-graph');
|
||||
|
@ -92907,19 +92911,30 @@ class BuildScanConfig {
|
|||
}
|
||||
}
|
||||
exports.BuildScanConfig = BuildScanConfig;
|
||||
function getGradleVersion() {
|
||||
return core.getInput('gradle-version');
|
||||
class GradleExecutionConfig {
|
||||
getGradleVersion() {
|
||||
return core.getInput('gradle-version');
|
||||
}
|
||||
getBuildRootDirectory() {
|
||||
const baseDirectory = getWorkspaceDirectory();
|
||||
const buildRootDirectoryInput = core.getInput('build-root-directory');
|
||||
const resolvedBuildRootDirectory = buildRootDirectoryInput === ''
|
||||
? path_1.default.resolve(baseDirectory)
|
||||
: path_1.default.resolve(baseDirectory, buildRootDirectoryInput);
|
||||
return resolvedBuildRootDirectory;
|
||||
}
|
||||
getArguments() {
|
||||
const input = core.getInput('arguments');
|
||||
return (0, string_argv_1.parseArgsStringToArgv)(input);
|
||||
}
|
||||
getDependencyResolutionTask() {
|
||||
return core.getInput('dependency-resolution-task') || ':ForceDependencyResolutionPlugin_resolveAllDependencies';
|
||||
}
|
||||
getAdditionalArguments() {
|
||||
return core.getInput('additional-arguments');
|
||||
}
|
||||
}
|
||||
exports.getGradleVersion = getGradleVersion;
|
||||
function getBuildRootDirectory() {
|
||||
return core.getInput('build-root-directory');
|
||||
}
|
||||
exports.getBuildRootDirectory = getBuildRootDirectory;
|
||||
function getArguments() {
|
||||
const input = core.getInput('arguments');
|
||||
return (0, string_argv_1.parseArgsStringToArgv)(input);
|
||||
}
|
||||
exports.getArguments = getArguments;
|
||||
exports.GradleExecutionConfig = GradleExecutionConfig;
|
||||
function getJobMatrix() {
|
||||
return core.getInput('workflow-job-context');
|
||||
}
|
||||
|
|
2
dist/dependency-submission/post/index.js.map
vendored
2
dist/dependency-submission/post/index.js.map
vendored
File diff suppressed because one or more lines are too long
66
dist/setup-gradle/main/index.js
vendored
66
dist/setup-gradle/main/index.js
vendored
|
@ -141512,16 +141512,13 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|||
exports.provisionAndMaybeExecute = void 0;
|
||||
const core = __importStar(__nccwpck_require__(42186));
|
||||
const exec = __importStar(__nccwpck_require__(71514));
|
||||
const path = __importStar(__nccwpck_require__(71017));
|
||||
const params = __importStar(__nccwpck_require__(23885));
|
||||
const provisioner = __importStar(__nccwpck_require__(14042));
|
||||
const gradlew = __importStar(__nccwpck_require__(46807));
|
||||
const input_params_1 = __nccwpck_require__(23885);
|
||||
function provisionAndMaybeExecute(args) {
|
||||
function provisionAndMaybeExecute(gradleVersion, buildRootDirectory, args) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const executable = yield provisioner.provisionGradle();
|
||||
const executable = yield provisioner.provisionGradle(gradleVersion);
|
||||
if (args.length > 0) {
|
||||
yield executeGradleBuild(executable, buildRootDirectory(), args);
|
||||
yield executeGradleBuild(executable, buildRootDirectory, args);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -141538,14 +141535,6 @@ function executeGradleBuild(executable, root, args) {
|
|||
}
|
||||
});
|
||||
}
|
||||
function buildRootDirectory() {
|
||||
const baseDirectory = (0, input_params_1.getWorkspaceDirectory)();
|
||||
const buildRootDirectoryInput = params.getBuildRootDirectory();
|
||||
const resolvedBuildRootDirectory = buildRootDirectoryInput === ''
|
||||
? path.resolve(baseDirectory)
|
||||
: path.resolve(baseDirectory, buildRootDirectoryInput);
|
||||
return resolvedBuildRootDirectory;
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
@ -141672,13 +141661,11 @@ const core = __importStar(__nccwpck_require__(42186));
|
|||
const cache = __importStar(__nccwpck_require__(27799));
|
||||
const toolCache = __importStar(__nccwpck_require__(27784));
|
||||
const gradlew = __importStar(__nccwpck_require__(46807));
|
||||
const params = __importStar(__nccwpck_require__(23885));
|
||||
const cache_utils_1 = __nccwpck_require__(11044);
|
||||
const input_params_1 = __nccwpck_require__(23885);
|
||||
const gradleVersionsBaseUrl = 'https://services.gradle.org/versions';
|
||||
function provisionGradle() {
|
||||
function provisionGradle(gradleVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const gradleVersion = params.getGradleVersion();
|
||||
if (gradleVersion !== '' && gradleVersion !== 'wrapper') {
|
||||
return addToPath(yield installGradle(gradleVersion));
|
||||
}
|
||||
|
@ -141879,13 +141866,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.parseNumericInput = exports.getWorkspaceDirectory = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getBuildRootDirectory = exports.getGradleVersion = exports.BuildScanConfig = exports.JobSummaryOption = exports.SummaryConfig = exports.CacheConfig = exports.DependencyGraphOption = exports.DependencyGraphConfig = void 0;
|
||||
exports.parseNumericInput = exports.getWorkspaceDirectory = exports.getGithubToken = exports.getJobMatrix = exports.GradleExecutionConfig = exports.BuildScanConfig = exports.JobSummaryOption = exports.SummaryConfig = exports.CacheConfig = exports.DependencyGraphOption = exports.DependencyGraphConfig = void 0;
|
||||
const core = __importStar(__nccwpck_require__(42186));
|
||||
const github = __importStar(__nccwpck_require__(95438));
|
||||
const cache = __importStar(__nccwpck_require__(27799));
|
||||
const summary_1 = __nccwpck_require__(81327);
|
||||
const string_argv_1 = __nccwpck_require__(19663);
|
||||
const path_1 = __importDefault(__nccwpck_require__(71017));
|
||||
class DependencyGraphConfig {
|
||||
getDependencyGraphOption() {
|
||||
const val = core.getInput('dependency-graph');
|
||||
|
@ -142058,19 +142049,30 @@ class BuildScanConfig {
|
|||
}
|
||||
}
|
||||
exports.BuildScanConfig = BuildScanConfig;
|
||||
function getGradleVersion() {
|
||||
return core.getInput('gradle-version');
|
||||
class GradleExecutionConfig {
|
||||
getGradleVersion() {
|
||||
return core.getInput('gradle-version');
|
||||
}
|
||||
getBuildRootDirectory() {
|
||||
const baseDirectory = getWorkspaceDirectory();
|
||||
const buildRootDirectoryInput = core.getInput('build-root-directory');
|
||||
const resolvedBuildRootDirectory = buildRootDirectoryInput === ''
|
||||
? path_1.default.resolve(baseDirectory)
|
||||
: path_1.default.resolve(baseDirectory, buildRootDirectoryInput);
|
||||
return resolvedBuildRootDirectory;
|
||||
}
|
||||
getArguments() {
|
||||
const input = core.getInput('arguments');
|
||||
return (0, string_argv_1.parseArgsStringToArgv)(input);
|
||||
}
|
||||
getDependencyResolutionTask() {
|
||||
return core.getInput('dependency-resolution-task') || ':ForceDependencyResolutionPlugin_resolveAllDependencies';
|
||||
}
|
||||
getAdditionalArguments() {
|
||||
return core.getInput('additional-arguments');
|
||||
}
|
||||
}
|
||||
exports.getGradleVersion = getGradleVersion;
|
||||
function getBuildRootDirectory() {
|
||||
return core.getInput('build-root-directory');
|
||||
}
|
||||
exports.getBuildRootDirectory = getBuildRootDirectory;
|
||||
function getArguments() {
|
||||
const input = core.getInput('arguments');
|
||||
return (0, string_argv_1.parseArgsStringToArgv)(input);
|
||||
}
|
||||
exports.getArguments = getArguments;
|
||||
exports.GradleExecutionConfig = GradleExecutionConfig;
|
||||
function getJobMatrix() {
|
||||
return core.getInput('workflow-job-context');
|
||||
}
|
||||
|
@ -142443,8 +142445,8 @@ function run() {
|
|||
try {
|
||||
yield setupGradle.setup(new input_params_1.CacheConfig(), new input_params_1.BuildScanConfig());
|
||||
yield dependencyGraph.setup(new input_params_1.DependencyGraphConfig());
|
||||
const args = (0, input_params_1.getArguments)();
|
||||
yield gradle.provisionAndMaybeExecute(args);
|
||||
const config = new input_params_1.GradleExecutionConfig();
|
||||
yield gradle.provisionAndMaybeExecute(config.getGradleVersion(), config.getBuildRootDirectory(), config.getArguments());
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(String(error));
|
||||
|
|
2
dist/setup-gradle/main/index.js.map
vendored
2
dist/setup-gradle/main/index.js.map
vendored
File diff suppressed because one or more lines are too long
41
dist/setup-gradle/post/index.js
vendored
41
dist/setup-gradle/post/index.js
vendored
|
@ -138952,13 +138952,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.parseNumericInput = exports.getWorkspaceDirectory = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getBuildRootDirectory = exports.getGradleVersion = exports.BuildScanConfig = exports.JobSummaryOption = exports.SummaryConfig = exports.CacheConfig = exports.DependencyGraphOption = exports.DependencyGraphConfig = void 0;
|
||||
exports.parseNumericInput = exports.getWorkspaceDirectory = exports.getGithubToken = exports.getJobMatrix = exports.GradleExecutionConfig = exports.BuildScanConfig = exports.JobSummaryOption = exports.SummaryConfig = exports.CacheConfig = exports.DependencyGraphOption = exports.DependencyGraphConfig = void 0;
|
||||
const core = __importStar(__nccwpck_require__(42186));
|
||||
const github = __importStar(__nccwpck_require__(95438));
|
||||
const cache = __importStar(__nccwpck_require__(27799));
|
||||
const summary_1 = __nccwpck_require__(81327);
|
||||
const string_argv_1 = __nccwpck_require__(19663);
|
||||
const path_1 = __importDefault(__nccwpck_require__(71017));
|
||||
class DependencyGraphConfig {
|
||||
getDependencyGraphOption() {
|
||||
const val = core.getInput('dependency-graph');
|
||||
|
@ -139131,19 +139135,30 @@ class BuildScanConfig {
|
|||
}
|
||||
}
|
||||
exports.BuildScanConfig = BuildScanConfig;
|
||||
function getGradleVersion() {
|
||||
return core.getInput('gradle-version');
|
||||
class GradleExecutionConfig {
|
||||
getGradleVersion() {
|
||||
return core.getInput('gradle-version');
|
||||
}
|
||||
getBuildRootDirectory() {
|
||||
const baseDirectory = getWorkspaceDirectory();
|
||||
const buildRootDirectoryInput = core.getInput('build-root-directory');
|
||||
const resolvedBuildRootDirectory = buildRootDirectoryInput === ''
|
||||
? path_1.default.resolve(baseDirectory)
|
||||
: path_1.default.resolve(baseDirectory, buildRootDirectoryInput);
|
||||
return resolvedBuildRootDirectory;
|
||||
}
|
||||
getArguments() {
|
||||
const input = core.getInput('arguments');
|
||||
return (0, string_argv_1.parseArgsStringToArgv)(input);
|
||||
}
|
||||
getDependencyResolutionTask() {
|
||||
return core.getInput('dependency-resolution-task') || ':ForceDependencyResolutionPlugin_resolveAllDependencies';
|
||||
}
|
||||
getAdditionalArguments() {
|
||||
return core.getInput('additional-arguments');
|
||||
}
|
||||
}
|
||||
exports.getGradleVersion = getGradleVersion;
|
||||
function getBuildRootDirectory() {
|
||||
return core.getInput('build-root-directory');
|
||||
}
|
||||
exports.getBuildRootDirectory = getBuildRootDirectory;
|
||||
function getArguments() {
|
||||
const input = core.getInput('arguments');
|
||||
return (0, string_argv_1.parseArgsStringToArgv)(input);
|
||||
}
|
||||
exports.getArguments = getArguments;
|
||||
exports.GradleExecutionConfig = GradleExecutionConfig;
|
||||
function getJobMatrix() {
|
||||
return core.getInput('workflow-job-context');
|
||||
}
|
||||
|
|
2
dist/setup-gradle/post/index.js.map
vendored
2
dist/setup-gradle/post/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -43,6 +43,21 @@ jobs:
|
|||
- name: Generate and submit dependency graph
|
||||
uses: gradle/actions/dependency-submission@v3
|
||||
```
|
||||
|
||||
### Gradle execution
|
||||
|
||||
To generate a dependency graph, the `dependency-submission` action must perform a Gradle execution that resolves
|
||||
the dependencies of the project. All dependencies that are resolved in this execution will be included in the
|
||||
generated dependency graph. By default action executes a built-in task that is designed to resolve all build dependencies
|
||||
(`:ForceDependencyResolutionPlugin_resolveAllDependencies`).
|
||||
|
||||
The action looks for a Gradle project in the root of the workspace, and executes this project with
|
||||
the Gradle wrapper, if configured for the project. If the wrapper is not configured, whatever `gradle` available
|
||||
on the command-line will be used.
|
||||
|
||||
The action provides the ability to override the Gradle version and task to execute, as well as provide
|
||||
additional arguments that will be passed to Gradle on the command-line. See [Configuration Parameters](#configuration-parameters) below.
|
||||
|
||||
### Publishing a Develocity Build Scan® from your dependency submission workflow
|
||||
|
||||
You can automatically publish a free Develocity Build Scan on every run of `gradle/actions/dependency-submission`.
|
||||
|
@ -64,8 +79,6 @@ A Build Scan makes it easy to determine the source of any dependency vulnerabili
|
|||
|
||||
In some cases, the default action configuration will not be sufficient, and additional action parameters will need to be specified.
|
||||
|
||||
See the example below for a summary, and the [Action Metadata file](action.yml) for a more detailed description of each input parameter.
|
||||
|
||||
```yaml
|
||||
- name: Generate and save dependency graph
|
||||
uses: gradle/actions/dependency-submission@v3
|
||||
|
@ -76,6 +89,12 @@ See the example below for a summary, and the [Action Metadata file](action.yml)
|
|||
# The gradle project is not in the root of the repository.
|
||||
build-root-directory: my-gradle-project
|
||||
|
||||
# Choose a task that will trigger dependency resolution
|
||||
dependency-resolution-task: myDependencyResolutionTask
|
||||
|
||||
# Additional arguments that should be passed to execute Gradle
|
||||
additonal-arguments: --no-configuration-cache
|
||||
|
||||
# Enable configuration-cache reuse for this build.
|
||||
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
|
||||
|
||||
|
@ -83,6 +102,8 @@ See the example below for a summary, and the [Action Metadata file](action.yml)
|
|||
dependency-graph: generate-and-upload
|
||||
```
|
||||
|
||||
See the [Action Metadata file](../dependency-submission/action.yml) for a more detailed description of each input parameter.
|
||||
|
||||
# Resolving a dependency vulnerability
|
||||
|
||||
## Finding the source of a dependency vulnerability
|
||||
|
|
|
@ -196,6 +196,11 @@ jobs:
|
|||
- run: gradle build --configuration-cache
|
||||
```
|
||||
|
||||
> [!IMPORTANT]
|
||||
> The configuration cache cannot be saved or restored in workflows triggered by a pull requests from a repsitory fork.
|
||||
> This is because [GitHub secrets are not passed to workflows triggered by PRs from forks](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#using-secrets-in-a-workflow).
|
||||
> This prevents a malicious PR from reading the configuration-cache data, which may encode secrets read by Gradle.
|
||||
|
||||
### Incompatibility with other caching mechanisms
|
||||
|
||||
When using `setup-gradle` we recommend that you avoid using other mechanisms to save and restore the Gradle User Home.
|
||||
|
@ -532,7 +537,7 @@ You enable GitHub Dependency Graph support by setting the `dependency-graph` act
|
|||
| `generate` | Generate a dependency graph snapshot for each build invocation. |
|
||||
| `generate-and-submit` | Generate a dependency graph snapshot for each build invocation, and submit these via the Dependency Submission API on completion of the job. |
|
||||
| `generate-and-upload` | Generate a dependency graph snapshot for each build invocation, saving it as a workflow artifact. |
|
||||
| `download-and-submit` | Download any previously saved dependency graph snapshots, and submit them via the Dependency Submission API. This can be useful to submit [dependency graphs for pull requests submitted from repository forks](#dependency-graphs-for-pull-request-workflows). |
|
||||
| `download-and-submit` | Download any previously saved dependency graph snapshots, and submit them via the Dependency Submission API. This can be useful to submit [dependency graphs for pull requests submitted from repository forks](dependency-submission.md#usage-with-pull-requests-from-public-forked-repositories). |
|
||||
|
||||
Example of a CI workflow that generates and submits a dependency graph:
|
||||
```yaml
|
||||
|
@ -569,7 +574,7 @@ Depending on [repository settings](https://docs.github.com/en/actions/security-g
|
|||
> but not when a workflow is triggered by a PR from a repository fork.
|
||||
> This is because the `contents: write` permission is not available when executing a workflow
|
||||
> for a PR submitted from a forked repository.
|
||||
> For a configuration that supports this setup, see [Dependency Graphs for pull request workflows](#dependency-graphs-for-pull-request-workflows).
|
||||
> For a configuration that supports this setup, see [Dependency Graphs for pull request workflows](dependency-submission.md#usage-with-pull-requests-from-public-forked-repositories).
|
||||
|
||||
### Making dependency graph failures cause Job failures
|
||||
|
||||
|
|
|
@ -5,7 +5,13 @@ import * as gradle from '../execution/gradle'
|
|||
import * as dependencyGraph from '../dependency-graph'
|
||||
|
||||
import {parseArgsStringToArgv} from 'string-argv'
|
||||
import {BuildScanConfig, CacheConfig, DependencyGraphConfig, DependencyGraphOption} from '../input-params'
|
||||
import {
|
||||
BuildScanConfig,
|
||||
CacheConfig,
|
||||
DependencyGraphConfig,
|
||||
DependencyGraphOption,
|
||||
GradleExecutionConfig
|
||||
} from '../input-params'
|
||||
|
||||
/**
|
||||
* The main entry point for the action, called by Github Actions for the step.
|
||||
|
@ -25,16 +31,22 @@ export async function run(): Promise<void> {
|
|||
}
|
||||
|
||||
// Only execute if arguments have been provided
|
||||
const additionalArgs = core.getInput('additional-arguments')
|
||||
const executionConfig = new GradleExecutionConfig()
|
||||
const taskList = executionConfig.getDependencyResolutionTask()
|
||||
const additionalArgs = executionConfig.getAdditionalArguments()
|
||||
const executionArgs = `
|
||||
-Dorg.gradle.configureondemand=false
|
||||
-Dorg.gradle.dependency.verification=off
|
||||
-Dorg.gradle.unsafe.isolated-projects=false
|
||||
:ForceDependencyResolutionPlugin_resolveAllDependencies
|
||||
${taskList}
|
||||
${additionalArgs}
|
||||
`
|
||||
const args: string[] = parseArgsStringToArgv(executionArgs)
|
||||
await gradle.provisionAndMaybeExecute(args)
|
||||
await gradle.provisionAndMaybeExecute(
|
||||
executionConfig.getGradleVersion(),
|
||||
executionConfig.getBuildRootDirectory(),
|
||||
args
|
||||
)
|
||||
|
||||
await dependencyGraph.complete(config)
|
||||
} catch (error) {
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
import * as core from '@actions/core'
|
||||
import * as exec from '@actions/exec'
|
||||
import * as path from 'path'
|
||||
|
||||
import * as params from '../input-params'
|
||||
import * as provisioner from './provision'
|
||||
import * as gradlew from './gradlew'
|
||||
import {getWorkspaceDirectory} from '../input-params'
|
||||
|
||||
export async function provisionAndMaybeExecute(args: string[]): Promise<void> {
|
||||
export async function provisionAndMaybeExecute(
|
||||
gradleVersion: string,
|
||||
buildRootDirectory: string,
|
||||
args: string[]
|
||||
): Promise<void> {
|
||||
// Download and install Gradle if required
|
||||
const executable = await provisioner.provisionGradle()
|
||||
const executable = await provisioner.provisionGradle(gradleVersion)
|
||||
|
||||
// Only execute if arguments have been provided
|
||||
if (args.length > 0) {
|
||||
await executeGradleBuild(executable, buildRootDirectory(), args)
|
||||
await executeGradleBuild(executable, buildRootDirectory, args)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,13 +31,3 @@ async function executeGradleBuild(executable: string | undefined, root: string,
|
|||
core.setFailed(`Gradle build failed: see console output for details`)
|
||||
}
|
||||
}
|
||||
|
||||
function buildRootDirectory(): string {
|
||||
const baseDirectory = getWorkspaceDirectory()
|
||||
const buildRootDirectoryInput = params.getBuildRootDirectory()
|
||||
const resolvedBuildRootDirectory =
|
||||
buildRootDirectoryInput === ''
|
||||
? path.resolve(baseDirectory)
|
||||
: path.resolve(baseDirectory, buildRootDirectoryInput)
|
||||
return resolvedBuildRootDirectory
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import * as cache from '@actions/cache'
|
|||
import * as toolCache from '@actions/tool-cache'
|
||||
|
||||
import * as gradlew from './gradlew'
|
||||
import * as params from '../input-params'
|
||||
import {handleCacheFailure} from '../caching/cache-utils'
|
||||
import {CacheConfig} from '../input-params'
|
||||
|
||||
|
@ -17,8 +16,7 @@ const gradleVersionsBaseUrl = 'https://services.gradle.org/versions'
|
|||
* Install any configured version of Gradle, adding the executable to the PATH.
|
||||
* @return Installed Gradle executable or undefined if no version configured.
|
||||
*/
|
||||
export async function provisionGradle(): Promise<string | undefined> {
|
||||
const gradleVersion = params.getGradleVersion()
|
||||
export async function provisionGradle(gradleVersion: string): Promise<string | undefined> {
|
||||
if (gradleVersion !== '' && gradleVersion !== 'wrapper') {
|
||||
return addToPath(await installGradle(gradleVersion))
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import * as cache from '@actions/cache'
|
|||
import {SUMMARY_ENV_VAR} from '@actions/core/lib/summary'
|
||||
|
||||
import {parseArgsStringToArgv} from 'string-argv'
|
||||
import path from 'path'
|
||||
|
||||
export class DependencyGraphConfig {
|
||||
getDependencyGraphOption(): DependencyGraphOption {
|
||||
|
@ -218,17 +219,33 @@ export class BuildScanConfig {
|
|||
}
|
||||
}
|
||||
|
||||
export function getGradleVersion(): string {
|
||||
return core.getInput('gradle-version')
|
||||
}
|
||||
export class GradleExecutionConfig {
|
||||
getGradleVersion(): string {
|
||||
return core.getInput('gradle-version')
|
||||
}
|
||||
|
||||
export function getBuildRootDirectory(): string {
|
||||
return core.getInput('build-root-directory')
|
||||
}
|
||||
getBuildRootDirectory(): string {
|
||||
const baseDirectory = getWorkspaceDirectory()
|
||||
const buildRootDirectoryInput = core.getInput('build-root-directory')
|
||||
const resolvedBuildRootDirectory =
|
||||
buildRootDirectoryInput === ''
|
||||
? path.resolve(baseDirectory)
|
||||
: path.resolve(baseDirectory, buildRootDirectoryInput)
|
||||
return resolvedBuildRootDirectory
|
||||
}
|
||||
|
||||
export function getArguments(): string[] {
|
||||
const input = core.getInput('arguments')
|
||||
return parseArgsStringToArgv(input)
|
||||
getArguments(): string[] {
|
||||
const input = core.getInput('arguments')
|
||||
return parseArgsStringToArgv(input)
|
||||
}
|
||||
|
||||
getDependencyResolutionTask(): string {
|
||||
return core.getInput('dependency-resolution-task') || ':ForceDependencyResolutionPlugin_resolveAllDependencies'
|
||||
}
|
||||
|
||||
getAdditionalArguments(): string {
|
||||
return core.getInput('additional-arguments')
|
||||
}
|
||||
}
|
||||
|
||||
// Internal parameters
|
||||
|
|
|
@ -3,7 +3,7 @@ import * as core from '@actions/core'
|
|||
import * as setupGradle from '../setup-gradle'
|
||||
import * as gradle from '../execution/gradle'
|
||||
import * as dependencyGraph from '../dependency-graph'
|
||||
import {BuildScanConfig, CacheConfig, DependencyGraphConfig, getArguments} from '../input-params'
|
||||
import {BuildScanConfig, CacheConfig, DependencyGraphConfig, GradleExecutionConfig} from '../input-params'
|
||||
|
||||
/**
|
||||
* The main entry point for the action, called by Github Actions for the step.
|
||||
|
@ -16,8 +16,12 @@ export async function run(): Promise<void> {
|
|||
// Configure the dependency graph submission
|
||||
await dependencyGraph.setup(new DependencyGraphConfig())
|
||||
|
||||
const args: string[] = getArguments()
|
||||
await gradle.provisionAndMaybeExecute(args)
|
||||
const config = new GradleExecutionConfig()
|
||||
await gradle.provisionAndMaybeExecute(
|
||||
config.getGradleVersion(),
|
||||
config.getBuildRootDirectory(),
|
||||
config.getArguments()
|
||||
)
|
||||
} catch (error) {
|
||||
core.setFailed(String(error))
|
||||
if (error instanceof Error && error.stack) {
|
||||
|
|
Loading…
Reference in a new issue