mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-26 11:02:10 +00:00
Merge pull request #149 from gradle/write-from-default-branch
Default to `cache-read-only` for non-default branches
This commit is contained in:
commit
14c898b500
12 changed files with 35 additions and 8 deletions
|
@ -31,6 +31,7 @@ jobs:
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
# Add "enterprise" to main cache entry but omit "notifications"
|
# Add "enterprise" to main cache entry but omit "notifications"
|
||||||
gradle-home-cache-includes: |
|
gradle-home-cache-includes: |
|
||||||
caches
|
caches
|
||||||
|
|
|
@ -31,6 +31,7 @@ jobs:
|
||||||
- name: Execute Gradle build
|
- name: Execute Gradle build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
build-root-directory: .github/workflow-samples/groovy-dsl
|
build-root-directory: .github/workflow-samples/groovy-dsl
|
||||||
arguments: test
|
arguments: test
|
||||||
|
|
||||||
|
|
2
.github/workflows/integ-test-execution.yml
vendored
2
.github/workflows/integ-test-execution.yml
vendored
|
@ -36,6 +36,7 @@ jobs:
|
||||||
- name: Test use defined Gradle version
|
- name: Test use defined Gradle version
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
gradle-version: 6.9
|
gradle-version: 6.9
|
||||||
build-root-directory: .github/workflow-samples/no-wrapper
|
build-root-directory: .github/workflow-samples/no-wrapper
|
||||||
arguments: help -DgradleVersionCheck=6.9
|
arguments: help -DgradleVersionCheck=6.9
|
||||||
|
@ -72,6 +73,7 @@ jobs:
|
||||||
uses: ./
|
uses: ./
|
||||||
id: gradle
|
id: gradle
|
||||||
with:
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
gradle-version: ${{matrix.gradle}}
|
gradle-version: ${{matrix.gradle}}
|
||||||
build-root-directory: .github/workflow-samples/no-wrapper${{ matrix.build-root-suffix }}
|
build-root-directory: .github/workflow-samples/no-wrapper${{ matrix.build-root-suffix }}
|
||||||
arguments: help -DgradleVersionCheck=${{matrix.gradle}}
|
arguments: help -DgradleVersionCheck=${{matrix.gradle}}
|
||||||
|
|
|
@ -36,6 +36,7 @@ jobs:
|
||||||
- name: Setup Gradle with v6.9
|
- name: Setup Gradle with v6.9
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
gradle-version: 6.9
|
gradle-version: 6.9
|
||||||
- name: Test uses Gradle v6.9
|
- name: Test uses Gradle v6.9
|
||||||
working-directory: .github/workflow-samples/no-wrapper
|
working-directory: .github/workflow-samples/no-wrapper
|
||||||
|
@ -74,6 +75,7 @@ jobs:
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
gradle-version: ${{ matrix.gradle }}
|
gradle-version: ${{ matrix.gradle }}
|
||||||
- name: Run Gradle build
|
- name: Run Gradle build
|
||||||
id: gradle
|
id: gradle
|
||||||
|
|
|
@ -32,6 +32,8 @@ jobs:
|
||||||
uses: ./.github/actions/download-dist
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
- name: Groovy build with configuration-cache enabled
|
- name: Groovy build with configuration-cache enabled
|
||||||
working-directory: .github/workflow-samples/groovy-dsl
|
working-directory: .github/workflow-samples/groovy-dsl
|
||||||
run: ./gradlew test --configuration-cache
|
run: ./gradlew test --configuration-cache
|
||||||
|
@ -102,6 +104,8 @@ jobs:
|
||||||
uses: ./.github/actions/download-dist
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
- name: Execute 'help' with configuration-cache enabled
|
- name: Execute 'help' with configuration-cache enabled
|
||||||
working-directory: .github/workflow-samples/kotlin-dsl
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
run: ./gradlew help --configuration-cache
|
run: ./gradlew help --configuration-cache
|
||||||
|
@ -121,6 +125,8 @@ jobs:
|
||||||
uses: ./.github/actions/download-dist
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
- name: Execute 'test' with configuration-cache enabled
|
- name: Execute 'test' with configuration-cache enabled
|
||||||
working-directory: .github/workflow-samples/kotlin-dsl
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
run: ./gradlew test --configuration-cache
|
run: ./gradlew test --configuration-cache
|
||||||
|
|
|
@ -30,6 +30,8 @@ jobs:
|
||||||
uses: ./.github/actions/download-dist
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
- name: Build using Gradle wrapper
|
- name: Build using Gradle wrapper
|
||||||
working-directory: .github/workflow-samples/groovy-dsl
|
working-directory: .github/workflow-samples/groovy-dsl
|
||||||
run: ./gradlew test --info
|
run: ./gradlew test --info
|
||||||
|
|
|
@ -31,6 +31,8 @@ jobs:
|
||||||
uses: ./.github/actions/download-dist
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
- name: Build using Gradle wrapper
|
- name: Build using Gradle wrapper
|
||||||
working-directory: .github/workflow-samples/groovy-dsl
|
working-directory: .github/workflow-samples/groovy-dsl
|
||||||
run: ./gradlew test
|
run: ./gradlew test
|
||||||
|
|
|
@ -30,6 +30,8 @@ jobs:
|
||||||
uses: ./.github/actions/download-dist
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
- name: Build using Gradle wrapper
|
- name: Build using Gradle wrapper
|
||||||
working-directory: .github/workflow-samples/java-toolchain
|
working-directory: .github/workflow-samples/java-toolchain
|
||||||
run: ./gradlew test --info
|
run: ./gradlew test --info
|
||||||
|
|
|
@ -30,6 +30,8 @@ jobs:
|
||||||
uses: ./.github/actions/download-dist
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
- name: Build gradle-plugin project
|
- name: Build gradle-plugin project
|
||||||
working-directory: .github/workflow-samples/gradle-plugin
|
working-directory: .github/workflow-samples/gradle-plugin
|
||||||
run: ./gradlew build
|
run: ./gradlew build
|
||||||
|
|
|
@ -30,6 +30,8 @@ jobs:
|
||||||
uses: ./.github/actions/download-dist
|
uses: ./.github/actions/download-dist
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: ./
|
uses: ./
|
||||||
|
with:
|
||||||
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
- name: Build kotlin-dsl project
|
- name: Build kotlin-dsl project
|
||||||
working-directory: .github/workflow-samples/kotlin-dsl
|
working-directory: .github/workflow-samples/kotlin-dsl
|
||||||
run: ./gradlew build
|
run: ./gradlew build
|
||||||
|
|
19
action.yml
19
action.yml
|
@ -14,11 +14,20 @@ inputs:
|
||||||
default: false
|
default: false
|
||||||
|
|
||||||
cache-read-only:
|
cache-read-only:
|
||||||
description: When 'true', existing entries will be read from the cache but no entries will be written.
|
description: |
|
||||||
|
When 'true', existing entries will be read from the cache but no entries will be written.
|
||||||
|
By default this value is 'false' for workflows on the GitHub default branch and 'true' for workflows on other branches.
|
||||||
|
required: false
|
||||||
|
default: ${{ github.ref_name != github.event.repository.default_branch }}
|
||||||
|
# e.g. Use the following setting to only write cache entries from your 'main' branch
|
||||||
|
# cache-read-only: ${{ github.ref_name != 'main' }}
|
||||||
|
|
||||||
|
cache-write-only:
|
||||||
|
description: |
|
||||||
|
When 'true', entries will not be restored from the cache but will be saved at the end of the Job.
|
||||||
|
Setting this to 'true' implies cache-read-only will be 'false'.
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
# e.g. Use the following setting to only write cache entries from your 'main' branch
|
|
||||||
# cache-read-only: ${{ github.ref != 'refs/heads/main' }}
|
|
||||||
|
|
||||||
gradle-home-cache-includes:
|
gradle-home-cache-includes:
|
||||||
description: Paths within Gradle User Home to cache.
|
description: Paths within Gradle User Home to cache.
|
||||||
|
@ -50,10 +59,6 @@ inputs:
|
||||||
# The following action properties allow fine-grained tweaking of the action caching behaviour.
|
# The following action properties allow fine-grained tweaking of the action caching behaviour.
|
||||||
# These properties are experimental and not (yet) designed for production use, and may change without notice in a subsequent release of `gradle-build-action`.
|
# These properties are experimental and not (yet) designed for production use, and may change without notice in a subsequent release of `gradle-build-action`.
|
||||||
# Use at your own risk!
|
# Use at your own risk!
|
||||||
cache-write-only:
|
|
||||||
description: When 'true', entries will not be restored from the cache but will be saved at the end of the Job. This allows a 'clean' cache entry to be written.
|
|
||||||
required: false
|
|
||||||
default: false
|
|
||||||
gradle-home-cache-strict-match:
|
gradle-home-cache-strict-match:
|
||||||
description: When 'true', the action will not attempt to restore the Gradle User Home entries from other Jobs.
|
description: When 'true', the action will not attempt to restore the Gradle User Home entries from other Jobs.
|
||||||
required: false
|
required: false
|
||||||
|
|
|
@ -27,7 +27,7 @@ export function isCacheDisabled(): boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isCacheReadOnly(): boolean {
|
export function isCacheReadOnly(): boolean {
|
||||||
return core.getBooleanInput(CACHE_READONLY_PARAMETER)
|
return !isCacheWriteOnly() && core.getBooleanInput(CACHE_READONLY_PARAMETER)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isCacheWriteOnly(): boolean {
|
export function isCacheWriteOnly(): boolean {
|
||||||
|
|
Loading…
Reference in a new issue