mirror of
https://github.com/gradle/actions.git
synced 2026-11-22 13:59:40 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c36ba1fb3d |
No files matched your search
@@ -3,7 +3,7 @@ name: 'Build and upload distribution'
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
@@ -23,7 +23,7 @@ runs:
|
||||
cp -r sources/dist .
|
||||
|
||||
- name: Upload distribution
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: dist
|
||||
path: dist/
|
||||
@@ -22,14 +22,14 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
cache-dependency-path: sources/package-lock.json
|
||||
- name: Setup Gradle
|
||||
# Use a released version to avoid breakages
|
||||
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
|
||||
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
|
||||
env:
|
||||
ALLOWED_GRADLE_WRAPPER_CHECKSUMS: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 # Invalid wrapper jar used for testing
|
||||
with:
|
||||
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v3.29.5
|
||||
uses: github/codeql-action/init@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v3.29.5
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
config: |
|
||||
@@ -43,4 +43,4 @@ jobs:
|
||||
- sources/src
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v3.29.5
|
||||
uses: github/codeql-action/analyze@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v3.29.5
|
||||
@@ -36,14 +36,14 @@ jobs:
|
||||
sources/test/init-scripts/**
|
||||
- name: Setup Java
|
||||
if: steps.changes.outputs.any_changed == 'true' || github.event_name != 'pull_request'
|
||||
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
|
||||
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
- name: Setup Gradle
|
||||
if: steps.changes.outputs.any_changed == 'true' || github.event_name != 'pull_request'
|
||||
# Use a released version to avoid breakages
|
||||
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
|
||||
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
|
||||
env:
|
||||
ALLOWED_GRADLE_WRAPPER_CHECKSUMS: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 # Invalid wrapper jar used for testing
|
||||
- name: Run integration tests
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
show-progress: false
|
||||
|
||||
- name: 'Run analysis'
|
||||
uses: ossf/scorecard-action@fa7117db83c52d787ae5a89f350999701505d78e # v2.5.0
|
||||
uses: ossf/scorecard-action@2d1146689b8cda280b9bc96326124645441f03bc # v2.4.4
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
@@ -44,7 +44,7 @@ jobs:
|
||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||
# format to the repository Actions tab.
|
||||
- name: 'Upload artifact'
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
token: ${{ secrets.BOT_GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
@@ -92,7 +92,7 @@ jobs:
|
||||
# Important: The push event will not trigger any other workflows, see
|
||||
# https://github.com/stefanzweifel/git-auto-commit-action?tab=readme-ov-file#commits-made-by-this-action-do-not-trigger-new-workflow-runs
|
||||
- name: Commit & push changes
|
||||
uses: stefanzweifel/git-auto-commit-action@d0b01107b5db882071f96de5dd4b54961ea93f4c # v7.2.1
|
||||
uses: stefanzweifel/git-auto-commit-action@4a55954c782fc1ea30b9056cd3e7a2b40ca8887d # v7.2.0
|
||||
with:
|
||||
commit_author: bot-githubaction <[email protected]>
|
||||
commit_user_name: bot-githubaction
|
||||
|
||||
@@ -12,6 +12,6 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: gradle/actions/wrapper-validation@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
|
||||
- uses: gradle/actions/wrapper-validation@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
|
||||
with:
|
||||
allow-checksums: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
@@ -118,7 +118,7 @@ jobs:
|
||||
|
||||
# Gradle 9 and later require Java 17
|
||||
- name: Setup Java 17
|
||||
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
|
||||
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
|
||||
@@ -178,7 +178,7 @@ jobs:
|
||||
runs-on: "ubuntu-latest"
|
||||
steps:
|
||||
- name: Download dependency-graph artifact
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
path: downloaded-dependency-graphs
|
||||
pattern: dependency-graph_*dependency-graph-generate-submit-and-upload.json
|
||||
|
||||
@@ -64,14 +64,14 @@ jobs:
|
||||
uses: ./.github/actions/init-integ-test
|
||||
|
||||
- name: Setup Java 16
|
||||
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
|
||||
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 16
|
||||
# Temurin 16 is EOL and publishes no signatures: setup-java v6 enables verify-signature by default
|
||||
verify-signature: false
|
||||
- name: Setup Java 20
|
||||
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
|
||||
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 20
|
||||
|
||||
@@ -56,7 +56,7 @@ jobs:
|
||||
run: gradle help "-DgradleVersionCheck=7.1.1"
|
||||
# Configure JDK 17 for Gradle 9 and later
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
|
||||
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
@@ -110,7 +110,7 @@ jobs:
|
||||
uses: ./.github/actions/init-integ-test
|
||||
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
|
||||
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: ${{ matrix.java-version }}
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: npm
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
|
||||
# If there are no changes, this action will not create a pull request
|
||||
- name: Create or update pull request
|
||||
uses: peter-evans/create-pull-request@3ffccacd46053766916f087ce41d627c0b8cf2d1 # v8.1.3
|
||||
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
|
||||
with:
|
||||
branch: bot/wrapper-checksums-update
|
||||
author: bot-githubaction <[email protected]>
|
||||
|
||||
+80
-13
@@ -431,6 +431,8 @@ As well as reducing the content that needs to be saved to the GitHub Actions cac
|
||||
this setup will ensure that your CI builds populate the remote cache and keep the cache entries fresh by reading these entries.
|
||||
Local builds can then benefit from the remote cache.
|
||||
|
||||
If your build uses Develocity, `setup-gradle` can apply this setup for you with [Develocity injection](#configuring-the-build-cache-with-develocity-injection).
|
||||
|
||||
## Basic Caching
|
||||
|
||||
Basic Caching is an open-source (MIT) alternative that uses `@actions/cache` to provide straightforward, path-based caching of Gradle dependencies. It uses the same caching strategy as `actions/setup-java` with `cache: gradle`.
|
||||
@@ -979,20 +981,20 @@ This access key will be used during the action execution to get a short-lived to
|
||||
|
||||
### Configuring Develocity injection
|
||||
|
||||
The `init-script` supports several additional configuration parameters that you may find useful. All configuration options (required and optional) are detailed below:
|
||||
The `init-script` supports several additional configuration parameters that you may find useful. These configuration options (required and optional) are detailed below:
|
||||
|
||||
| Variable | Required | Description |
|
||||
|--------------------------------------| :---: |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| develocity-injection-enabled | :white_check_mark: | enables Develocity injection |
|
||||
| develocity-url | :white_check_mark: | the URL of the Develocity server |
|
||||
| develocity-allow-untrusted-server | | allow communication with an untrusted server; set to _true_ if your Develocity instance is using a self-signed certificate |
|
||||
| develocity-capture-file-fingerprints | | enables capturing the paths and content hashes of each individual input file |
|
||||
| develocity-enforce-url | | enforce the configured Develocity URL over a URL configured in the project's build; set to _true_ to enforce publication of build scans to the configured Develocity URL |
|
||||
| develocity-plugin-version | :white_check_mark: | the version of the [Develocity Gradle plugin](https://docs.gradle.com/develocity/gradle-plugin/) to apply |
|
||||
| develocity-ccud-plugin-version | | the version of the [Common Custom User Data Gradle plugin](https://github.com/gradle/common-custom-user-data-gradle-plugin) to apply, if any |
|
||||
| gradle-plugin-repository-url | | the URL of the repository to use when resolving the Develocity and CCUD plugins; the Gradle Plugin Portal is used by default |
|
||||
| gradle-plugin-repository-username | | the username for the repository URL to use when resolving the Develocity and CCUD plugins |
|
||||
| gradle-plugin-repository-password | | the password for the repository URL to use when resolving the Develocity and CCUD plugins; Consider using secrets to pass the value to this variable |
|
||||
| Variable | Required | Description |
|
||||
|--------------------------------------| :---: |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| develocity-injection-enabled | :white_check_mark: | enables Develocity injection |
|
||||
| develocity-url | :white_check_mark: | the URL of the Develocity server |
|
||||
| develocity-allow-untrusted-server | | allow communication with an untrusted server; set to _true_ if your Develocity instance is using a self-signed certificate |
|
||||
| develocity-capture-file-fingerprints | | enables capturing the paths and content hashes of each individual input file |
|
||||
| develocity-enforce-url | | enforce the configured Develocity URL over a URL configured in the project's build; set to _true_ to enforce publication of build scans to the configured Develocity URL; a Develocity Build Cache connector without a server defined follows the enforced URL, but a server explicitly configured in the project's build is not changed |
|
||||
| develocity-plugin-version | :white_check_mark: | the version of the [Develocity Gradle plugin](https://docs.gradle.com/develocity/gradle-plugin/) to apply |
|
||||
| develocity-ccud-plugin-version | | the version of the [Common Custom User Data Gradle plugin](https://github.com/gradle/common-custom-user-data-gradle-plugin) to apply, if any |
|
||||
| gradle-plugin-repository-url | | the URL of the repository to use when resolving the Develocity and CCUD plugins; the Gradle Plugin Portal is used by default |
|
||||
| gradle-plugin-repository-username | | the username for the repository URL to use when resolving the Develocity and CCUD plugins |
|
||||
| gradle-plugin-repository-password | | the password for the repository URL to use when resolving the Develocity and CCUD plugins; Consider using secrets to pass the value to this variable |
|
||||
|
||||
The input parameters can be expressed as environment variables following the relationships outlined in the table below:
|
||||
|
||||
@@ -1026,6 +1028,71 @@ Here's an example using the env vars:
|
||||
DEVELOCITY_INJECTION_CCUD_PLUGIN_VERSION: '2.2.1'
|
||||
```
|
||||
|
||||
### Configuring the build cache with Develocity injection
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Develocity injection can configure the local and remote build caches, but it cannot enable
|
||||
> the [Gradle build cache](https://docs.gradle.org/current/userguide/build_cache.html) feature
|
||||
> itself. Enable it with `org.gradle.caching=true` in `gradle.properties` or with the
|
||||
> `--build-cache` command line option. Without it, the `setup-gradle` build cache configuration
|
||||
> has no effect.
|
||||
|
||||
Develocity injection can also configure the build cache of your build.
|
||||
The remote build cache is configured with the [Develocity Build Cache connector](https://docs.gradle.com/develocity/gradle-plugin/current/#using_build_caching), which uses the Develocity server unless another server is configured.
|
||||
The connector authenticates with the same access key the Develocity Gradle plugin uses to publish Build Scans.
|
||||
|
||||
| Input | Description |
|
||||
|-------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
|
||||
| develocity-enforce-build-cache | set to _true_ to replace a remote build cache configured in the project's build with the Develocity Build Cache connector |
|
||||
| develocity-remote-build-cache-enabled | enable the remote build cache |
|
||||
| develocity-remote-build-cache-push | store task outputs in the remote build cache |
|
||||
| develocity-remote-build-cache-server | the URL of the remote build cache server; the Develocity server is used by default |
|
||||
| develocity-remote-build-cache-path | the path of the remote build cache on the server |
|
||||
| develocity-remote-build-cache-allow-insecure-protocol | allow communication with the remote build cache over plain HTTP |
|
||||
| develocity-remote-build-cache-allow-untrusted-server | allow communication with an untrusted remote build cache server |
|
||||
| develocity-local-build-cache-enabled | enable the local build cache |
|
||||
| develocity-local-build-cache-push | store task outputs in the local build cache |
|
||||
|
||||
The input parameters can be expressed as environment variables following the relationships outlined in the table below:
|
||||
|
||||
| Input | Environment Variable |
|
||||
|-------------------------------------------------------|-----------------------------------------------------------------|
|
||||
| develocity-enforce-build-cache | DEVELOCITY_INJECTION_ENFORCE_BUILD_CACHE |
|
||||
| develocity-remote-build-cache-enabled | DEVELOCITY_INJECTION_REMOTE_BUILD_CACHE_ENABLED |
|
||||
| develocity-remote-build-cache-push | DEVELOCITY_INJECTION_REMOTE_BUILD_CACHE_PUSH |
|
||||
| develocity-remote-build-cache-server | DEVELOCITY_INJECTION_REMOTE_BUILD_CACHE_SERVER |
|
||||
| develocity-remote-build-cache-path | DEVELOCITY_INJECTION_REMOTE_BUILD_CACHE_PATH |
|
||||
| develocity-remote-build-cache-allow-insecure-protocol | DEVELOCITY_INJECTION_REMOTE_BUILD_CACHE_ALLOW_INSECURE_PROTOCOL |
|
||||
| develocity-remote-build-cache-allow-untrusted-server | DEVELOCITY_INJECTION_REMOTE_BUILD_CACHE_ALLOW_UNTRUSTED_SERVER |
|
||||
| develocity-local-build-cache-enabled | DEVELOCITY_INJECTION_LOCAL_BUILD_CACHE_ENABLED |
|
||||
| develocity-local-build-cache-push | DEVELOCITY_INJECTION_LOCAL_BUILD_CACHE_PUSH |
|
||||
|
||||
The remote build cache is only configured when `develocity-remote-build-cache-enabled` is set, and the local build cache only when `develocity-local-build-cache-enabled` is set.
|
||||
If the project's build already configures a remote build cache, the existing build cache configuration is not modified unless `develocity-enforce-build-cache` is set to _true_.
|
||||
If the remote build cache cannot be configured, the local build cache is not configured either, so a build is never left with a partial build cache configuration.
|
||||
|
||||
Build cache configuration requires Gradle 6.0 or later and the Develocity Gradle plugin 3.11 or later.
|
||||
With the configuration cache enabled, it requires Gradle 7.5.1 or later.
|
||||
Builds that do not meet these requirements keep their own build cache configuration.
|
||||
|
||||
Here's an example that has CI builds populate the remote build cache on the Develocity server and disables the local build cache:
|
||||
|
||||
```yaml
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v6
|
||||
with:
|
||||
develocity-access-key: ${{ secrets.MY_DEVELOCITY_ACCESS_KEY }}
|
||||
develocity-injection-enabled: true
|
||||
develocity-url: 'https://develocity.your-server.com'
|
||||
develocity-plugin-version: '4.0'
|
||||
develocity-remote-build-cache-enabled: true
|
||||
develocity-remote-build-cache-push: true
|
||||
develocity-local-build-cache-enabled: false
|
||||
|
||||
- name: Run a Gradle build with the Develocity remote build cache
|
||||
run: ./gradlew build --build-cache
|
||||
```
|
||||
|
||||
# Dependency verification
|
||||
|
||||
Develocity injection, Build Scan publishing and Dependency Graph generation all work by applying external plugins to your build.
|
||||
|
||||
@@ -136,6 +136,33 @@ inputs:
|
||||
develocity-ccud-plugin-version:
|
||||
type: string
|
||||
|
||||
develocity-enforce-build-cache:
|
||||
type: boolean
|
||||
|
||||
develocity-remote-build-cache-enabled:
|
||||
type: boolean
|
||||
|
||||
develocity-remote-build-cache-push:
|
||||
type: boolean
|
||||
|
||||
develocity-remote-build-cache-server:
|
||||
type: string
|
||||
|
||||
develocity-remote-build-cache-path:
|
||||
type: string
|
||||
|
||||
develocity-remote-build-cache-allow-insecure-protocol:
|
||||
type: boolean
|
||||
|
||||
develocity-remote-build-cache-allow-untrusted-server:
|
||||
type: boolean
|
||||
|
||||
develocity-local-build-cache-enabled:
|
||||
type: boolean
|
||||
|
||||
develocity-local-build-cache-push:
|
||||
type: boolean
|
||||
|
||||
gradle-plugin-repository-url:
|
||||
type: string
|
||||
|
||||
|
||||
+37
-1
@@ -174,7 +174,7 @@ inputs:
|
||||
required: false
|
||||
|
||||
develocity-enforce-url:
|
||||
description: Enforce the configured Develocity URL over a URL configured in the project's build; set to _true_ to enforce publication of build scans to the configured Develocity URL.
|
||||
description: Enforce the configured Develocity URL over a URL configured in the project's build; set to _true_ to enforce publication of build scans to the configured Develocity URL; a Develocity Build Cache connector without a server defined follows the enforced URL, but a server explicitly configured in the project's build is not changed.
|
||||
required: false
|
||||
|
||||
develocity-plugin-version:
|
||||
@@ -185,6 +185,42 @@ inputs:
|
||||
description: The version of the Common Custom User Data Gradle plugin to apply, if any.
|
||||
required: false
|
||||
|
||||
develocity-enforce-build-cache:
|
||||
description: Replace a remote build cache configured in the project's build with the Develocity Build Cache connector.
|
||||
required: false
|
||||
|
||||
develocity-remote-build-cache-enabled:
|
||||
description: Enables the remote build cache.
|
||||
required: false
|
||||
|
||||
develocity-remote-build-cache-push:
|
||||
description: Store task outputs in the remote build cache.
|
||||
required: false
|
||||
|
||||
develocity-remote-build-cache-server:
|
||||
description: The URL of the remote build cache server; the Develocity server is used by default.
|
||||
required: false
|
||||
|
||||
develocity-remote-build-cache-path:
|
||||
description: The path of the remote build cache on the server.
|
||||
required: false
|
||||
|
||||
develocity-remote-build-cache-allow-insecure-protocol:
|
||||
description: Allow communication with the remote build cache over plain HTTP.
|
||||
required: false
|
||||
|
||||
develocity-remote-build-cache-allow-untrusted-server:
|
||||
description: Allow communication with an untrusted remote build cache server.
|
||||
required: false
|
||||
|
||||
develocity-local-build-cache-enabled:
|
||||
description: Enables the local build cache.
|
||||
required: false
|
||||
|
||||
develocity-local-build-cache-push:
|
||||
description: Store task outputs in the local build cache.
|
||||
required: false
|
||||
|
||||
gradle-plugin-repository-url:
|
||||
description: The URL of the repository to use when resolving the Develocity and CCUD plugins; the Gradle Plugin Portal is used by default.
|
||||
required: false
|
||||
|
||||
@@ -312,6 +312,42 @@ export class DevelocityConfig {
|
||||
return core.getInput('develocity-ccud-plugin-version')
|
||||
}
|
||||
|
||||
getDevelocityEnforceBuildCache(): boolean | undefined {
|
||||
return getOptionalBooleanInput('develocity-enforce-build-cache')
|
||||
}
|
||||
|
||||
getDevelocityRemoteBuildCacheEnabled(): boolean | undefined {
|
||||
return getOptionalBooleanInput('develocity-remote-build-cache-enabled')
|
||||
}
|
||||
|
||||
getDevelocityRemoteBuildCachePush(): boolean | undefined {
|
||||
return getOptionalBooleanInput('develocity-remote-build-cache-push')
|
||||
}
|
||||
|
||||
getDevelocityRemoteBuildCacheServer(): string {
|
||||
return core.getInput('develocity-remote-build-cache-server')
|
||||
}
|
||||
|
||||
getDevelocityRemoteBuildCachePath(): string {
|
||||
return core.getInput('develocity-remote-build-cache-path')
|
||||
}
|
||||
|
||||
getDevelocityRemoteBuildCacheAllowInsecureProtocol(): boolean | undefined {
|
||||
return getOptionalBooleanInput('develocity-remote-build-cache-allow-insecure-protocol')
|
||||
}
|
||||
|
||||
getDevelocityRemoteBuildCacheAllowUntrustedServer(): boolean | undefined {
|
||||
return getOptionalBooleanInput('develocity-remote-build-cache-allow-untrusted-server')
|
||||
}
|
||||
|
||||
getDevelocityLocalBuildCacheEnabled(): boolean | undefined {
|
||||
return getOptionalBooleanInput('develocity-local-build-cache-enabled')
|
||||
}
|
||||
|
||||
getDevelocityLocalBuildCachePush(): boolean | undefined {
|
||||
return getOptionalBooleanInput('develocity-local-build-cache-push')
|
||||
}
|
||||
|
||||
getPluginRepository(): PluginRepositoryConfig {
|
||||
return new PluginRepositoryConfig()
|
||||
}
|
||||
|
||||
@@ -27,6 +27,39 @@ export function setup(config: DevelocityConfig): void {
|
||||
'DEVELOCITY_INJECTION_PLUGIN_REPOSITORY_PASSWORD',
|
||||
config.getPluginRepository().getPassword()
|
||||
)
|
||||
maybeExportVariableNotEmpty('DEVELOCITY_INJECTION_ENFORCE_BUILD_CACHE', config.getDevelocityEnforceBuildCache())
|
||||
maybeExportVariableNotEmpty(
|
||||
'DEVELOCITY_INJECTION_REMOTE_BUILD_CACHE_ENABLED',
|
||||
config.getDevelocityRemoteBuildCacheEnabled()
|
||||
)
|
||||
maybeExportVariableNotEmpty(
|
||||
'DEVELOCITY_INJECTION_REMOTE_BUILD_CACHE_PUSH',
|
||||
config.getDevelocityRemoteBuildCachePush()
|
||||
)
|
||||
maybeExportVariableNotEmpty(
|
||||
'DEVELOCITY_INJECTION_REMOTE_BUILD_CACHE_SERVER',
|
||||
config.getDevelocityRemoteBuildCacheServer()
|
||||
)
|
||||
maybeExportVariableNotEmpty(
|
||||
'DEVELOCITY_INJECTION_REMOTE_BUILD_CACHE_PATH',
|
||||
config.getDevelocityRemoteBuildCachePath()
|
||||
)
|
||||
maybeExportVariableNotEmpty(
|
||||
'DEVELOCITY_INJECTION_REMOTE_BUILD_CACHE_ALLOW_INSECURE_PROTOCOL',
|
||||
config.getDevelocityRemoteBuildCacheAllowInsecureProtocol()
|
||||
)
|
||||
maybeExportVariableNotEmpty(
|
||||
'DEVELOCITY_INJECTION_REMOTE_BUILD_CACHE_ALLOW_UNTRUSTED_SERVER',
|
||||
config.getDevelocityRemoteBuildCacheAllowUntrustedServer()
|
||||
)
|
||||
maybeExportVariableNotEmpty(
|
||||
'DEVELOCITY_INJECTION_LOCAL_BUILD_CACHE_ENABLED',
|
||||
config.getDevelocityLocalBuildCacheEnabled()
|
||||
)
|
||||
maybeExportVariableNotEmpty(
|
||||
'DEVELOCITY_INJECTION_LOCAL_BUILD_CACHE_PUSH',
|
||||
config.getDevelocityLocalBuildCachePush()
|
||||
)
|
||||
|
||||
// If build-scan-publish is enabled, ensure the environment variables are set
|
||||
// The DEVELOCITY_PLUGIN_VERSION and DEVELOCITY_CCUD_PLUGIN_VERSION are set to the latest versions
|
||||
|
||||
+10
@@ -147,6 +147,16 @@ class BaseInitScriptTest extends Specification {
|
||||
buildFile.text = maybeAddPluginsToRootProject(gradleVersion, false, CCUD_PLUGIN_VERSION, serverUrl) + buildFile.text
|
||||
}
|
||||
|
||||
def declareHttpBuildCache() {
|
||||
settingsFile << """
|
||||
buildCache {
|
||||
remote(HttpBuildCache) {
|
||||
url = 'https://build-cache-server.invalid/cache/'
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
|
||||
String maybeAddPluginsToSettings(GradleVersion gradleVersion, boolean legacy, String ccudPluginVersion, URI serverUri) {
|
||||
if (gradleVersion < GradleVersion.version('6.0')) {
|
||||
'' // applied in build.gradle
|
||||
|
||||
+99
@@ -354,6 +354,47 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
||||
testGradleVersion << CONFIGURATION_CACHE_VERSIONS
|
||||
}
|
||||
|
||||
def "configures remote and local build cache when Develocity plugin is applied by the init script"() {
|
||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||
|
||||
when:
|
||||
def config = testConfig().withRemoteBuildCache().withLocalBuildCache(false)
|
||||
def result = run(testGradleVersion, config)
|
||||
|
||||
then:
|
||||
outputContainsDevelocityPluginApplicationViaInitScript(result, testGradleVersion.gradleVersion)
|
||||
outputContainsRemoteBuildCacheConfiguration(result, 'Develocity server', '<default>', true, true)
|
||||
outputContainsLocalBuildCacheConfiguration(result, false, true)
|
||||
|
||||
and:
|
||||
outputContainsBuildScanUrl(result)
|
||||
|
||||
where:
|
||||
testGradleVersion << SETTINGS_PLUGIN_VERSIONS
|
||||
}
|
||||
|
||||
def "enforces remote build cache in project if enforce build cache parameter is enabled"() {
|
||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||
|
||||
given:
|
||||
declareHttpBuildCache()
|
||||
|
||||
when:
|
||||
def config = testConfig().withRemoteBuildCache().withRemoteBuildCacheLocation('https://build-cache-server.invalid', 'cache').withEnforceBuildCache()
|
||||
def result = run(testGradleVersion, config)
|
||||
|
||||
then:
|
||||
outputContainsDevelocityPluginApplicationViaInitScript(result, testGradleVersion.gradleVersion)
|
||||
outputReplacesRemoteBuildCache(result)
|
||||
outputContainsRemoteBuildCacheConfiguration(result, 'https://build-cache-server.invalid', 'cache', true, true)
|
||||
|
||||
and:
|
||||
outputContainsBuildScanUrl(result)
|
||||
|
||||
where:
|
||||
testGradleVersion << SETTINGS_PLUGIN_VERSIONS
|
||||
}
|
||||
|
||||
void outputContainsBuildScanUrl(BuildResult result) {
|
||||
def opt = ['Publishing build scan...', 'Publishing Build Scan...', 'Publishing Build Scan to Develocity...'].stream()
|
||||
.filter { result.output.contains("${it}\n${mockScansServer.address}s/$PUBLIC_BUILD_SCAN_ID") }.findFirst()
|
||||
@@ -441,6 +482,24 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
||||
assert 1 == result.output.count(enforceUrl)
|
||||
}
|
||||
|
||||
void outputContainsRemoteBuildCacheConfiguration(BuildResult result, String server, String path, boolean enabled, boolean push) {
|
||||
def remoteBuildCacheInfo = "Configuring the remote build cache: $server, path: $path, enabled: $enabled, push: $push, allowInsecureProtocol: false, allowUntrustedServer: <default>"
|
||||
assert result.output.contains(remoteBuildCacheInfo)
|
||||
assert 1 == result.output.count(remoteBuildCacheInfo)
|
||||
}
|
||||
|
||||
void outputContainsLocalBuildCacheConfiguration(BuildResult result, boolean enabled, boolean push) {
|
||||
def localBuildCacheInfo = "Configuring the local build cache: enabled: $enabled, push: $push"
|
||||
assert result.output.contains(localBuildCacheInfo)
|
||||
assert 1 == result.output.count(localBuildCacheInfo)
|
||||
}
|
||||
|
||||
void outputReplacesRemoteBuildCache(BuildResult result) {
|
||||
def replaceRemoteBuildCache = "Replacing the existing remote build cache with the Develocity Build Cache connector"
|
||||
assert result.output.contains(replaceRemoteBuildCache)
|
||||
assert 1 == result.output.count(replaceRemoteBuildCache)
|
||||
}
|
||||
|
||||
private BuildResult run(TestGradleVersion testGradleVersion, TestConfig config, List<String> args = ["help"]) {
|
||||
return run(args, initScript, testGradleVersion.gradleVersion, config.jvmArgs, config.envVars)
|
||||
}
|
||||
@@ -457,6 +516,12 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
||||
String pluginRepositoryUsername = null
|
||||
String pluginRepositoryPassword = null
|
||||
boolean captureFileFingerprints = false
|
||||
boolean enforceBuildCache = false
|
||||
Boolean remoteBuildCacheEnabled = null
|
||||
Boolean remoteBuildCachePush = null
|
||||
String remoteBuildCacheServer = null
|
||||
String remoteBuildCachePath = null
|
||||
Boolean localBuildCacheEnabled = null
|
||||
String develocityPluginVersion
|
||||
|
||||
TestConfig(String develocityPluginVersion) {
|
||||
@@ -490,6 +555,28 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
||||
return this
|
||||
}
|
||||
|
||||
TestConfig withRemoteBuildCache(boolean enabled = true, boolean push = true) {
|
||||
this.remoteBuildCacheEnabled = enabled
|
||||
this.remoteBuildCachePush = push
|
||||
return this
|
||||
}
|
||||
|
||||
TestConfig withRemoteBuildCacheLocation(String server, String path) {
|
||||
this.remoteBuildCacheServer = server
|
||||
this.remoteBuildCachePath = path
|
||||
return this
|
||||
}
|
||||
|
||||
TestConfig withLocalBuildCache(boolean enabled = true) {
|
||||
this.localBuildCacheEnabled = enabled
|
||||
return this
|
||||
}
|
||||
|
||||
TestConfig withEnforceBuildCache() {
|
||||
this.enforceBuildCache = true
|
||||
return this
|
||||
}
|
||||
|
||||
def getEnvVars() {
|
||||
Map<String, String> envVars = [
|
||||
DEVELOCITY_INJECTION_INIT_SCRIPT_NAME : "gradle-actions.inject-develocity.init.gradle",
|
||||
@@ -507,6 +594,12 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
||||
if (pluginRepositoryUrl != null) envVars.put("DEVELOCITY_INJECTION_PLUGIN_REPOSITORY_URL", pluginRepositoryUrl)
|
||||
if (pluginRepositoryUsername != null) envVars.put("DEVELOCITY_INJECTION_PLUGIN_REPOSITORY_USERNAME", pluginRepositoryUsername)
|
||||
if (pluginRepositoryPassword != null) envVars.put("DEVELOCITY_INJECTION_PLUGIN_REPOSITORY_PASSWORD", pluginRepositoryPassword)
|
||||
if (enforceBuildCache) envVars.put("DEVELOCITY_INJECTION_ENFORCE_BUILD_CACHE", "true")
|
||||
if (remoteBuildCacheEnabled != null) envVars.put("DEVELOCITY_INJECTION_REMOTE_BUILD_CACHE_ENABLED", String.valueOf(remoteBuildCacheEnabled))
|
||||
if (remoteBuildCachePush != null) envVars.put("DEVELOCITY_INJECTION_REMOTE_BUILD_CACHE_PUSH", String.valueOf(remoteBuildCachePush))
|
||||
if (remoteBuildCacheServer != null) envVars.put("DEVELOCITY_INJECTION_REMOTE_BUILD_CACHE_SERVER", remoteBuildCacheServer)
|
||||
if (remoteBuildCachePath != null) envVars.put("DEVELOCITY_INJECTION_REMOTE_BUILD_CACHE_PATH", remoteBuildCachePath)
|
||||
if (localBuildCacheEnabled != null) envVars.put("DEVELOCITY_INJECTION_LOCAL_BUILD_CACHE_ENABLED", String.valueOf(localBuildCacheEnabled))
|
||||
|
||||
return envVars
|
||||
}
|
||||
@@ -529,6 +622,12 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
||||
if (pluginRepositoryUrl != null) jvmArgs.add("-Ddevelocity-injection.plugin-repository.url=$pluginRepositoryUrl")
|
||||
if (pluginRepositoryUsername != null) jvmArgs.add("-Ddevelocity-injection.plugin-repository.username=$pluginRepositoryUsername")
|
||||
if (pluginRepositoryPassword != null) jvmArgs.add("-Ddevelocity-injection.plugin-repository.password=$pluginRepositoryPassword")
|
||||
if (enforceBuildCache) jvmArgs.add("-Ddevelocity-injection.enforce-build-cache=true")
|
||||
if (remoteBuildCacheEnabled != null) jvmArgs.add("-Ddevelocity-injection.remote-build-cache.enabled=$remoteBuildCacheEnabled")
|
||||
if (remoteBuildCachePush != null) jvmArgs.add("-Ddevelocity-injection.remote-build-cache.push=$remoteBuildCachePush")
|
||||
if (remoteBuildCacheServer != null) jvmArgs.add("-Ddevelocity-injection.remote-build-cache.server=$remoteBuildCacheServer")
|
||||
if (remoteBuildCachePath != null) jvmArgs.add("-Ddevelocity-injection.remote-build-cache.path=$remoteBuildCachePath")
|
||||
if (localBuildCacheEnabled != null) jvmArgs.add("-Ddevelocity-injection.local-build-cache.enabled=$localBuildCacheEnabled")
|
||||
|
||||
return jvmArgs.collect { it.toString() } // Convert from GStrings
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user