Skip to content

Commit

Permalink
Merge pull request #968 : Prepare for version 3.x
Browse files Browse the repository at this point in the history
Contains all functionality planned for the initial 3.x release.

- Fixes #726 
- Fixes #946 
- Fixes #966 
- Fixes #996
  • Loading branch information
bigdaz committed Dec 23, 2023
2 parents 982da8e + e6566cd commit a7b7438
Show file tree
Hide file tree
Showing 19 changed files with 26,735 additions and 14,606 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-full-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
cache-key-prefix: ${{github.run_number}}-

caching-config:
uses: ./.github/workflows/integ-test-action-inputs-caching.yml
uses: ./.github/workflows/integ-test-caching-config.yml
with:
cache-key-prefix: ${{github.run_number}}-

Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/ci-quick-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

caching-config:
needs: build-distribution
uses: ./.github/workflows/integ-test-action-inputs-caching.yml
uses: ./.github/workflows/integ-test-caching-config.yml
with:
runner-os: '["ubuntu-latest"]'
download-dist: true
Expand Down Expand Up @@ -87,12 +87,12 @@ jobs:
runner-os: '["ubuntu-latest"]'
download-dist: true

# restore-configuration-cache:
# needs: build-distribution
# uses: ./.github/workflows/integ-test-restore-configuration-cache.yml
# with:
# runner-os: '["ubuntu-latest"]'
# download-dist: true
restore-configuration-cache:
needs: build-distribution
uses: ./.github/workflows/integ-test-restore-configuration-cache.yml
with:
runner-os: '["ubuntu-latest"]'
download-dist: true

restore-containerized-gradle-home:
needs: build-distribution
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test action inputs for caching
name: Test caching configuration

on:
workflow_call:
Expand Down Expand Up @@ -38,7 +38,8 @@ jobs:
enterprise
# Exclude build-cache from main cache entry
gradle-home-cache-excludes: |
caches/build-cache-1
caches/build-cache-*
caches/*/executionHistory
- name: Build using Gradle wrapper
working-directory: .github/workflow-samples/groovy-dsl
run: ./gradlew test
Expand All @@ -63,7 +64,8 @@ jobs:
caches
enterprise
gradle-home-cache-excludes: |
caches/build-cache-1
caches/build-cache-*
caches/*/executionHistory
cache-read-only: true
- name: Execute Gradle build with --offline
working-directory: .github/workflow-samples/groovy-dsl
Expand Down
24 changes: 18 additions & 6 deletions .github/workflows/integ-test-restore-configuration-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ jobs:
uses: ./
with:
cache-read-only: false # For testing, allow writing cache entries on non-default branches
cache-encryption-key: Da25KUVSE5jbGds2zXmfXw==
gradle-version: release-nightly
- name: Groovy build with configuration-cache enabled
working-directory: .github/workflow-samples/groovy-dsl
run: ./gradlew test --configuration-cache
run: gradle test --configuration-cache

verify-build-groovy:
env:
Expand All @@ -55,10 +57,12 @@ jobs:
uses: ./
with:
cache-read-only: true
cache-encryption-key: Da25KUVSE5jbGds2zXmfXw==
gradle-version: release-nightly
- name: Groovy build with configuration-cache enabled
id: execute
working-directory: .github/workflow-samples/groovy-dsl
run: ./gradlew test --configuration-cache
run: gradle test --configuration-cache
- name: Check that configuration-cache was used
uses: actions/github-script@v7
with:
Expand Down Expand Up @@ -88,9 +92,11 @@ jobs:
GRADLE_BUILD_ACTION_SKIP_RESTORE: "generated-gradle-jars|wrapper-zips|java-toolchains|instrumented-jars|dependencies|kotlin-dsl"
with:
cache-read-only: true
cache-encryption-key: Da25KUVSE5jbGds2zXmfXw==
gradle-version: release-nightly
- name: Check execute Gradle build with configuration cache enabled (but not restored)
working-directory: .github/workflow-samples/groovy-dsl
run: ./gradlew test --configuration-cache
run: gradle test --configuration-cache

seed-build-kotlin:
env:
Expand All @@ -108,9 +114,11 @@ jobs:
uses: ./
with:
cache-read-only: false # For testing, allow writing cache entries on non-default branches
cache-encryption-key: Da25KUVSE5jbGds2zXmfXw==
gradle-version: release-nightly
- name: Execute 'help' with configuration-cache enabled
working-directory: .github/workflow-samples/kotlin-dsl
run: ./gradlew help --configuration-cache
run: gradle help --configuration-cache

modify-build-kotlin:
env:
Expand All @@ -129,9 +137,11 @@ jobs:
uses: ./
with:
cache-read-only: false # For testing, allow writing cache entries on non-default branches
cache-encryption-key: Da25KUVSE5jbGds2zXmfXw==
gradle-version: release-nightly
- name: Execute 'test' with configuration-cache enabled
working-directory: .github/workflow-samples/kotlin-dsl
run: ./gradlew test --configuration-cache
run: gradle test --configuration-cache

# Test restore configuration-cache from the third build invocation
verify-build-kotlin:
Expand All @@ -151,10 +161,12 @@ jobs:
uses: ./
with:
cache-read-only: true
cache-encryption-key: Da25KUVSE5jbGds2zXmfXw==
gradle-version: release-nightly
- name: Execute 'test' again with configuration-cache enabled
id: execute
working-directory: .github/workflow-samples/kotlin-dsl
run: ./gradlew test --configuration-cache
run: gradle test --configuration-cache
- name: Check that configuration-cache was used
uses: actions/github-script@v7
with:
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Configuration file for asdf version manager
nodejs 16.18.1
nodejs 20.10.0
gradle 8.5
98 changes: 0 additions & 98 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ jobs:
- run: echo "The release-candidate version was ${{ steps.setup-gradle.outputs.gradle-version }}"
```


## Caching build state between Jobs

The `gradle-build-action` will use the GitHub Actions cache to save and restore reusable state that may be speed up a subsequent build invocation. This includes most content that is downloaded from the internet as part of a build, as well as expensive to create content like compiled build scripts, transformed Jar files, etc.
Expand Down Expand Up @@ -423,103 +422,6 @@ jobs:
path: build/reports/
```

## Use the action to invoke Gradle

If the `gradle-build-action` is configured with an `arguments` input, then Gradle will execute a Gradle build with the arguments provided. NOTE: We recommend using the `gradle-build-action` as a "Setup Gradle" step as described above, with Gradle being invoked via a regular `run` command.

If no `arguments` are provided, the action will not execute Gradle, but will still cache Gradle state and configure build-scan capture for all subsequent Gradle executions.

```yaml
name: Run Gradle on PRs
on: pull_request
jobs:
gradle:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11

- name: Setup and execute Gradle 'test' task
uses: gradle/gradle-build-action@v2
with:
arguments: test
```

### Multiple Gradle executions in the same Job

It is possible to configure multiple Gradle executions to run sequentially in the same job.
The initial Action step will perform the Gradle setup.

```yaml
- uses: gradle/gradle-build-action@v2
with:
arguments: assemble
- uses: gradle/gradle-build-action@v2
with:
arguments: check
```

### Gradle command-line arguments

The `arguments` input can be used to pass arbitrary arguments to the `gradle` command line.
Arguments can be supplied in a single line, or as a multi-line input.

Here are some valid examples:
```yaml
arguments: build
arguments: check --scan
arguments: some arbitrary tasks
arguments: build -PgradleProperty=foo
arguments: |
build
--scan
-PgradleProperty=foo
-DsystemProperty=bar
```

If you need to pass environment variables, use the GitHub Actions workflow syntax:

```yaml
- uses: gradle/gradle-build-action@v2
env:
CI: true
with:
arguments: build
```

### Gradle build located in a subdirectory

By default, the action will execute Gradle in the root directory of your project.
Use the `build-root-directory` input to target a Gradle build in a subdirectory.

```yaml
- uses: gradle/gradle-build-action@v2
with:
arguments: build
build-root-directory: some/subdirectory
```

### Using a specific Gradle executable

The action will first look for a Gradle wrapper script in the root directory of your project.
If not found, `gradle` will be executed from the PATH.
Use the `gradle-executable` input to execute using a specific Gradle installation.

```yaml
- uses: gradle/gradle-build-action@v2
with:
arguments: build
gradle-executable: /path/to/installed/gradle
```

This mechanism can also be used to target a Gradle wrapper script that is located in a non-default location.

## Support for GitHub Enterprise Server (GHES)

You can use the `gradle-build-action` on GitHub Enterprise Server, and benefit from the improved integration with Gradle. Depending on the version of GHES you are running, certain features may be limited:
Expand Down
38 changes: 25 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ inputs:
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

cache-disabled:
description: When 'true', all caching is disabled. No entries will be written to or read from the cache.
required: false
Expand All @@ -40,6 +32,13 @@ inputs:
required: false
default: false

cache-encryption-key:
description: |
A base64 encoded AES key used to encrypt the configuration-cache data. The key is exported as 'GRADLE_ENCRYPTION_KEY' for later steps.
A suitable key can be generated with `openssl rand -base64 16`.
Configuration-cache data will not be saved/restored without an encryption key being provided.
required: false

gradle-home-cache-includes:
description: Paths within Gradle User Home to cache.
required: false
Expand All @@ -59,10 +58,6 @@ inputs:
required: false
default: false

arguments:
description: Gradle command line arguments (supports multi-line input)
required: false

generate-job-summary:
description: When 'false', no Job Summary will be generated for the Job.
required: false
Expand All @@ -77,6 +72,22 @@ inputs:
description: Specifies the number of days to retain any artifacts generated by the action. If not set, the default retention settings for the repository will apply.
required: false

# DEPRECATED ACTION INPUTS
arguments:
description: Gradle command line arguments (supports multi-line input)
required: false
deprecation-message: Using the action to execute Gradle directly is deprecated in favor of using the action to setup Gradle, and executing Gradle in a subsequent Step. See https://github.com/gradle/gradle-build-action?tab=readme-ov-file#use-the-action-to-setup-gradle.

build-root-directory:
description: Path to the root directory of the build. Default is the root of the GitHub workspace.
required: false
deprecation-message: Using the action to execute Gradle directly is deprecated in favor of using the action to setup Gradle, and executing Gradle in a subsequent Step. See https://github.com/gradle/gradle-build-action?tab=readme-ov-file#use-the-action-to-setup-gradle.

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
deprecation-message: Using the action to execute Gradle directly is deprecated in favor of using the action to setup Gradle, and executing Gradle in a subsequent Step. See https://github.com/gradle/gradle-build-action?tab=readme-ov-file#use-the-action-to-setup-gradle.

# EXPERIMENTAL & INTERNAL ACTION INPUTS
# The following action properties allow fine-grained tweaking of the action caching behaviour.
# These properties are experimental and not (yet) designed for production use, and may change without notice in a subsequent release of `gradle-build-action`.
Expand All @@ -85,6 +96,7 @@ inputs:
description: When 'true', the action will not attempt to restore the Gradle User Home entries from other Jobs.
required: false
default: false

workflow-job-context:
description: Used to uniquely identify the current job invocation. Defaults to the matrix values for this job; this should not be overridden by users (INTERNAL).
required: false
Expand All @@ -104,7 +116,7 @@ outputs:
description: Version of Gradle that was setup by the action

runs:
using: 'node16'
using: 'node20'
main: 'dist/main/index.js'
post: 'dist/post/index.js'

Expand Down

0 comments on commit a7b7438

Please sign in to comment.