Compare commits

..

27 Commits

Author SHA1 Message Date
daz
8e02c8272a Build outputs 2023-06-28 12:24:28 -06:00
daz
f63cb02cfc Bump development dependencies 2023-06-28 11:51:09 -06:00
daz
198484d871 Bump java dependencies in samples/tests 2023-06-28 11:48:23 -06:00
Daz DeBoer
fce96e0d6a Merge pull request #740 from gradle/dd/dependency-graph-actions
Initial support for GitHub Dependency Submission
2023-06-28 19:38:14 +02:00
daz
75a86cfe02 Build outputs 2023-06-28 11:24:58 -06:00
daz
be413309fa First cut at actions for dependency-graph
- Dependency graph init-script references published version of plugin jar.
- `dependency-graph-generate` action will:
     - Provision Gradle if required
     - Execute Gradle with dependency-graph plugin to generate graph JSON
     - Upload dependency-graph JSON file as workflow artifact
- `dependency-graph-submit` action will:
    - Download dependency-graph JSON artifact
    - Submit the graph via the GitHub dependency submission API
2023-06-28 11:24:57 -06:00
Daz DeBoer
1b2daf5833 Merge pull request #734 from gradle/dd/input-params
Refactor in preparation for dependency-graph support
2023-06-06 18:52:31 +02:00
daz
4388b1f9e5 Build outputs 2023-06-06 10:51:48 -06:00
daz
07023d3e3e Refactor input parameters
Moved reading of all input parameters into a common source: `input-params.ts`.
This centralized all input parameter reads, and allowed an improved implementation
of reading boolean parameters. In particular, the implementation now provides a default
value for a boolean input parameter that isn't declared for an action.
2023-06-06 10:47:56 -06:00
daz
c94d573317 Refactor action execution for reuse
Introducing new actions for the GitHub dependency graph will involve reuse of much of
the action infrastructure. This commit reorganises things a little to facilitate reuse.
2023-06-03 14:09:52 -06:00
daz
680037c65b Bump Gradle Enterprise plugin version 2023-05-29 13:17:01 -06:00
daz
2bf6bc3646 Include workflow name in cache key
Fixes #699 by avoiding cache key collisions between jobs with the
same name in different workflows.
2023-05-23 14:59:12 -06:00
Daz DeBoer
631021bf98 Document the generate-job-summary options
Fixes #646
2023-05-23 14:56:51 -06:00
Daz DeBoer
d1c4012c0d Merge pull request #719 from gradle/dd/dependency-updates
Update development dependencies
2023-05-23 22:25:34 +02:00
daz
c097126a28 Bump NPM development dependencies 2023-05-23 14:15:08 -06:00
daz
b4a540a61f Bump com.fasterxml.jackson.dataformat:jackson-dataformat-smile from 2.15.0 to 2.15.1 2023-05-23 14:13:17 -06:00
daz
c9a87440e3 Bump org.gradle.enterprise plugin to 3.13.2 2023-05-23 14:11:15 -06:00
daz
d23c38fad3 Remove incorrect comment 2023-05-04 08:25:28 -06:00
daz
a810b86311 Update dependencies
- Bump string-argv from 0.3.1 to 0.3.2
- Bump patch-package from 6.5.1 to 7.0.0
- Bump @typescript-eslint/parser from 5.59.1 to 5.59.2
2023-05-02 14:58:36 -06:00
Daz DeBoer
7e48093f71 Attempt to resolve security alert
Testing if explicitly using `v2.4.2` will cause the alert to be resolved.
2023-05-01 13:36:49 -06:00
Daz DeBoer
12681a2972 Merge pull request #695 from gradle/dd/issue-626
Handle GE plugin applied in settingsEvaluated
2023-04-29 09:07:12 -06:00
dependabot[bot]
a8aa75965b Bump org.junit.jupiter:junit-jupiter (#693)
Bumps [org.junit.jupiter:junit-jupiter](https://github.com/junit-team/junit5) from 5.9.2 to 5.9.3.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.9.2...r5.9.3)

---
updated-dependencies:
- dependency-name: org.junit.jupiter:junit-jupiter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-29 09:05:25 -06:00
daz
a580d9bd57 Detect GE plugin applied in settingsEvaluated
The `PluginManager.hasPlugin` method was not detecting the GE plugin when it
was applied during settingsEvaluated.
Switching to `PluginManager.withPlugin` fixes this.

Fixes #626
2023-04-26 10:49:32 -06:00
daz
a13870c94e Test for GE plugin applied in settingsEvaluated 2023-04-26 10:49:31 -06:00
daz
55d241b8a2 Update development dependencies 2023-04-25 11:26:43 -06:00
Daz DeBoer
9cf99034d2 Update to latest Gradle and GE plugin
* Update workflow samples to Gradle 8.1.1
* Update tests to use Gradle 8.1.1
*Update workflow samples to GE plugin 3.13
2023-04-22 12:56:45 -06:00
dependabot[bot]
6778644d75 Bump @typescript-eslint/parser from 5.58.0 to 5.59.0 (#676)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.58.0 to 5.59.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.59.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-18 18:39:59 -06:00
60 changed files with 99307 additions and 768 deletions

View File

@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionSha256Sum=ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 distributionSha256Sum=e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000 networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done done
fi fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command; # Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in # shell script including quotes and variable substitutions, so put them in

View File

@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionSha256Sum=ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 distributionSha256Sum=e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000 networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done done
fi fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command; # Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in # shell script including quotes and variable substitutions, so put them in

View File

@@ -1,6 +1,6 @@
plugins { plugins {
id "com.gradle.enterprise" version "3.12.6" id "com.gradle.enterprise" version "3.13.4"
id "com.gradle.common-custom-user-data-gradle-plugin" version "1.10" id "com.gradle.common-custom-user-data-gradle-plugin" version "1.11"
} }
gradleEnterprise { gradleEnterprise {

View File

@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionSha256Sum=ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 distributionSha256Sum=e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000 networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done done
fi fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command; # Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in # shell script including quotes and variable substitutions, so put them in

View File

@@ -8,9 +8,9 @@ repositories {
dependencies { dependencies {
api("org.apache.commons:commons-math3:3.6.1") api("org.apache.commons:commons-math3:3.6.1")
implementation("com.google.guava:guava:31.1-jre") implementation("com.google.guava:guava:32.0.1-jre")
testImplementation("org.junit.jupiter:junit-jupiter:5.9.2") testImplementation("org.junit.jupiter:junit-jupiter:5.9.3")
} }
tasks.test { tasks.test {

View File

@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionSha256Sum=ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 distributionSha256Sum=e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000 networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done done
fi fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command; # Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in # shell script including quotes and variable substitutions, so put them in

View File

@@ -1,6 +1,6 @@
plugins { plugins {
id("com.gradle.enterprise") version "3.12.6" id("com.gradle.enterprise") version "3.13.4"
id("com.gradle.common-custom-user-data-gradle-plugin") version "1.10" id("com.gradle.common-custom-user-data-gradle-plugin") version "1.11"
} }
gradleEnterprise { gradleEnterprise {

View File

@@ -1,5 +1,5 @@
plugins { plugins {
id "com.gradle.build-scan" version "3.12.6" id "com.gradle.build-scan" version "3.13.4"
} }
gradleEnterprise { gradleEnterprise {

View File

@@ -1,5 +1,5 @@
plugins { plugins {
id "com.gradle.enterprise" version "3.12.6" id "com.gradle.enterprise" version "3.13.4"
} }
gradleEnterprise { gradleEnterprise {

View File

@@ -20,7 +20,7 @@ jobs:
distribution: temurin distribution: temurin
java-version: 8 java-version: 8
- name: Setup Gradle - name: Setup Gradle
uses: gradle/gradle-build-action@v2 # Use a released version to avoid breakages uses: gradle/gradle-build-action@v2.4.2 # Use a released version to avoid breakages
- name: Run integration tests - name: Run integration tests
working-directory: test/init-scripts working-directory: test/init-scripts
run: ./gradlew check run: ./gradlew check

View File

@@ -22,7 +22,7 @@ jobs:
- name: Configure Gradle as default for unit test - name: Configure Gradle as default for unit test
uses: ./ uses: ./
with: with:
gradle-version: 7.6.1 gradle-version: 8.1.1
- name: Run tests - name: Run tests
run: | run: |
npm install npm install

View File

@@ -1,3 +1,3 @@
# Configuration file for asdf version manager # Configuration file for asdf version manager
nodejs 16.18.1 nodejs 16.18.1
gradle 7.6.1 gradle 8.1.1

View File

@@ -321,37 +321,28 @@ Gradle Home cache cleanup is disabled by default. You can enable this feature f
gradle-home-cache-cleanup: true gradle-home-cache-cleanup: true
``` ```
## Saving build outputs ## Build reporting
By default, a GitHub Actions workflow using `gradle-build-action` will record the log output and any Build Scan links for your build, The `gradle-build-action` collects information about any Gradle executions that occur in a workflow, and reports these via
but any output files generated by the build will not be saved. a Job Summary, visible in the GitHub Actions UI. For each Gradle execution, details about the invocation are listed, together with
a link to any Build Scan® published.
To save selected files from your build execution, you can use the core [Upload-Artifact](https://github.com/actions/upload-artifact) action.
For example:
Generation of a Job Summary is enabled by default. If this is not desired, it can be disable as follows:
```yaml ```yaml
jobs: generate-job-summary: false
gradle:
runs-on: ubuntu-latest
steps:
- name: Checkout project sources
uses: actions/checkout@v3
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Run build with Gradle wrapper
run: ./gradlew build --scan
- name: Upload build reports
uses: actions/upload-artifact@v3
with:
name: build-reports
path: build/reports/
``` ```
## Build scans Note that the action collects information about Gradle invocations via an [Initialization Script](https://docs.gradle.org/current/userguide/init_scripts.html#sec:using_an_init_script)
located at `USER_HOME/.gradle/init.d/build-result-capture.init.gradle`.
If you are using init scripts for the [Gradle Enterprise Gradle Plugin](https://plugins.gradle.org/plugin/com.gradle.enterprise) like
[`scans-init.gradle` or `gradle-enterprise-init.gradle`](https://docs.gradle.com/enterprise/gradle-plugin/#scans_gradle_com),
you'll need to ensure these files are applied prior to `build-result-capture.init.gradle`.
Since Gradle applies init scripts in alphabetical order, one way to ensure this is via file naming.
If your build publishes a [build scan](https://gradle.com/build-scans/) the `gradle-build-action` action will: ### Build scan link as Step output
- Add a notice with the link to the GitHub Actions user interface
- For each step that executes Gradle, adds the link to the published build scan as a Step output named `build-scan-url`. As well as reporting the [Build Scan](https://gradle.com/build-scans/) link in the Job Summary,
the `gradle-build-action` action makes this link available as a Step output named `build-scan-url`.
You can then use that link in subsequent actions of your workflow. For example: You can then use that link in subsequent actions of your workflow. For example:
@@ -384,12 +375,31 @@ jobs:
}) })
``` ```
Note that the build scan capturing utilizes the [Initialization Script](https://docs.gradle.org/current/userguide/init_scripts.html#sec:using_an_init_script) ### Saving build outputs
in the `USER_HOME/.gradle/init.d/` directory, with the file named `build-result-capture.init.gradle`.
So, if you are using the init scripts for the [Gradle Enterprise Gradle Plugin](https://plugins.gradle.org/plugin/com.gradle.enterprise) like By default, a GitHub Actions workflow using `gradle-build-action` will record the log output and any Build Scan links for your build,
[`scans-init.gradle` or `gradle-enterprise-init.gradle`](https://docs.gradle.com/enterprise/gradle-plugin/#scans_gradle_com), but any output files generated by the build will not be saved.
make sure that its file names have earlier alphabetical order to the `build-result-capture.init.gradle`,
since configuring capture requires Gradle Enterprise Gradle Plugin to be applied already. To save selected files from your build execution, you can use the core [Upload-Artifact](https://github.com/actions/upload-artifact) action.
For example:
```yaml
jobs:
gradle:
runs-on: ubuntu-latest
steps:
- name: Checkout project sources
uses: actions/checkout@v3
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Run build with Gradle wrapper
run: ./gradlew build --scan
- name: Upload build reports
uses: actions/upload-artifact@v3
with:
name: build-reports
path: build/reports/
```
## Support for GitHub Enterprise Server (GHES) ## Support for GitHub Enterprise Server (GHES)

View File

@@ -5,7 +5,15 @@ description: 'Configures Gradle for use in GitHub actions, caching useful state
inputs: inputs:
gradle-version: gradle-version:
description: Gradle version to use description: Gradle version to use. If specified, this Gradle version will be downloaded, added to the PATH and used for invoking Gradle.
required: false
gradle-executable:
description: Path to the Gradle executable. If specified, this executable will be added to the PATH and used for invoking Gradle.
required: false
build-root-directory:
description: Path to the root directory of the build. Default is the root of the GitHub workspace.
required: false required: false
cache-disabled: cache-disabled:
@@ -45,14 +53,6 @@ inputs:
description: Gradle command line arguments (supports multi-line input) description: Gradle command line arguments (supports multi-line input)
required: false required: false
build-root-directory:
description: Path to the root directory of the build
required: false
gradle-executable:
description: Path to the Gradle executable
required: false
generate-job-summary: generate-job-summary:
description: When 'false', no Job Summary will be generated for the Job. description: When 'false', no Job Summary will be generated for the Job.
required: false required: false

View File

@@ -0,0 +1,19 @@
name: "Dependency Graph Generate"
description: Calculates the complete dependency graph for the repository, saving it as a JSON artifact.
inputs:
gradle-version:
description: Gradle version to use. If specified, this Gradle version will be downloaded, added to the PATH and used for invoking Gradle.
required: false
gradle-executable:
description: Path to the Gradle executable. If specified, this executable will be added to the PATH and used for invoking Gradle.
required: false
build-root-directory:
description: Path to the root directory of the build. Default is the root of the GitHub workspace.
required: false
runs:
using: 'node16'
main: '../../dist/dependency-graph-generate/index.js'

View File

@@ -0,0 +1,12 @@
name: "Dependency Graph Submit"
description: Retrieves a previously created dependency graph JSON and submits via the GitHub Dependency Submission API.
inputs:
github-token:
description: The GitHub token used to authenticate when submitting via the Dependency Submission API.
default: ${{ github.token }}
required: false
runs:
using: 'node16'
main: '../../dist/dependency-graph-submit/index.js'

72829
dist/dependency-graph-generate/index.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

24783
dist/dependency-graph-submit/index.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

408
dist/main/index.js vendored
View File

@@ -55409,58 +55409,6 @@ function coerce (version, options) {
} }
/***/ }),
/***/ 9453:
/***/ ((__unused_webpack_module, exports) => {
"use strict";
exports.__esModule = true;
function parseArgsStringToArgv(value, env, file) {
// ([^\s'"]([^\s'"]*(['"])([^\3]*?)\3)+[^\s'"]*) Matches nested quotes until the first space outside of quotes
// [^\s'"]+ or Match if not a space ' or "
// (['"])([^\5]*?)\5 or Match "quoted text" without quotes
// `\3` and `\5` are a backreference to the quote style (' or ") captured
var myRegexp = /([^\s'"]([^\s'"]*(['"])([^\3]*?)\3)+[^\s'"]*)|[^\s'"]+|(['"])([^\5]*?)\5/gi;
var myString = value;
var myArray = [];
if (env) {
myArray.push(env);
}
if (file) {
myArray.push(file);
}
var match;
do {
// Each call to exec returns the next regex match as an array
match = myRegexp.exec(myString);
if (match !== null) {
// Index 1 in the array is the captured group if it exists
// Index 0 is the matched text, which we use if no captured group exists
myArray.push(firstString(match[1], match[6], match[0]));
}
} while (match !== null);
return myArray;
}
exports["default"] = parseArgsStringToArgv;
exports.parseArgsStringToArgv = parseArgsStringToArgv;
// Accepts any number of arguments, and returns the first one that is a string
// (even an empty string)
function firstString() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
for (var i = 0; i < args.length; i++) {
var arg = args[i];
if (typeof arg === "string") {
return arg;
}
}
}
/***/ }), /***/ }),
/***/ 4256: /***/ 4256:
@@ -63611,12 +63559,11 @@ const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514)); const exec = __importStar(__nccwpck_require__(1514));
const path_1 = __importDefault(__nccwpck_require__(1017)); const path_1 = __importDefault(__nccwpck_require__(1017));
const fs_1 = __importDefault(__nccwpck_require__(7147)); const fs_1 = __importDefault(__nccwpck_require__(7147));
const params = __importStar(__nccwpck_require__(3885));
const cache_utils_1 = __nccwpck_require__(1678); const cache_utils_1 = __nccwpck_require__(1678);
const cache_extract_entries_1 = __nccwpck_require__(6161); const cache_extract_entries_1 = __nccwpck_require__(6161);
const RESTORED_CACHE_KEY_KEY = 'restored-cache-key'; const RESTORED_CACHE_KEY_KEY = 'restored-cache-key';
exports.META_FILE_DIR = '.gradle-build-action'; exports.META_FILE_DIR = '.gradle-build-action';
const INCLUDE_PATHS_PARAMETER = 'gradle-home-cache-includes';
const EXCLUDE_PATHS_PARAMETER = 'gradle-home-cache-excludes';
class GradleStateCache { class GradleStateCache {
constructor(gradleUserHome) { constructor(gradleUserHome) {
this.gradleUserHome = gradleUserHome; this.gradleUserHome = gradleUserHome;
@@ -63708,7 +63655,7 @@ class GradleStateCache {
}); });
} }
deleteExcludedPaths() { deleteExcludedPaths() {
const rawPaths = core.getMultilineInput(EXCLUDE_PATHS_PARAMETER); const rawPaths = params.getCacheExcludes();
const resolvedPaths = rawPaths.map(x => path_1.default.resolve(this.gradleUserHome, x)); const resolvedPaths = rawPaths.map(x => path_1.default.resolve(this.gradleUserHome, x));
for (const p of resolvedPaths) { for (const p of resolvedPaths) {
(0, cache_utils_1.cacheDebug)(`Deleting excluded path: ${p}`); (0, cache_utils_1.cacheDebug)(`Deleting excluded path: ${p}`);
@@ -63716,7 +63663,7 @@ class GradleStateCache {
} }
} }
getCachePath() { getCachePath() {
const rawPaths = core.getMultilineInput(INCLUDE_PATHS_PARAMETER); const rawPaths = params.getCacheIncludes();
rawPaths.push(exports.META_FILE_DIR); rawPaths.push(exports.META_FILE_DIR);
const resolvedPaths = rawPaths.map(x => this.resolveCachePath(x)); const resolvedPaths = rawPaths.map(x => this.resolveCachePath(x));
(0, cache_utils_1.cacheDebug)(`Using cache paths: ${resolvedPaths}`); (0, cache_utils_1.cacheDebug)(`Using cache paths: ${resolvedPaths}`);
@@ -63871,17 +63818,12 @@ class CacheCleaner {
implicitDescendants: false implicitDescendants: false
}); });
try { try {
for (var _d = true, _e = __asyncValues(globber.globGenerator()), _f; _f = yield _e.next(), _a = _f.done, !_a;) { for (var _d = true, _e = __asyncValues(globber.globGenerator()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
_c = _f.value; _c = _f.value;
_d = false; _d = false;
try {
const file = _c; const file = _c;
fs_1.default.utimesSync(file, timestamp, timestamp); fs_1.default.utimesSync(file, timestamp, timestamp);
} }
finally {
_d = true;
}
}
} }
catch (e_1_1) { e_1 = { error: e_1_1 }; } catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally { finally {
@@ -63944,6 +63886,7 @@ const path_1 = __importDefault(__nccwpck_require__(1017));
const fs_1 = __importDefault(__nccwpck_require__(7147)); const fs_1 = __importDefault(__nccwpck_require__(7147));
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const glob = __importStar(__nccwpck_require__(8090)); const glob = __importStar(__nccwpck_require__(8090));
const params = __importStar(__nccwpck_require__(3885));
const cache_base_1 = __nccwpck_require__(6948); const cache_base_1 = __nccwpck_require__(6948);
const cache_utils_1 = __nccwpck_require__(1678); const cache_utils_1 = __nccwpck_require__(1678);
const build_results_1 = __nccwpck_require__(2107); const build_results_1 = __nccwpck_require__(2107);
@@ -64076,7 +64019,7 @@ class AbstractEntryExtractor {
} }
awaitForDebugging(p) { awaitForDebugging(p) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if ((0, cache_utils_1.isCacheDebuggingEnabled)()) { if (params.isCacheDebuggingEnabled()) {
yield p; yield p;
} }
return p; return p;
@@ -64447,14 +64390,8 @@ const exec = __importStar(__nccwpck_require__(1514));
const crypto = __importStar(__nccwpck_require__(6113)); const crypto = __importStar(__nccwpck_require__(6113));
const path = __importStar(__nccwpck_require__(1017)); const path = __importStar(__nccwpck_require__(1017));
const fs = __importStar(__nccwpck_require__(7147)); const fs = __importStar(__nccwpck_require__(7147));
const CACHE_PROTOCOL_VERSION = 'v7-'; const params = __importStar(__nccwpck_require__(3885));
const JOB_CONTEXT_PARAMETER = 'workflow-job-context'; const CACHE_PROTOCOL_VERSION = 'v8-';
const CACHE_DISABLED_PARAMETER = 'cache-disabled';
const CACHE_READONLY_PARAMETER = 'cache-read-only';
const CACHE_WRITEONLY_PARAMETER = 'cache-write-only';
const STRICT_CACHE_MATCH_PARAMETER = 'gradle-home-cache-strict-match';
const CACHE_CLEANUP_ENABLED_PARAMETER = 'gradle-home-cache-cleanup';
const CACHE_DEBUG_VAR = 'GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED';
const CACHE_KEY_PREFIX_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX'; const CACHE_KEY_PREFIX_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX';
const CACHE_KEY_OS_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_ENVIRONMENT'; const CACHE_KEY_OS_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_ENVIRONMENT';
const CACHE_KEY_JOB_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_JOB'; const CACHE_KEY_JOB_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_JOB';
@@ -64466,23 +64403,23 @@ function isCacheDisabled() {
if (!cache.isFeatureAvailable()) { if (!cache.isFeatureAvailable()) {
return true; return true;
} }
return core.getBooleanInput(CACHE_DISABLED_PARAMETER); return params.isCacheDisabled();
} }
exports.isCacheDisabled = isCacheDisabled; exports.isCacheDisabled = isCacheDisabled;
function isCacheReadOnly() { function isCacheReadOnly() {
return !isCacheWriteOnly() && core.getBooleanInput(CACHE_READONLY_PARAMETER); return !isCacheWriteOnly() && params.isCacheReadOnly();
} }
exports.isCacheReadOnly = isCacheReadOnly; exports.isCacheReadOnly = isCacheReadOnly;
function isCacheWriteOnly() { function isCacheWriteOnly() {
return core.getBooleanInput(CACHE_WRITEONLY_PARAMETER); return params.isCacheWriteOnly();
} }
exports.isCacheWriteOnly = isCacheWriteOnly; exports.isCacheWriteOnly = isCacheWriteOnly;
function isCacheDebuggingEnabled() { function isCacheDebuggingEnabled() {
return process.env[CACHE_DEBUG_VAR] ? true : false; return params.isCacheDebuggingEnabled();
} }
exports.isCacheDebuggingEnabled = isCacheDebuggingEnabled; exports.isCacheDebuggingEnabled = isCacheDebuggingEnabled;
function isCacheCleanupEnabled() { function isCacheCleanupEnabled() {
return core.getBooleanInput(CACHE_CLEANUP_ENABLED_PARAMETER); return params.isCacheCleanupEnabled();
} }
exports.isCacheCleanupEnabled = isCacheCleanupEnabled; exports.isCacheCleanupEnabled = isCacheCleanupEnabled;
class CacheKey { class CacheKey {
@@ -64498,7 +64435,7 @@ function generateCacheKey(cacheName) {
const cacheKeyForJob = `${cacheKeyForEnvironment}|${getCacheKeyJob()}`; const cacheKeyForJob = `${cacheKeyForEnvironment}|${getCacheKeyJob()}`;
const cacheKeyForJobContext = `${cacheKeyForJob}[${getCacheKeyJobInstance()}]`; const cacheKeyForJobContext = `${cacheKeyForJob}[${getCacheKeyJobInstance()}]`;
const cacheKey = `${cacheKeyForJobContext}-${getCacheKeyJobExecution()}`; const cacheKey = `${cacheKeyForJobContext}-${getCacheKeyJobExecution()}`;
if (core.getBooleanInput(STRICT_CACHE_MATCH_PARAMETER)) { if (params.isCacheStrictMatch()) {
return new CacheKey(cacheKey, [cacheKeyForJobContext]); return new CacheKey(cacheKey, [cacheKeyForJobContext]);
} }
return new CacheKey(cacheKey, [cacheKeyForJobContext, cacheKeyForJob, cacheKeyForEnvironment]); return new CacheKey(cacheKey, [cacheKeyForJobContext, cacheKeyForJob, cacheKeyForEnvironment]);
@@ -64513,14 +64450,14 @@ function getCacheKeyEnvironment() {
return process.env[CACHE_KEY_OS_VAR] || runnerOs; return process.env[CACHE_KEY_OS_VAR] || runnerOs;
} }
function getCacheKeyJob() { function getCacheKeyJob() {
return process.env[CACHE_KEY_JOB_VAR] || github.context.job; return process.env[CACHE_KEY_JOB_VAR] || `${github.context.workflow}-${github.context.job}`;
} }
function getCacheKeyJobInstance() { function getCacheKeyJobInstance() {
const override = process.env[CACHE_KEY_JOB_INSTANCE_VAR]; const override = process.env[CACHE_KEY_JOB_INSTANCE_VAR];
if (override) { if (override) {
return override; return override;
} }
const workflowJobContext = core.getInput(JOB_CONTEXT_PARAMETER); const workflowJobContext = params.getJobContext();
return hashStrings([workflowJobContext]); return hashStrings([workflowJobContext]);
} }
function getCacheKeyJobExecution() { function getCacheKeyJobExecution() {
@@ -64963,6 +64900,115 @@ function validateGradleWrapper(buildRootDirectory) {
} }
/***/ }),
/***/ 3885:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobContext = exports.getArguments = exports.getGradleExecutable = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
const core = __importStar(__nccwpck_require__(2186));
const string_argv_1 = __nccwpck_require__(9663);
function isCacheDisabled() {
return getBooleanInput('cache-disabled');
}
exports.isCacheDisabled = isCacheDisabled;
function isCacheReadOnly() {
return getBooleanInput('cache-read-only');
}
exports.isCacheReadOnly = isCacheReadOnly;
function isCacheWriteOnly() {
return getBooleanInput('cache-write-only');
}
exports.isCacheWriteOnly = isCacheWriteOnly;
function isCacheStrictMatch() {
return getBooleanInput('gradle-home-cache-strict-match');
}
exports.isCacheStrictMatch = isCacheStrictMatch;
function isCacheDebuggingEnabled() {
return process.env['GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED'] ? true : false;
}
exports.isCacheDebuggingEnabled = isCacheDebuggingEnabled;
function isCacheCleanupEnabled() {
return getBooleanInput('gradle-home-cache-cleanup');
}
exports.isCacheCleanupEnabled = isCacheCleanupEnabled;
function getCacheIncludes() {
return core.getMultilineInput('gradle-home-cache-includes');
}
exports.getCacheIncludes = getCacheIncludes;
function getCacheExcludes() {
return core.getMultilineInput('gradle-home-cache-excludes');
}
exports.getCacheExcludes = getCacheExcludes;
function getBuildRootDirectory() {
return core.getInput('build-root-directory');
}
exports.getBuildRootDirectory = getBuildRootDirectory;
function getGradleVersion() {
return core.getInput('gradle-version');
}
exports.getGradleVersion = getGradleVersion;
function getGradleExecutable() {
return core.getInput('gradle-executable');
}
exports.getGradleExecutable = getGradleExecutable;
function getArguments() {
const input = core.getInput('arguments');
return (0, string_argv_1.parseArgsStringToArgv)(input);
}
exports.getArguments = getArguments;
function getJobContext() {
return core.getInput('workflow-job-context');
}
exports.getJobContext = getJobContext;
function getGithubToken() {
return core.getInput('github-token', { required: true });
}
exports.getGithubToken = getGithubToken;
function isJobSummaryEnabled() {
return getBooleanInput('generate-job-summary', true);
}
exports.isJobSummaryEnabled = isJobSummaryEnabled;
function getBooleanInput(paramName, paramDefault = false) {
const paramValue = core.getInput(paramName);
switch (paramValue.toLowerCase().trim()) {
case '':
return paramDefault;
case 'false':
return false;
case 'true':
return true;
}
throw TypeError(`The value '${paramValue} is not valid for '${paramName}. Valid values are: [true, false]`);
}
/***/ }), /***/ }),
/***/ 7345: /***/ 7345:
@@ -65128,23 +65174,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.run = void 0; exports.run = void 0;
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const path = __importStar(__nccwpck_require__(1017));
const string_argv_1 = __nccwpck_require__(9453);
const setupGradle = __importStar(__nccwpck_require__(8652)); const setupGradle = __importStar(__nccwpck_require__(8652));
const execution = __importStar(__nccwpck_require__(3584)); const execution = __importStar(__nccwpck_require__(3584));
const provision = __importStar(__nccwpck_require__(2501)); const provisioner = __importStar(__nccwpck_require__(2501));
const layout = __importStar(__nccwpck_require__(8182));
const params = __importStar(__nccwpck_require__(3885));
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
const workspaceDirectory = process.env[`GITHUB_WORKSPACE`] || ''; yield setupGradle.setup();
const buildRootDirectory = resolveBuildRootDirectory(workspaceDirectory); const executable = yield provisioner.provisionGradle();
yield setupGradle.setup(buildRootDirectory); const args = params.getArguments();
const executable = yield provisionGradle(workspaceDirectory);
if (executable !== undefined) {
core.addPath(path.dirname(executable));
}
const args = parseCommandLineArguments();
if (args.length > 0) { if (args.length > 0) {
const buildRootDirectory = layout.buildRootDirectory();
yield execution.executeGradleBuild(executable, buildRootDirectory, args); yield execution.executeGradleBuild(executable, buildRootDirectory, args);
} }
} }
@@ -65158,28 +65200,6 @@ function run() {
} }
exports.run = run; exports.run = run;
run(); run();
function provisionGradle(workspaceDirectory) {
return __awaiter(this, void 0, void 0, function* () {
const gradleVersion = core.getInput('gradle-version');
if (gradleVersion !== '' && gradleVersion !== 'wrapper') {
return path.resolve(yield provision.gradleVersion(gradleVersion));
}
const gradleExecutable = core.getInput('gradle-executable');
if (gradleExecutable !== '') {
return path.resolve(workspaceDirectory, gradleExecutable);
}
return undefined;
});
}
function resolveBuildRootDirectory(baseDirectory) {
const buildRootDirectory = core.getInput('build-root-directory');
const resolvedBuildRootDirectory = buildRootDirectory === '' ? path.resolve(baseDirectory) : path.resolve(baseDirectory, buildRootDirectory);
return resolvedBuildRootDirectory;
}
function parseCommandLineArguments() {
const input = core.getInput('arguments');
return (0, string_argv_1.parseArgsStringToArgv)(input);
}
/***/ }), /***/ }),
@@ -65222,7 +65242,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}); });
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.gradleVersion = void 0; exports.provisionGradle = void 0;
const fs = __importStar(__nccwpck_require__(7147)); const fs = __importStar(__nccwpck_require__(7147));
const os = __importStar(__nccwpck_require__(2037)); const os = __importStar(__nccwpck_require__(2037));
const path = __importStar(__nccwpck_require__(1017)); const path = __importStar(__nccwpck_require__(1017));
@@ -65231,9 +65251,32 @@ const core = __importStar(__nccwpck_require__(2186));
const cache = __importStar(__nccwpck_require__(7799)); const cache = __importStar(__nccwpck_require__(7799));
const toolCache = __importStar(__nccwpck_require__(7784)); const toolCache = __importStar(__nccwpck_require__(7784));
const gradlew = __importStar(__nccwpck_require__(2335)); const gradlew = __importStar(__nccwpck_require__(2335));
const params = __importStar(__nccwpck_require__(3885));
const layout = __importStar(__nccwpck_require__(8182));
const cache_utils_1 = __nccwpck_require__(1678); const cache_utils_1 = __nccwpck_require__(1678);
const gradleVersionsBaseUrl = 'https://services.gradle.org/versions'; const gradleVersionsBaseUrl = 'https://services.gradle.org/versions';
function gradleVersion(version) { function provisionGradle() {
return __awaiter(this, void 0, void 0, function* () {
const gradleVersion = params.getGradleVersion();
if (gradleVersion !== '' && gradleVersion !== 'wrapper') {
return addToPath(path.resolve(yield installGradle(gradleVersion)));
}
const gradleExecutable = params.getGradleExecutable();
if (gradleExecutable !== '') {
const workspaceDirectory = layout.workspaceDirectory();
return addToPath(path.resolve(workspaceDirectory, gradleExecutable));
}
return undefined;
});
}
exports.provisionGradle = provisionGradle;
function addToPath(executable) {
return __awaiter(this, void 0, void 0, function* () {
core.addPath(path.dirname(executable));
return executable;
});
}
function installGradle(version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
switch (version) { switch (version) {
case 'current': case 'current':
@@ -65252,18 +65295,17 @@ function gradleVersion(version) {
} }
}); });
} }
exports.gradleVersion = gradleVersion;
function gradleCurrent() { function gradleCurrent() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/current`); const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/current`);
return provisionGradle(versionInfo); return installGradleVersion(versionInfo);
}); });
} }
function gradleReleaseCandidate() { function gradleReleaseCandidate() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-candidate`); const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-candidate`);
if (versionInfo && versionInfo.version && versionInfo.downloadUrl) { if (versionInfo && versionInfo.version && versionInfo.downloadUrl) {
return provisionGradle(versionInfo); return installGradleVersion(versionInfo);
} }
core.info('No current release-candidate found, will fallback to current'); core.info('No current release-candidate found, will fallback to current');
return gradleCurrent(); return gradleCurrent();
@@ -65272,13 +65314,13 @@ function gradleReleaseCandidate() {
function gradleNightly() { function gradleNightly() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/nightly`); const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/nightly`);
return provisionGradle(versionInfo); return installGradleVersion(versionInfo);
}); });
} }
function gradleReleaseNightly() { function gradleReleaseNightly() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-nightly`); const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-nightly`);
return provisionGradle(versionInfo); return installGradleVersion(versionInfo);
}); });
} }
function gradle(version) { function gradle(version) {
@@ -65287,7 +65329,7 @@ function gradle(version) {
if (!versionInfo) { if (!versionInfo) {
throw new Error(`Gradle version ${version} does not exists`); throw new Error(`Gradle version ${version} does not exists`);
} }
return provisionGradle(versionInfo); return installGradleVersion(versionInfo);
}); });
} }
function gradleVersionDeclaration(url) { function gradleVersionDeclaration(url) {
@@ -65303,7 +65345,7 @@ function findGradleVersionDeclaration(version) {
}); });
}); });
} }
function provisionGradle(versionInfo) { function installGradleVersion(versionInfo) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
return core.group(`Provision Gradle ${versionInfo.version}`, () => __awaiter(this, void 0, void 0, function* () { return core.group(`Provision Gradle ${versionInfo.version}`, () => __awaiter(this, void 0, void 0, function* () {
return locateGradleAndDownloadIfRequired(versionInfo); return locateGradleAndDownloadIfRequired(versionInfo);
@@ -65386,6 +65428,55 @@ function httpGetString(url) {
} }
/***/ }),
/***/ 8182:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.buildRootDirectory = exports.workspaceDirectory = void 0;
const params = __importStar(__nccwpck_require__(3885));
const path = __importStar(__nccwpck_require__(1017));
function workspaceDirectory() {
return process.env[`GITHUB_WORKSPACE`] || '';
}
exports.workspaceDirectory = workspaceDirectory;
function buildRootDirectory() {
const baseDirectory = workspaceDirectory();
const buildRootDirectoryInput = params.getBuildRootDirectory();
const resolvedBuildRootDirectory = buildRootDirectoryInput === ''
? path.resolve(baseDirectory)
: path.resolve(baseDirectory, buildRootDirectoryInput);
return resolvedBuildRootDirectory;
}
exports.buildRootDirectory = buildRootDirectory;
/***/ }), /***/ }),
/***/ 8652: /***/ 8652:
@@ -65433,6 +65524,8 @@ const summary_1 = __nccwpck_require__(1327);
const path = __importStar(__nccwpck_require__(1017)); const path = __importStar(__nccwpck_require__(1017));
const os = __importStar(__nccwpck_require__(2037)); const os = __importStar(__nccwpck_require__(2037));
const caches = __importStar(__nccwpck_require__(3800)); const caches = __importStar(__nccwpck_require__(3800));
const layout = __importStar(__nccwpck_require__(8182));
const params = __importStar(__nccwpck_require__(3885));
const job_summary_1 = __nccwpck_require__(7345); const job_summary_1 = __nccwpck_require__(7345);
const build_results_1 = __nccwpck_require__(2107); const build_results_1 = __nccwpck_require__(2107);
const cache_reporting_1 = __nccwpck_require__(6674); const cache_reporting_1 = __nccwpck_require__(6674);
@@ -65440,16 +65533,9 @@ const daemon_controller_1 = __nccwpck_require__(5146);
const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED'; const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED';
const GRADLE_USER_HOME = 'GRADLE_USER_HOME'; const GRADLE_USER_HOME = 'GRADLE_USER_HOME';
const CACHE_LISTENER = 'CACHE_LISTENER'; const CACHE_LISTENER = 'CACHE_LISTENER';
const JOB_SUMMARY_ENABLED_PARAMETER = 'generate-job-summary'; function setup() {
function shouldGenerateJobSummary() {
if (!process.env[summary_1.SUMMARY_ENV_VAR]) {
return false;
}
return core.getBooleanInput(JOB_SUMMARY_ENABLED_PARAMETER);
}
function setup(buildRootDirectory) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const gradleUserHome = yield determineGradleUserHome(buildRootDirectory); const gradleUserHome = yield determineGradleUserHome();
if (process.env[GRADLE_SETUP_VAR]) { if (process.env[GRADLE_SETUP_VAR]) {
core.info('Gradle setup only performed on first gradle-build-action step in workflow.'); core.info('Gradle setup only performed on first gradle-build-action step in workflow.');
return; return;
@@ -65484,10 +65570,11 @@ function complete() {
}); });
} }
exports.complete = complete; exports.complete = complete;
function determineGradleUserHome(rootDir) { function determineGradleUserHome() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const customGradleUserHome = process.env['GRADLE_USER_HOME']; const customGradleUserHome = process.env['GRADLE_USER_HOME'];
if (customGradleUserHome) { if (customGradleUserHome) {
const rootDir = layout.workspaceDirectory();
return path.resolve(rootDir, customGradleUserHome); return path.resolve(rootDir, customGradleUserHome);
} }
return path.resolve(yield determineUserHome(), '.gradle'); return path.resolve(yield determineUserHome(), '.gradle');
@@ -65507,6 +65594,12 @@ function determineUserHome() {
return userHome; return userHome;
}); });
} }
function shouldGenerateJobSummary() {
if (!process.env[summary_1.SUMMARY_ENV_VAR]) {
return false;
}
return params.isJobSummaryEnabled();
}
/***/ }), /***/ }),
@@ -65669,6 +65762,59 @@ module.exports = require("util");
"use strict"; "use strict";
module.exports = require("zlib"); module.exports = require("zlib");
/***/ }),
/***/ 9663:
/***/ ((__unused_webpack_module, exports) => {
"use strict";
exports.__esModule = true;
exports.parseArgsStringToArgv = void 0;
function parseArgsStringToArgv(value, env, file) {
// ([^\s'"]([^\s'"]*(['"])([^\3]*?)\3)+[^\s'"]*) Matches nested quotes until the first space outside of quotes
// [^\s'"]+ or Match if not a space ' or "
// (['"])([^\5]*?)\5 or Match "quoted text" without quotes
// `\3` and `\5` are a backreference to the quote style (' or ") captured
var myRegexp = /([^\s'"]([^\s'"]*(['"])([^\3]*?)\3)+[^\s'"]*)|[^\s'"]+|(['"])([^\5]*?)\5/gi;
var myString = value;
var myArray = [];
if (env) {
myArray.push(env);
}
if (file) {
myArray.push(file);
}
var match;
do {
// Each call to exec returns the next regex match as an array
match = myRegexp.exec(myString);
if (match !== null) {
// Index 1 in the array is the captured group if it exists
// Index 0 is the matched text, which we use if no captured group exists
myArray.push(firstString(match[1], match[6], match[0]));
}
} while (match !== null);
return myArray;
}
exports["default"] = parseArgsStringToArgv;
exports.parseArgsStringToArgv = parseArgsStringToArgv;
// Accepts any number of arguments, and returns the first one that is a string
// (even an empty string)
function firstString() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
for (var i = 0; i < args.length; i++) {
var arg = args[i];
if (typeof arg === "string") {
return arg;
}
}
}
/***/ }), /***/ }),
/***/ 3765: /***/ 3765:

File diff suppressed because one or more lines are too long

276
dist/post/index.js vendored
View File

@@ -62662,12 +62662,11 @@ const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514)); const exec = __importStar(__nccwpck_require__(1514));
const path_1 = __importDefault(__nccwpck_require__(1017)); const path_1 = __importDefault(__nccwpck_require__(1017));
const fs_1 = __importDefault(__nccwpck_require__(7147)); const fs_1 = __importDefault(__nccwpck_require__(7147));
const params = __importStar(__nccwpck_require__(3885));
const cache_utils_1 = __nccwpck_require__(1678); const cache_utils_1 = __nccwpck_require__(1678);
const cache_extract_entries_1 = __nccwpck_require__(6161); const cache_extract_entries_1 = __nccwpck_require__(6161);
const RESTORED_CACHE_KEY_KEY = 'restored-cache-key'; const RESTORED_CACHE_KEY_KEY = 'restored-cache-key';
exports.META_FILE_DIR = '.gradle-build-action'; exports.META_FILE_DIR = '.gradle-build-action';
const INCLUDE_PATHS_PARAMETER = 'gradle-home-cache-includes';
const EXCLUDE_PATHS_PARAMETER = 'gradle-home-cache-excludes';
class GradleStateCache { class GradleStateCache {
constructor(gradleUserHome) { constructor(gradleUserHome) {
this.gradleUserHome = gradleUserHome; this.gradleUserHome = gradleUserHome;
@@ -62759,7 +62758,7 @@ class GradleStateCache {
}); });
} }
deleteExcludedPaths() { deleteExcludedPaths() {
const rawPaths = core.getMultilineInput(EXCLUDE_PATHS_PARAMETER); const rawPaths = params.getCacheExcludes();
const resolvedPaths = rawPaths.map(x => path_1.default.resolve(this.gradleUserHome, x)); const resolvedPaths = rawPaths.map(x => path_1.default.resolve(this.gradleUserHome, x));
for (const p of resolvedPaths) { for (const p of resolvedPaths) {
(0, cache_utils_1.cacheDebug)(`Deleting excluded path: ${p}`); (0, cache_utils_1.cacheDebug)(`Deleting excluded path: ${p}`);
@@ -62767,7 +62766,7 @@ class GradleStateCache {
} }
} }
getCachePath() { getCachePath() {
const rawPaths = core.getMultilineInput(INCLUDE_PATHS_PARAMETER); const rawPaths = params.getCacheIncludes();
rawPaths.push(exports.META_FILE_DIR); rawPaths.push(exports.META_FILE_DIR);
const resolvedPaths = rawPaths.map(x => this.resolveCachePath(x)); const resolvedPaths = rawPaths.map(x => this.resolveCachePath(x));
(0, cache_utils_1.cacheDebug)(`Using cache paths: ${resolvedPaths}`); (0, cache_utils_1.cacheDebug)(`Using cache paths: ${resolvedPaths}`);
@@ -62922,17 +62921,12 @@ class CacheCleaner {
implicitDescendants: false implicitDescendants: false
}); });
try { try {
for (var _d = true, _e = __asyncValues(globber.globGenerator()), _f; _f = yield _e.next(), _a = _f.done, !_a;) { for (var _d = true, _e = __asyncValues(globber.globGenerator()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
_c = _f.value; _c = _f.value;
_d = false; _d = false;
try {
const file = _c; const file = _c;
fs_1.default.utimesSync(file, timestamp, timestamp); fs_1.default.utimesSync(file, timestamp, timestamp);
} }
finally {
_d = true;
}
}
} }
catch (e_1_1) { e_1 = { error: e_1_1 }; } catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally { finally {
@@ -62995,6 +62989,7 @@ const path_1 = __importDefault(__nccwpck_require__(1017));
const fs_1 = __importDefault(__nccwpck_require__(7147)); const fs_1 = __importDefault(__nccwpck_require__(7147));
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const glob = __importStar(__nccwpck_require__(8090)); const glob = __importStar(__nccwpck_require__(8090));
const params = __importStar(__nccwpck_require__(3885));
const cache_base_1 = __nccwpck_require__(6948); const cache_base_1 = __nccwpck_require__(6948);
const cache_utils_1 = __nccwpck_require__(1678); const cache_utils_1 = __nccwpck_require__(1678);
const build_results_1 = __nccwpck_require__(2107); const build_results_1 = __nccwpck_require__(2107);
@@ -63127,7 +63122,7 @@ class AbstractEntryExtractor {
} }
awaitForDebugging(p) { awaitForDebugging(p) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if ((0, cache_utils_1.isCacheDebuggingEnabled)()) { if (params.isCacheDebuggingEnabled()) {
yield p; yield p;
} }
return p; return p;
@@ -63498,14 +63493,8 @@ const exec = __importStar(__nccwpck_require__(1514));
const crypto = __importStar(__nccwpck_require__(6113)); const crypto = __importStar(__nccwpck_require__(6113));
const path = __importStar(__nccwpck_require__(1017)); const path = __importStar(__nccwpck_require__(1017));
const fs = __importStar(__nccwpck_require__(7147)); const fs = __importStar(__nccwpck_require__(7147));
const CACHE_PROTOCOL_VERSION = 'v7-'; const params = __importStar(__nccwpck_require__(3885));
const JOB_CONTEXT_PARAMETER = 'workflow-job-context'; const CACHE_PROTOCOL_VERSION = 'v8-';
const CACHE_DISABLED_PARAMETER = 'cache-disabled';
const CACHE_READONLY_PARAMETER = 'cache-read-only';
const CACHE_WRITEONLY_PARAMETER = 'cache-write-only';
const STRICT_CACHE_MATCH_PARAMETER = 'gradle-home-cache-strict-match';
const CACHE_CLEANUP_ENABLED_PARAMETER = 'gradle-home-cache-cleanup';
const CACHE_DEBUG_VAR = 'GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED';
const CACHE_KEY_PREFIX_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX'; const CACHE_KEY_PREFIX_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX';
const CACHE_KEY_OS_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_ENVIRONMENT'; const CACHE_KEY_OS_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_ENVIRONMENT';
const CACHE_KEY_JOB_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_JOB'; const CACHE_KEY_JOB_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_JOB';
@@ -63517,23 +63506,23 @@ function isCacheDisabled() {
if (!cache.isFeatureAvailable()) { if (!cache.isFeatureAvailable()) {
return true; return true;
} }
return core.getBooleanInput(CACHE_DISABLED_PARAMETER); return params.isCacheDisabled();
} }
exports.isCacheDisabled = isCacheDisabled; exports.isCacheDisabled = isCacheDisabled;
function isCacheReadOnly() { function isCacheReadOnly() {
return !isCacheWriteOnly() && core.getBooleanInput(CACHE_READONLY_PARAMETER); return !isCacheWriteOnly() && params.isCacheReadOnly();
} }
exports.isCacheReadOnly = isCacheReadOnly; exports.isCacheReadOnly = isCacheReadOnly;
function isCacheWriteOnly() { function isCacheWriteOnly() {
return core.getBooleanInput(CACHE_WRITEONLY_PARAMETER); return params.isCacheWriteOnly();
} }
exports.isCacheWriteOnly = isCacheWriteOnly; exports.isCacheWriteOnly = isCacheWriteOnly;
function isCacheDebuggingEnabled() { function isCacheDebuggingEnabled() {
return process.env[CACHE_DEBUG_VAR] ? true : false; return params.isCacheDebuggingEnabled();
} }
exports.isCacheDebuggingEnabled = isCacheDebuggingEnabled; exports.isCacheDebuggingEnabled = isCacheDebuggingEnabled;
function isCacheCleanupEnabled() { function isCacheCleanupEnabled() {
return core.getBooleanInput(CACHE_CLEANUP_ENABLED_PARAMETER); return params.isCacheCleanupEnabled();
} }
exports.isCacheCleanupEnabled = isCacheCleanupEnabled; exports.isCacheCleanupEnabled = isCacheCleanupEnabled;
class CacheKey { class CacheKey {
@@ -63549,7 +63538,7 @@ function generateCacheKey(cacheName) {
const cacheKeyForJob = `${cacheKeyForEnvironment}|${getCacheKeyJob()}`; const cacheKeyForJob = `${cacheKeyForEnvironment}|${getCacheKeyJob()}`;
const cacheKeyForJobContext = `${cacheKeyForJob}[${getCacheKeyJobInstance()}]`; const cacheKeyForJobContext = `${cacheKeyForJob}[${getCacheKeyJobInstance()}]`;
const cacheKey = `${cacheKeyForJobContext}-${getCacheKeyJobExecution()}`; const cacheKey = `${cacheKeyForJobContext}-${getCacheKeyJobExecution()}`;
if (core.getBooleanInput(STRICT_CACHE_MATCH_PARAMETER)) { if (params.isCacheStrictMatch()) {
return new CacheKey(cacheKey, [cacheKeyForJobContext]); return new CacheKey(cacheKey, [cacheKeyForJobContext]);
} }
return new CacheKey(cacheKey, [cacheKeyForJobContext, cacheKeyForJob, cacheKeyForEnvironment]); return new CacheKey(cacheKey, [cacheKeyForJobContext, cacheKeyForJob, cacheKeyForEnvironment]);
@@ -63564,14 +63553,14 @@ function getCacheKeyEnvironment() {
return process.env[CACHE_KEY_OS_VAR] || runnerOs; return process.env[CACHE_KEY_OS_VAR] || runnerOs;
} }
function getCacheKeyJob() { function getCacheKeyJob() {
return process.env[CACHE_KEY_JOB_VAR] || github.context.job; return process.env[CACHE_KEY_JOB_VAR] || `${github.context.workflow}-${github.context.job}`;
} }
function getCacheKeyJobInstance() { function getCacheKeyJobInstance() {
const override = process.env[CACHE_KEY_JOB_INSTANCE_VAR]; const override = process.env[CACHE_KEY_JOB_INSTANCE_VAR];
if (override) { if (override) {
return override; return override;
} }
const workflowJobContext = core.getInput(JOB_CONTEXT_PARAMETER); const workflowJobContext = params.getJobContext();
return hashStrings([workflowJobContext]); return hashStrings([workflowJobContext]);
} }
function getCacheKeyJobExecution() { function getCacheKeyJobExecution() {
@@ -63883,6 +63872,115 @@ class DaemonController {
exports.DaemonController = DaemonController; exports.DaemonController = DaemonController;
/***/ }),
/***/ 3885:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobContext = exports.getArguments = exports.getGradleExecutable = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
const core = __importStar(__nccwpck_require__(2186));
const string_argv_1 = __nccwpck_require__(9663);
function isCacheDisabled() {
return getBooleanInput('cache-disabled');
}
exports.isCacheDisabled = isCacheDisabled;
function isCacheReadOnly() {
return getBooleanInput('cache-read-only');
}
exports.isCacheReadOnly = isCacheReadOnly;
function isCacheWriteOnly() {
return getBooleanInput('cache-write-only');
}
exports.isCacheWriteOnly = isCacheWriteOnly;
function isCacheStrictMatch() {
return getBooleanInput('gradle-home-cache-strict-match');
}
exports.isCacheStrictMatch = isCacheStrictMatch;
function isCacheDebuggingEnabled() {
return process.env['GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED'] ? true : false;
}
exports.isCacheDebuggingEnabled = isCacheDebuggingEnabled;
function isCacheCleanupEnabled() {
return getBooleanInput('gradle-home-cache-cleanup');
}
exports.isCacheCleanupEnabled = isCacheCleanupEnabled;
function getCacheIncludes() {
return core.getMultilineInput('gradle-home-cache-includes');
}
exports.getCacheIncludes = getCacheIncludes;
function getCacheExcludes() {
return core.getMultilineInput('gradle-home-cache-excludes');
}
exports.getCacheExcludes = getCacheExcludes;
function getBuildRootDirectory() {
return core.getInput('build-root-directory');
}
exports.getBuildRootDirectory = getBuildRootDirectory;
function getGradleVersion() {
return core.getInput('gradle-version');
}
exports.getGradleVersion = getGradleVersion;
function getGradleExecutable() {
return core.getInput('gradle-executable');
}
exports.getGradleExecutable = getGradleExecutable;
function getArguments() {
const input = core.getInput('arguments');
return (0, string_argv_1.parseArgsStringToArgv)(input);
}
exports.getArguments = getArguments;
function getJobContext() {
return core.getInput('workflow-job-context');
}
exports.getJobContext = getJobContext;
function getGithubToken() {
return core.getInput('github-token', { required: true });
}
exports.getGithubToken = getGithubToken;
function isJobSummaryEnabled() {
return getBooleanInput('generate-job-summary', true);
}
exports.isJobSummaryEnabled = isJobSummaryEnabled;
function getBooleanInput(paramName, paramDefault = false) {
const paramValue = core.getInput(paramName);
switch (paramValue.toLowerCase().trim()) {
case '':
return paramDefault;
case 'false':
return false;
case 'true':
return true;
}
throw TypeError(`The value '${paramValue} is not valid for '${paramName}. Valid values are: [true, false]`);
}
/***/ }), /***/ }),
/***/ 7345: /***/ 7345:
@@ -64070,6 +64168,55 @@ function handleFailure(error) {
run(); run();
/***/ }),
/***/ 8182:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.buildRootDirectory = exports.workspaceDirectory = void 0;
const params = __importStar(__nccwpck_require__(3885));
const path = __importStar(__nccwpck_require__(1017));
function workspaceDirectory() {
return process.env[`GITHUB_WORKSPACE`] || '';
}
exports.workspaceDirectory = workspaceDirectory;
function buildRootDirectory() {
const baseDirectory = workspaceDirectory();
const buildRootDirectoryInput = params.getBuildRootDirectory();
const resolvedBuildRootDirectory = buildRootDirectoryInput === ''
? path.resolve(baseDirectory)
: path.resolve(baseDirectory, buildRootDirectoryInput);
return resolvedBuildRootDirectory;
}
exports.buildRootDirectory = buildRootDirectory;
/***/ }), /***/ }),
/***/ 8652: /***/ 8652:
@@ -64117,6 +64264,8 @@ const summary_1 = __nccwpck_require__(1327);
const path = __importStar(__nccwpck_require__(1017)); const path = __importStar(__nccwpck_require__(1017));
const os = __importStar(__nccwpck_require__(2037)); const os = __importStar(__nccwpck_require__(2037));
const caches = __importStar(__nccwpck_require__(3800)); const caches = __importStar(__nccwpck_require__(3800));
const layout = __importStar(__nccwpck_require__(8182));
const params = __importStar(__nccwpck_require__(3885));
const job_summary_1 = __nccwpck_require__(7345); const job_summary_1 = __nccwpck_require__(7345);
const build_results_1 = __nccwpck_require__(2107); const build_results_1 = __nccwpck_require__(2107);
const cache_reporting_1 = __nccwpck_require__(6674); const cache_reporting_1 = __nccwpck_require__(6674);
@@ -64124,16 +64273,9 @@ const daemon_controller_1 = __nccwpck_require__(5146);
const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED'; const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED';
const GRADLE_USER_HOME = 'GRADLE_USER_HOME'; const GRADLE_USER_HOME = 'GRADLE_USER_HOME';
const CACHE_LISTENER = 'CACHE_LISTENER'; const CACHE_LISTENER = 'CACHE_LISTENER';
const JOB_SUMMARY_ENABLED_PARAMETER = 'generate-job-summary'; function setup() {
function shouldGenerateJobSummary() {
if (!process.env[summary_1.SUMMARY_ENV_VAR]) {
return false;
}
return core.getBooleanInput(JOB_SUMMARY_ENABLED_PARAMETER);
}
function setup(buildRootDirectory) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const gradleUserHome = yield determineGradleUserHome(buildRootDirectory); const gradleUserHome = yield determineGradleUserHome();
if (process.env[GRADLE_SETUP_VAR]) { if (process.env[GRADLE_SETUP_VAR]) {
core.info('Gradle setup only performed on first gradle-build-action step in workflow.'); core.info('Gradle setup only performed on first gradle-build-action step in workflow.');
return; return;
@@ -64168,10 +64310,11 @@ function complete() {
}); });
} }
exports.complete = complete; exports.complete = complete;
function determineGradleUserHome(rootDir) { function determineGradleUserHome() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const customGradleUserHome = process.env['GRADLE_USER_HOME']; const customGradleUserHome = process.env['GRADLE_USER_HOME'];
if (customGradleUserHome) { if (customGradleUserHome) {
const rootDir = layout.workspaceDirectory();
return path.resolve(rootDir, customGradleUserHome); return path.resolve(rootDir, customGradleUserHome);
} }
return path.resolve(yield determineUserHome(), '.gradle'); return path.resolve(yield determineUserHome(), '.gradle');
@@ -64191,6 +64334,12 @@ function determineUserHome() {
return userHome; return userHome;
}); });
} }
function shouldGenerateJobSummary() {
if (!process.env[summary_1.SUMMARY_ENV_VAR]) {
return false;
}
return params.isJobSummaryEnabled();
}
/***/ }), /***/ }),
@@ -64353,6 +64502,59 @@ module.exports = require("util");
"use strict"; "use strict";
module.exports = require("zlib"); module.exports = require("zlib");
/***/ }),
/***/ 9663:
/***/ ((__unused_webpack_module, exports) => {
"use strict";
exports.__esModule = true;
exports.parseArgsStringToArgv = void 0;
function parseArgsStringToArgv(value, env, file) {
// ([^\s'"]([^\s'"]*(['"])([^\3]*?)\3)+[^\s'"]*) Matches nested quotes until the first space outside of quotes
// [^\s'"]+ or Match if not a space ' or "
// (['"])([^\5]*?)\5 or Match "quoted text" without quotes
// `\3` and `\5` are a backreference to the quote style (' or ") captured
var myRegexp = /([^\s'"]([^\s'"]*(['"])([^\3]*?)\3)+[^\s'"]*)|[^\s'"]+|(['"])([^\5]*?)\5/gi;
var myString = value;
var myArray = [];
if (env) {
myArray.push(env);
}
if (file) {
myArray.push(file);
}
var match;
do {
// Each call to exec returns the next regex match as an array
match = myRegexp.exec(myString);
if (match !== null) {
// Index 1 in the array is the captured group if it exists
// Index 0 is the matched text, which we use if no captured group exists
myArray.push(firstString(match[1], match[6], match[0]));
}
} while (match !== null);
return myArray;
}
exports["default"] = parseArgsStringToArgv;
exports.parseArgsStringToArgv = parseArgsStringToArgv;
// Accepts any number of arguments, and returns the first one that is a string
// (even an empty string)
function firstString() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
for (var i = 0; i < args.length; i++) {
var arg = args[i];
if (typeof arg === "string") {
return arg;
}
}
}
/***/ }), /***/ }),
/***/ 3765: /***/ 3765:

File diff suppressed because one or more lines are too long

918
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,13 @@
"format": "prettier --write **/*.ts", "format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts", "format-check": "prettier --check **/*.ts",
"lint": "eslint src/**/*.ts", "lint": "eslint src/**/*.ts",
"compile": "ncc build src/main.ts --out dist/main --source-map --no-source-map-register && ncc build src/post.ts --out dist/post --source-map --no-source-map-register",
"compile-main": "ncc build src/main.ts --out dist/main --source-map --no-source-map-register",
"compile-post": "ncc build src/post.ts --out dist/post --source-map --no-source-map-register",
"compile-dependency-graph-generate": "ncc build src/dependency-graph-generate.ts --out dist/dependency-graph-generate --source-map --no-source-map-register",
"compile-dependency-graph-submit": "ncc build src/dependency-graph-submit.ts --out dist/dependency-graph-submit --source-map --no-source-map-register",
"compile": "npm run compile-main && npm run compile-post && npm run compile-dependency-graph-generate && npm run compile-dependency-graph-submit",
"test": "jest", "test": "jest",
"check": "npm run format && npm run lint", "check": "npm run format && npm run lint",
"build": "npm run check && npm run compile", "build": "npm run check && npm run compile",
@@ -26,6 +32,7 @@
], ],
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/artifact": "1.1.1",
"@actions/cache": "3.2.1", "@actions/cache": "3.2.1",
"@actions/core": "1.10.0", "@actions/core": "1.10.0",
"@actions/exec": "1.1.1", "@actions/exec": "1.1.1",
@@ -33,22 +40,23 @@
"@actions/glob": "0.4.0", "@actions/glob": "0.4.0",
"@actions/http-client": "2.1.0", "@actions/http-client": "2.1.0",
"@actions/tool-cache": "2.0.1", "@actions/tool-cache": "2.0.1",
"string-argv": "0.3.1" "@octokit/rest": "19.0.11",
"string-argv": "0.3.2"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "16.11.21", "@types/node": "16.11.21",
"@types/jest": "29.5.0", "@types/jest": "29.5.2",
"@types/unzipper": "0.10.5", "@types/unzipper": "0.10.6",
"@typescript-eslint/parser": "5.58.0", "@typescript-eslint/parser": "5.60.1",
"@vercel/ncc": "0.36.1", "@vercel/ncc": "0.36.1",
"eslint": "8.38.0", "eslint": "8.43.0",
"eslint-plugin-github": "4.7.0", "eslint-plugin-github": "4.8.0",
"eslint-plugin-jest": "27.2.1", "eslint-plugin-jest": "27.2.1",
"jest": "29.5.0", "jest": "29.5.0",
"js-yaml": "4.1.0", "js-yaml": "4.1.0",
"patch-package": "6.5.1", "patch-package": "7.0.0",
"prettier": "2.8.7", "prettier": "2.8.8",
"ts-jest": "29.1.0", "ts-jest": "29.1.0",
"typescript": "5.0.4" "typescript": "5.1.5"
} }
} }

View File

@@ -2,6 +2,7 @@ import * as core from '@actions/core'
import * as exec from '@actions/exec' import * as exec from '@actions/exec'
import path from 'path' import path from 'path'
import fs from 'fs' import fs from 'fs'
import * as params from './input-params'
import {CacheListener} from './cache-reporting' import {CacheListener} from './cache-reporting'
import {saveCache, restoreCache, cacheDebug, isCacheDebuggingEnabled, tryDelete, generateCacheKey} from './cache-utils' import {saveCache, restoreCache, cacheDebug, isCacheDebuggingEnabled, tryDelete, generateCacheKey} from './cache-utils'
import {GradleHomeEntryExtractor} from './cache-extract-entries' import {GradleHomeEntryExtractor} from './cache-extract-entries'
@@ -9,8 +10,6 @@ import {GradleHomeEntryExtractor} from './cache-extract-entries'
const RESTORED_CACHE_KEY_KEY = 'restored-cache-key' const RESTORED_CACHE_KEY_KEY = 'restored-cache-key'
export const META_FILE_DIR = '.gradle-build-action' export const META_FILE_DIR = '.gradle-build-action'
const INCLUDE_PATHS_PARAMETER = 'gradle-home-cache-includes'
const EXCLUDE_PATHS_PARAMETER = 'gradle-home-cache-excludes'
export class GradleStateCache { export class GradleStateCache {
private cacheName: string private cacheName: string
@@ -142,7 +141,7 @@ export class GradleStateCache {
* Delete any file paths that are excluded by the `gradle-home-cache-excludes` parameter. * Delete any file paths that are excluded by the `gradle-home-cache-excludes` parameter.
*/ */
private deleteExcludedPaths(): void { private deleteExcludedPaths(): void {
const rawPaths: string[] = core.getMultilineInput(EXCLUDE_PATHS_PARAMETER) const rawPaths: string[] = params.getCacheExcludes()
const resolvedPaths = rawPaths.map(x => path.resolve(this.gradleUserHome, x)) const resolvedPaths = rawPaths.map(x => path.resolve(this.gradleUserHome, x))
for (const p of resolvedPaths) { for (const p of resolvedPaths) {
@@ -157,7 +156,7 @@ export class GradleStateCache {
* but this can be overridden by the `gradle-home-cache-includes` parameter. * but this can be overridden by the `gradle-home-cache-includes` parameter.
*/ */
protected getCachePath(): string[] { protected getCachePath(): string[] {
const rawPaths: string[] = core.getMultilineInput(INCLUDE_PATHS_PARAMETER) const rawPaths: string[] = params.getCacheIncludes()
rawPaths.push(META_FILE_DIR) rawPaths.push(META_FILE_DIR)
const resolvedPaths = rawPaths.map(x => this.resolveCachePath(x)) const resolvedPaths = rawPaths.map(x => this.resolveCachePath(x))
cacheDebug(`Using cache paths: ${resolvedPaths}`) cacheDebug(`Using cache paths: ${resolvedPaths}`)

View File

@@ -3,17 +3,11 @@ import fs from 'fs'
import * as core from '@actions/core' import * as core from '@actions/core'
import * as glob from '@actions/glob' import * as glob from '@actions/glob'
import * as params from './input-params'
import {META_FILE_DIR} from './cache-base' import {META_FILE_DIR} from './cache-base'
import {CacheEntryListener, CacheListener} from './cache-reporting' import {CacheEntryListener, CacheListener} from './cache-reporting'
import { import {cacheDebug, getCacheKeyPrefix, hashFileNames, restoreCache, saveCache, tryDelete} from './cache-utils'
cacheDebug,
getCacheKeyPrefix,
hashFileNames,
isCacheDebuggingEnabled,
restoreCache,
saveCache,
tryDelete
} from './cache-utils'
import {loadBuildResults} from './build-results' import {loadBuildResults} from './build-results'
const SKIP_RESTORE_VAR = 'GRADLE_BUILD_ACTION_SKIP_RESTORE' const SKIP_RESTORE_VAR = 'GRADLE_BUILD_ACTION_SKIP_RESTORE'
@@ -246,7 +240,7 @@ abstract class AbstractEntryExtractor {
// Run actions sequentially if debugging is enabled // Run actions sequentially if debugging is enabled
private async awaitForDebugging(p: Promise<ExtractedCacheEntry>): Promise<ExtractedCacheEntry> { private async awaitForDebugging(p: Promise<ExtractedCacheEntry>): Promise<ExtractedCacheEntry> {
if (isCacheDebuggingEnabled()) { if (params.isCacheDebuggingEnabled()) {
await p await p
} }
return p return p

View File

@@ -7,17 +7,11 @@ import * as crypto from 'crypto'
import * as path from 'path' import * as path from 'path'
import * as fs from 'fs' import * as fs from 'fs'
import * as params from './input-params'
import {CacheEntryListener} from './cache-reporting' import {CacheEntryListener} from './cache-reporting'
const CACHE_PROTOCOL_VERSION = 'v7-' const CACHE_PROTOCOL_VERSION = 'v8-'
const JOB_CONTEXT_PARAMETER = 'workflow-job-context'
const CACHE_DISABLED_PARAMETER = 'cache-disabled'
const CACHE_READONLY_PARAMETER = 'cache-read-only'
const CACHE_WRITEONLY_PARAMETER = 'cache-write-only'
const STRICT_CACHE_MATCH_PARAMETER = 'gradle-home-cache-strict-match'
const CACHE_CLEANUP_ENABLED_PARAMETER = 'gradle-home-cache-cleanup'
const CACHE_DEBUG_VAR = 'GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED'
const CACHE_KEY_PREFIX_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX' const CACHE_KEY_PREFIX_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX'
const CACHE_KEY_OS_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_ENVIRONMENT' const CACHE_KEY_OS_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_ENVIRONMENT'
@@ -32,23 +26,23 @@ export function isCacheDisabled(): boolean {
if (!cache.isFeatureAvailable()) { if (!cache.isFeatureAvailable()) {
return true return true
} }
return core.getBooleanInput(CACHE_DISABLED_PARAMETER) return params.isCacheDisabled()
} }
export function isCacheReadOnly(): boolean { export function isCacheReadOnly(): boolean {
return !isCacheWriteOnly() && core.getBooleanInput(CACHE_READONLY_PARAMETER) return !isCacheWriteOnly() && params.isCacheReadOnly()
} }
export function isCacheWriteOnly(): boolean { export function isCacheWriteOnly(): boolean {
return core.getBooleanInput(CACHE_WRITEONLY_PARAMETER) return params.isCacheWriteOnly()
} }
export function isCacheDebuggingEnabled(): boolean { export function isCacheDebuggingEnabled(): boolean {
return process.env[CACHE_DEBUG_VAR] ? true : false return params.isCacheDebuggingEnabled()
} }
export function isCacheCleanupEnabled(): boolean { export function isCacheCleanupEnabled(): boolean {
return core.getBooleanInput(CACHE_CLEANUP_ENABLED_PARAMETER) return params.isCacheCleanupEnabled()
} }
/** /**
@@ -97,7 +91,7 @@ export function generateCacheKey(cacheName: string): CacheKey {
// Exact match on Git SHA // Exact match on Git SHA
const cacheKey = `${cacheKeyForJobContext}-${getCacheKeyJobExecution()}` const cacheKey = `${cacheKeyForJobContext}-${getCacheKeyJobExecution()}`
if (core.getBooleanInput(STRICT_CACHE_MATCH_PARAMETER)) { if (params.isCacheStrictMatch()) {
return new CacheKey(cacheKey, [cacheKeyForJobContext]) return new CacheKey(cacheKey, [cacheKeyForJobContext])
} }
@@ -115,8 +109,7 @@ function getCacheKeyEnvironment(): string {
} }
function getCacheKeyJob(): string { function getCacheKeyJob(): string {
// Prefix can be used to force change all cache keys (defaults to cache protocol version) return process.env[CACHE_KEY_JOB_VAR] || `${github.context.workflow}-${github.context.job}`
return process.env[CACHE_KEY_JOB_VAR] || github.context.job
} }
function getCacheKeyJobInstance(): string { function getCacheKeyJobInstance(): string {
@@ -127,7 +120,7 @@ function getCacheKeyJobInstance(): string {
// By default, we hash the full `matrix` data for the run, to uniquely identify this job invocation // By default, we hash the full `matrix` data for the run, to uniquely identify this job invocation
// The only way we can obtain the `matrix` data is via the `workflow-job-context` parameter in action.yml. // The only way we can obtain the `matrix` data is via the `workflow-job-context` parameter in action.yml.
const workflowJobContext = core.getInput(JOB_CONTEXT_PARAMETER) const workflowJobContext = params.getJobContext()
return hashStrings([workflowJobContext]) return hashStrings([workflowJobContext])
} }

View File

@@ -0,0 +1,24 @@
import * as core from '@actions/core'
import * as provisioner from './provision'
import * as dependencyGraph from './dependency-graph'
/**
* The main entry point for the action, called by Github Actions for the step.
*/
export async function run(): Promise<void> {
try {
// Download and install Gradle if required
const executable = await provisioner.provisionGradle()
// Generate and upload dependency graph artifact
await dependencyGraph.generateDependencyGraph(executable)
} catch (error) {
core.setFailed(String(error))
if (error instanceof Error && error.stack) {
core.info(error.stack)
}
}
}
run()

View File

@@ -0,0 +1,16 @@
import * as core from '@actions/core'
import * as dependencyGraph from './dependency-graph'
export async function run(): Promise<void> {
try {
// Retrieve the dependency graph artifact and submit via Dependency Submission API
await dependencyGraph.submitDependencyGraph()
} catch (error) {
core.setFailed(String(error))
if (error instanceof Error && error.stack) {
core.info(error.stack)
}
}
}
run()

155
src/dependency-graph.ts Normal file
View File

@@ -0,0 +1,155 @@
import * as core from '@actions/core'
import * as artifact from '@actions/artifact'
import * as github from '@actions/github'
import * as glob from '@actions/glob'
import * as toolCache from '@actions/tool-cache'
import {Octokit} from '@octokit/rest'
import * as path from 'path'
import fs from 'fs'
import * as execution from './execution'
import * as layout from './repository-layout'
const DEPENDENCY_GRAPH_ARTIFACT = 'dependency-graph'
const DEPENDENCY_GRAPH_FILE = 'dependency-graph.json'
export async function generateDependencyGraph(executable: string | undefined): Promise<void> {
const workspaceDirectory = layout.workspaceDirectory()
const buildRootDirectory = layout.buildRootDirectory()
const buildPath = getRelativePathFromWorkspace(buildRootDirectory)
const initScript = path.resolve(
__dirname,
'..',
'..',
'src',
'resources',
'init-scripts',
'github-dependency-graph.init.gradle'
)
const args = [
`-Dorg.gradle.github.env.GRADLE_BUILD_PATH=${buildPath}`,
'--init-script',
initScript,
':GitHubDependencyGraphPlugin_generateDependencyGraph'
]
await execution.executeGradleBuild(executable, buildRootDirectory, args)
const dependencyGraphJson = copyDependencyGraphToBuildRoot(buildRootDirectory)
const artifactClient = artifact.create()
artifactClient.uploadArtifact(DEPENDENCY_GRAPH_ARTIFACT, [dependencyGraphJson], workspaceDirectory)
}
function copyDependencyGraphToBuildRoot(buildRootDirectory: string): string {
const sourceFile = path.resolve(
buildRootDirectory,
'build',
'reports',
'github-dependency-graph-plugin',
'github-dependency-snapshot.json'
)
const destFile = path.resolve(buildRootDirectory, DEPENDENCY_GRAPH_FILE)
fs.copyFileSync(sourceFile, destFile)
return destFile
}
export async function submitDependencyGraph(): Promise<void> {
const workspaceDirectory = layout.workspaceDirectory()
const octokit: Octokit = getOctokit()
for (const jsonFile of await retrieveDependencyGraphs(octokit, workspaceDirectory)) {
const jsonContent = fs.readFileSync(jsonFile, 'utf8')
const jsonObject = JSON.parse(jsonContent)
jsonObject.owner = github.context.repo.owner
jsonObject.repo = github.context.repo.repo
const response = await octokit.request('POST /repos/{owner}/{repo}/dependency-graph/snapshots', jsonObject)
const relativeJsonFile = getRelativePathFromWorkspace(jsonFile)
core.info(`Submitted ${relativeJsonFile}: ${JSON.stringify(response)}`)
core.notice(`Submitted ${relativeJsonFile}: ${response.data.message}`)
}
}
async function findDependencyGraphFiles(dir: string): Promise<string[]> {
const globber = await glob.create(`${dir}/**/${DEPENDENCY_GRAPH_FILE}`)
const graphFiles = globber.glob()
core.info(`Found graph files in ${dir}: ${graphFiles}`)
return graphFiles
}
async function retrieveDependencyGraphs(octokit: Octokit, workspaceDirectory: string): Promise<string[]> {
if (github.context.payload.workflow_run) {
return await retrieveDependencyGraphsForWorkflowRun(
github.context.payload.workflow_run.id,
octokit,
workspaceDirectory
)
}
return retrieveDependencyGraphsForCurrentWorkflow(workspaceDirectory)
}
async function retrieveDependencyGraphsForWorkflowRun(
runId: number,
octokit: Octokit,
workspaceDirectory: string
): Promise<string[]> {
// Find the workflow run artifacts named "dependency-graph"
const artifacts = await octokit.rest.actions.listWorkflowRunArtifacts({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
run_id: runId
})
const matchArtifact = artifacts.data.artifacts.find(candidate => {
return candidate.name === DEPENDENCY_GRAPH_ARTIFACT
})
if (matchArtifact === undefined) {
throw new Error(`Dependency graph artifact not found. Has it been generated by workflow run '${runId}'?`)
}
// Download the dependency-graph artifact
const download = await octokit.rest.actions.downloadArtifact({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip'
})
const downloadBuffer = download.data as ArrayBuffer
const downloadZip = path.resolve(workspaceDirectory, 'dependency-graph.zip')
fs.writeFileSync(downloadZip, Buffer.from(downloadBuffer))
// Expance the dependency-graph zip and locate each dependency-graph JSON file
const extractDir = path.resolve(workspaceDirectory, 'dependency-graph')
const extracted = await toolCache.extractZip(downloadZip, extractDir)
core.info(`Extracted dependency graph artifacts to ${extracted}: ${fs.readdirSync(extracted)}`)
return findDependencyGraphFiles(extracted)
}
async function retrieveDependencyGraphsForCurrentWorkflow(workspaceDirectory: string): Promise<string[]> {
const artifactClient = artifact.create()
const downloadPath = path.resolve(workspaceDirectory, 'dependency-graph')
await artifactClient.downloadArtifact(DEPENDENCY_GRAPH_ARTIFACT, downloadPath)
return await findDependencyGraphFiles(downloadPath)
}
function getOctokit(): Octokit {
return new Octokit({
auth: getGithubToken()
})
}
function getGithubToken(): string {
return core.getInput('github-token', {required: true})
}
function getRelativePathFromWorkspace(file: string): string {
const workspaceDirectory = layout.workspaceDirectory()
return path.relative(workspaceDirectory, file)
}

77
src/input-params.ts Normal file
View File

@@ -0,0 +1,77 @@
import * as core from '@actions/core'
import {parseArgsStringToArgv} from 'string-argv'
export function isCacheDisabled(): boolean {
return getBooleanInput('cache-disabled')
}
export function isCacheReadOnly(): boolean {
return getBooleanInput('cache-read-only')
}
export function isCacheWriteOnly(): boolean {
return getBooleanInput('cache-write-only')
}
export function isCacheStrictMatch(): boolean {
return getBooleanInput('gradle-home-cache-strict-match')
}
export function isCacheDebuggingEnabled(): boolean {
return process.env['GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED'] ? true : false
}
export function isCacheCleanupEnabled(): boolean {
return getBooleanInput('gradle-home-cache-cleanup')
}
export function getCacheIncludes(): string[] {
return core.getMultilineInput('gradle-home-cache-includes')
}
export function getCacheExcludes(): string[] {
return core.getMultilineInput('gradle-home-cache-excludes')
}
export function getBuildRootDirectory(): string {
return core.getInput('build-root-directory')
}
export function getGradleVersion(): string {
return core.getInput('gradle-version')
}
export function getGradleExecutable(): string {
return core.getInput('gradle-executable')
}
export function getArguments(): string[] {
const input = core.getInput('arguments')
return parseArgsStringToArgv(input)
}
// Internal parameters
export function getJobContext(): string {
return core.getInput('workflow-job-context')
}
export function getGithubToken(): string {
return core.getInput('github-token', {required: true})
}
export function isJobSummaryEnabled(): boolean {
return getBooleanInput('generate-job-summary', true)
}
function getBooleanInput(paramName: string, paramDefault = false): boolean {
const paramValue = core.getInput(paramName)
switch (paramValue.toLowerCase().trim()) {
case '':
return paramDefault
case 'false':
return false
case 'true':
return true
}
throw TypeError(`The value '${paramValue} is not valid for '${paramName}. Valid values are: [true, false]`)
}

View File

@@ -1,30 +1,26 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import * as path from 'path'
import {parseArgsStringToArgv} from 'string-argv'
import * as setupGradle from './setup-gradle' import * as setupGradle from './setup-gradle'
import * as execution from './execution' import * as execution from './execution'
import * as provision from './provision' import * as provisioner from './provision'
import * as layout from './repository-layout'
import * as params from './input-params'
/** /**
* The main entry point for the action, called by Github Actions for the step. * The main entry point for the action, called by Github Actions for the step.
*/ */
export async function run(): Promise<void> { export async function run(): Promise<void> {
try { try {
const workspaceDirectory = process.env[`GITHUB_WORKSPACE`] || '' // Configure Gradle environment (Gradle User Home)
const buildRootDirectory = resolveBuildRootDirectory(workspaceDirectory) await setupGradle.setup()
await setupGradle.setup(buildRootDirectory) // Download and install Gradle if required
const executable = await provisioner.provisionGradle()
const executable = await provisionGradle(workspaceDirectory)
// executable will be undefined if using Gradle wrapper
if (executable !== undefined) {
core.addPath(path.dirname(executable))
}
// Only execute if arguments have been provided // Only execute if arguments have been provided
const args: string[] = parseCommandLineArguments() const args: string[] = params.getArguments()
if (args.length > 0) { if (args.length > 0) {
const buildRootDirectory = layout.buildRootDirectory()
await execution.executeGradleBuild(executable, buildRootDirectory, args) await execution.executeGradleBuild(executable, buildRootDirectory, args)
} }
} catch (error) { } catch (error) {
@@ -36,29 +32,3 @@ export async function run(): Promise<void> {
} }
run() run()
async function provisionGradle(workspaceDirectory: string): Promise<string | undefined> {
const gradleVersion = core.getInput('gradle-version')
if (gradleVersion !== '' && gradleVersion !== 'wrapper') {
return path.resolve(await provision.gradleVersion(gradleVersion))
}
const gradleExecutable = core.getInput('gradle-executable')
if (gradleExecutable !== '') {
return path.resolve(workspaceDirectory, gradleExecutable)
}
return undefined
}
function resolveBuildRootDirectory(baseDirectory: string): string {
const buildRootDirectory = core.getInput('build-root-directory')
const resolvedBuildRootDirectory =
buildRootDirectory === '' ? path.resolve(baseDirectory) : path.resolve(baseDirectory, buildRootDirectory)
return resolvedBuildRootDirectory
}
function parseCommandLineArguments(): string[] {
const input = core.getInput('arguments')
return parseArgsStringToArgv(input)
}

View File

@@ -7,14 +7,37 @@ import * as cache from '@actions/cache'
import * as toolCache from '@actions/tool-cache' import * as toolCache from '@actions/tool-cache'
import * as gradlew from './gradlew' import * as gradlew from './gradlew'
import * as params from './input-params'
import * as layout from './repository-layout'
import {handleCacheFailure, isCacheDisabled, isCacheReadOnly} from './cache-utils' import {handleCacheFailure, isCacheDisabled, isCacheReadOnly} from './cache-utils'
const gradleVersionsBaseUrl = 'https://services.gradle.org/versions' const gradleVersionsBaseUrl = 'https://services.gradle.org/versions'
/** /**
* @return Gradle executable path * 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 gradleVersion(version: string): Promise<string> { export async function provisionGradle(): Promise<string | undefined> {
const gradleVersion = params.getGradleVersion()
if (gradleVersion !== '' && gradleVersion !== 'wrapper') {
return addToPath(path.resolve(await installGradle(gradleVersion)))
}
const gradleExecutable = params.getGradleExecutable()
if (gradleExecutable !== '') {
const workspaceDirectory = layout.workspaceDirectory()
return addToPath(path.resolve(workspaceDirectory, gradleExecutable))
}
return undefined
}
async function addToPath(executable: string): Promise<string> {
core.addPath(path.dirname(executable))
return executable
}
async function installGradle(version: string): Promise<string> {
switch (version) { switch (version) {
case 'current': case 'current':
return gradleCurrent() return gradleCurrent()
@@ -34,13 +57,13 @@ export async function gradleVersion(version: string): Promise<string> {
async function gradleCurrent(): Promise<string> { async function gradleCurrent(): Promise<string> {
const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/current`) const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/current`)
return provisionGradle(versionInfo) return installGradleVersion(versionInfo)
} }
async function gradleReleaseCandidate(): Promise<string> { async function gradleReleaseCandidate(): Promise<string> {
const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-candidate`) const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-candidate`)
if (versionInfo && versionInfo.version && versionInfo.downloadUrl) { if (versionInfo && versionInfo.version && versionInfo.downloadUrl) {
return provisionGradle(versionInfo) return installGradleVersion(versionInfo)
} }
core.info('No current release-candidate found, will fallback to current') core.info('No current release-candidate found, will fallback to current')
return gradleCurrent() return gradleCurrent()
@@ -48,12 +71,12 @@ async function gradleReleaseCandidate(): Promise<string> {
async function gradleNightly(): Promise<string> { async function gradleNightly(): Promise<string> {
const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/nightly`) const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/nightly`)
return provisionGradle(versionInfo) return installGradleVersion(versionInfo)
} }
async function gradleReleaseNightly(): Promise<string> { async function gradleReleaseNightly(): Promise<string> {
const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-nightly`) const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-nightly`)
return provisionGradle(versionInfo) return installGradleVersion(versionInfo)
} }
async function gradle(version: string): Promise<string> { async function gradle(version: string): Promise<string> {
@@ -61,7 +84,7 @@ async function gradle(version: string): Promise<string> {
if (!versionInfo) { if (!versionInfo) {
throw new Error(`Gradle version ${version} does not exists`) throw new Error(`Gradle version ${version} does not exists`)
} }
return provisionGradle(versionInfo) return installGradleVersion(versionInfo)
} }
async function gradleVersionDeclaration(url: string): Promise<GradleVersionInfo> { async function gradleVersionDeclaration(url: string): Promise<GradleVersionInfo> {
@@ -75,7 +98,7 @@ async function findGradleVersionDeclaration(version: string): Promise<GradleVers
}) })
} }
async function provisionGradle(versionInfo: GradleVersionInfo): Promise<string> { async function installGradleVersion(versionInfo: GradleVersionInfo): Promise<string> {
return core.group(`Provision Gradle ${versionInfo.version}`, async () => { return core.group(`Provision Gradle ${versionInfo.version}`, async () => {
return locateGradleAndDownloadIfRequired(versionInfo) return locateGradleAndDownloadIfRequired(versionInfo)
}) })

16
src/repository-layout.ts Normal file
View File

@@ -0,0 +1,16 @@
import * as params from './input-params'
import * as path from 'path'
export function workspaceDirectory(): string {
return process.env[`GITHUB_WORKSPACE`] || ''
}
export function buildRootDirectory(): string {
const baseDirectory = workspaceDirectory()
const buildRootDirectoryInput = params.getBuildRootDirectory()
const resolvedBuildRootDirectory =
buildRootDirectoryInput === ''
? path.resolve(baseDirectory)
: path.resolve(baseDirectory, buildRootDirectoryInput)
return resolvedBuildRootDirectory
}

View File

@@ -16,26 +16,29 @@ if (isTopLevelBuild) {
if (atLeastGradle6) { if (atLeastGradle6) {
def useBuildService = version >= GradleVersion.version("6.6") def useBuildService = version >= GradleVersion.version("6.6")
settingsEvaluated { settings -> settingsEvaluated { settings ->
// The `buildScanPublished` hook is the only way to capture the build scan URI. // By default, use standard mechanisms to capture build results
if (settings.pluginManager.hasPlugin("com.gradle.enterprise")) {
captureUsingBuildScanPublished(settings.extensions["gradleEnterprise"].buildScan, settings.rootProject, invocationId)
}
// We also need to add hooks in case the plugin is applied but no build scan is published
// The `buildScanPublished` results will NOT be overwritten by these calls
if (useBuildService) { if (useBuildService) {
captureUsingBuildService(settings, invocationId) captureUsingBuildService(settings, invocationId)
} else { } else {
captureUsingBuildFinished(gradle, invocationId) captureUsingBuildFinished(gradle, invocationId)
} }
// The `buildScanPublished` hook allows the capture of the build scan URI.
// Results captured this way will overwrite any results from the other mechanism.
settings.pluginManager.withPlugin("com.gradle.enterprise") {
captureUsingBuildScanPublished(settings.extensions["gradleEnterprise"].buildScan, settings.rootProject, invocationId)
}
} }
} else if (atLeastGradle3) { } else if (atLeastGradle3) {
projectsEvaluated { gradle -> projectsEvaluated { gradle ->
if (gradle.rootProject.pluginManager.hasPlugin("com.gradle.build-scan")) { // By default, use 'buildFinished' to capture build results
captureUsingBuildFinished(gradle, invocationId)
// The `buildScanPublished` hook allows the capture of the build scan URI.
// Results captured this way will overwrite any results from 'buildFinished'.
gradle.rootProject.pluginManager.withPlugin("com.gradle.build-scan") {
captureUsingBuildScanPublished(gradle.rootProject.extensions["buildScan"], gradle.rootProject, invocationId) captureUsingBuildScanPublished(gradle.rootProject.extensions["buildScan"], gradle.rootProject, invocationId)
} }
// Always attempt to capture in buildFinished in case the plugin is applied but no build scan is published
// The `buildScanPublished` results will NOT be overwritten by this call
captureUsingBuildFinished(gradle, invocationId)
} }
} }
} }
@@ -70,6 +73,7 @@ def captureUsingBuildScanPublished(buildScanExtension, rootProject, invocationId
def captureUsingBuildFinished(gradle, invocationId) { def captureUsingBuildFinished(gradle, invocationId) {
gradle.buildFinished { result -> gradle.buildFinished { result ->
println "Got buildFinished: ${result}"
def buildResults = new BuildResults(invocationId, gradle, gradle.rootProject) def buildResults = new BuildResults(invocationId, gradle, gradle.rootProject)
buildResults.setBuildResult(result) buildResults.setBuildResult(result)
buildResults.writeToResultsFile(false) buildResults.writeToResultsFile(false)

View File

@@ -0,0 +1,12 @@
import org.gradle.github.GitHubDependencyGraphPlugin
initscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("org.gradle:github-dependency-graph-gradle-plugin:+")
}
}
apply plugin: GitHubDependencyGraphPlugin

View File

@@ -4,6 +4,8 @@ import {SUMMARY_ENV_VAR} from '@actions/core/lib/summary'
import * as path from 'path' import * as path from 'path'
import * as os from 'os' import * as os from 'os'
import * as caches from './caches' import * as caches from './caches'
import * as layout from './repository-layout'
import * as params from './input-params'
import {logJobSummary, writeJobSummary} from './job-summary' import {logJobSummary, writeJobSummary} from './job-summary'
import {loadBuildResults} from './build-results' import {loadBuildResults} from './build-results'
@@ -13,19 +15,9 @@ import {DaemonController} from './daemon-controller'
const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED' const GRADLE_SETUP_VAR = 'GRADLE_BUILD_ACTION_SETUP_COMPLETED'
const GRADLE_USER_HOME = 'GRADLE_USER_HOME' const GRADLE_USER_HOME = 'GRADLE_USER_HOME'
const CACHE_LISTENER = 'CACHE_LISTENER' const CACHE_LISTENER = 'CACHE_LISTENER'
const JOB_SUMMARY_ENABLED_PARAMETER = 'generate-job-summary'
function shouldGenerateJobSummary(): boolean { export async function setup(): Promise<void> {
// Check if Job Summary is supported on this platform const gradleUserHome = await determineGradleUserHome()
if (!process.env[SUMMARY_ENV_VAR]) {
return false
}
return core.getBooleanInput(JOB_SUMMARY_ENABLED_PARAMETER)
}
export async function setup(buildRootDirectory: string): Promise<void> {
const gradleUserHome = await determineGradleUserHome(buildRootDirectory)
// Bypass setup on all but first action step in workflow. // Bypass setup on all but first action step in workflow.
if (process.env[GRADLE_SETUP_VAR]) { if (process.env[GRADLE_SETUP_VAR]) {
@@ -68,9 +60,10 @@ export async function complete(): Promise<void> {
} }
} }
async function determineGradleUserHome(rootDir: string): Promise<string> { async function determineGradleUserHome(): Promise<string> {
const customGradleUserHome = process.env['GRADLE_USER_HOME'] const customGradleUserHome = process.env['GRADLE_USER_HOME']
if (customGradleUserHome) { if (customGradleUserHome) {
const rootDir = layout.workspaceDirectory()
return path.resolve(rootDir, customGradleUserHome) return path.resolve(rootDir, customGradleUserHome)
} }
@@ -93,3 +86,12 @@ async function determineUserHome(): Promise<string> {
core.debug(`Determined user.home from java -version output: '${userHome}'`) core.debug(`Determined user.home from java -version output: '${userHome}'`)
return userHome return userHome
} }
function shouldGenerateJobSummary(): boolean {
// Check if Job Summary is supported on this platform
if (!process.env[SUMMARY_ENV_VAR]) {
return false
}
return params.isJobSummaryEnabled()
}

View File

@@ -20,8 +20,7 @@ dependencies {
testImplementation ('io.ratpack:ratpack-groovy-test:1.9.0') { testImplementation ('io.ratpack:ratpack-groovy-test:1.9.0') {
exclude group: 'org.codehaus.groovy', module: 'groovy-all' exclude group: 'org.codehaus.groovy', module: 'groovy-all'
} }
testImplementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-smile:2.14.2' testImplementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-smile:2.15.2'
} }
test { test {

View File

@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip distributionSha256Sum=e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,10 @@ do
esac esac
done done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # This is normally unused
# shellcheck disable=SC2034
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@@ -143,12 +140,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
case $MAX_FD in #( case $MAX_FD in #(
'' | soft) :;; #( '' | soft) :;; #(
*) *)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
@@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done done
fi fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command; # Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in # shell script including quotes and variable substitutions, so put them in
@@ -205,6 +210,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \ org.gradle.wrapper.GradleWrapperMain \
"$@" "$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args. # Use "xargs" to parse quoted args.
# #
# With -n1 it outputs one arg per line, with the quotes and backslashes removed. # With -n1 it outputs one arg per line, with the quotes and backslashes removed.

View File

@@ -14,7 +14,7 @@
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute if %ERRORLEVEL% equ 0 goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if %ERRORLEVEL% equ 0 goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 set EXIT_CODE=%ERRORLEVEL%
exit /b 1 if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal

View File

@@ -1,6 +1,6 @@
plugins { plugins {
id "com.gradle.enterprise" version "3.12.6" id "com.gradle.enterprise" version "3.13.4"
id "com.gradle.common-custom-user-data-gradle-plugin" version "1.10" id "com.gradle.common-custom-user-data-gradle-plugin" version "1.11"
} }
gradleEnterprise { gradleEnterprise {

View File

@@ -38,6 +38,9 @@ class BaseInitScriptTest extends Specification {
static final List<TestGradleVersion> CONFIGURATION_CACHE_VERSIONS = static final List<TestGradleVersion> CONFIGURATION_CACHE_VERSIONS =
[GRADLE_7_X, GRADLE_8_X] [GRADLE_7_X, GRADLE_8_X]
static final List<TestGradleVersion> SETTINGS_PLUGIN_VERSIONS =
[GRADLE_6_X, GRADLE_7_X, GRADLE_8_X]
static final String PUBLIC_BUILD_SCAN_ID = 'i2wepy2gr7ovw' static final String PUBLIC_BUILD_SCAN_ID = 'i2wepy2gr7ovw'
static final String DEFAULT_SCAN_UPLOAD_TOKEN = 'scan-upload-token' static final String DEFAULT_SCAN_UPLOAD_TOKEN = 'scan-upload-token'
static final String ROOT_PROJECT_NAME = 'test-init-script' static final String ROOT_PROJECT_NAME = 'test-init-script'
@@ -134,7 +137,7 @@ class BaseInitScriptTest extends Specification {
} else { } else {
""" """
plugins { plugins {
id 'com.gradle.enterprise' version '3.12.6' id 'com.gradle.enterprise' version '3.13.4'
} }
gradleEnterprise { gradleEnterprise {
server = '$mockScansServer.address' server = '$mockScansServer.address'
@@ -160,7 +163,7 @@ class BaseInitScriptTest extends Specification {
} else if (gradleVersion < GradleVersion.version('6.0')) { } else if (gradleVersion < GradleVersion.version('6.0')) {
""" """
plugins { plugins {
id 'com.gradle.build-scan' version '3.12.6' id 'com.gradle.build-scan' version '3.13.4'
} }
gradleEnterprise { gradleEnterprise {
server = '$mockScansServer.address' server = '$mockScansServer.address'

View File

@@ -148,6 +148,34 @@ class TestBuildResultRecorder extends BaseInitScriptTest {
testGradleVersion << ALL_VERSIONS testGradleVersion << ALL_VERSIONS
} }
def "produces build results file with build scan when GE plugin is applied in settingsEvaluated"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm
when:
settingsFile.text = """
plugins {
id 'com.gradle.enterprise' version '3.13.4' apply(false)
}
gradle.settingsEvaluated {
apply plugin: 'com.gradle.enterprise'
gradleEnterprise {
server = '$mockScansServer.address'
buildScan {
publishAlways()
}
}
}
""" + settingsFile.text
run(['help'], initScript, testGradleVersion.gradleVersion)
then:
assertResults('help', testGradleVersion, false, true)
where:
testGradleVersion << SETTINGS_PLUGIN_VERSIONS
}
void assertResults(String task, TestGradleVersion testGradleVersion, boolean hasFailure, boolean hasBuildScan, boolean scanUploadFailed = false) { void assertResults(String task, TestGradleVersion testGradleVersion, boolean hasFailure, boolean hasBuildScan, boolean scanUploadFailed = false) {
def results = new JsonSlurper().parse(buildResultFile) def results = new JsonSlurper().parse(buildResultFile)
assert results['rootProjectName'] == ROOT_PROJECT_NAME assert results['rootProjectName'] == ROOT_PROJECT_NAME

View File

@@ -47,18 +47,18 @@ test('will cleanup unused gradle versions', async () => {
// Run with only one of these versions // Run with only one of these versions
await runGradleBuild(projectRoot, 'build') await runGradleBuild(projectRoot, 'build')
const gradle733 = path.resolve(gradleUserHome, "caches/7.3.3") const gradle802 = path.resolve(gradleUserHome, "caches/8.0.2")
const wrapper733 = path.resolve(gradleUserHome, "wrapper/dists/gradle-7.3.3-bin") const wrapper802 = path.resolve(gradleUserHome, "wrapper/dists/gradle-8.0.2-bin")
const gradleCurrent = path.resolve(gradleUserHome, "caches/7.6.1") const gradleCurrent = path.resolve(gradleUserHome, "caches/8.1.1")
expect(fs.existsSync(gradle733)).toBe(true) expect(fs.existsSync(gradle802)).toBe(true)
expect(fs.existsSync(wrapper733)).toBe(true) expect(fs.existsSync(wrapper802)).toBe(true)
expect(fs.existsSync(gradleCurrent)).toBe(true) expect(fs.existsSync(gradleCurrent)).toBe(true)
await cacheCleaner.forceCleanup() await cacheCleaner.forceCleanup()
expect(fs.existsSync(gradle733)).toBe(false) expect(fs.existsSync(gradle802)).toBe(false)
expect(fs.existsSync(wrapper733)).toBe(false) expect(fs.existsSync(wrapper802)).toBe(false)
expect(fs.existsSync(gradleCurrent)).toBe(true) expect(fs.existsSync(gradleCurrent)).toBe(true)
}) })

View File

@@ -1,7 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
# Deliberately not using the latest Gradle version for cache cleanup testing # Deliberately not using the latest Gradle version for cache cleanup testing
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,10 @@ do
esac esac
done done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # This is normally unused
# shellcheck disable=SC2034
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@@ -143,12 +140,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
case $MAX_FD in #( case $MAX_FD in #(
'' | soft) :;; #( '' | soft) :;; #(
*) *)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
@@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done done
fi fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command; # Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in # shell script including quotes and variable substitutions, so put them in
@@ -205,6 +210,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \ org.gradle.wrapper.GradleWrapperMain \
"$@" "$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args. # Use "xargs" to parse quoted args.
# #
# With -n1 it outputs one arg per line, with the quotes and backslashes removed. # With -n1 it outputs one arg per line, with the quotes and backslashes removed.

View File

@@ -14,7 +14,7 @@
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute if %ERRORLEVEL% equ 0 goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if %ERRORLEVEL% equ 0 goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 set EXIT_CODE=%ERRORLEVEL%
exit /b 1 if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal