Update most test workflows to separate config from execution

This commit is contained in:
Daz DeBoer 2021-12-08 10:29:13 -07:00
parent 0e8b9655a0
commit e977669c8c
No known key found for this signature in database
GPG key ID: DD6B9F0B06683D5D
7 changed files with 154 additions and 76 deletions

View file

@ -11,8 +11,6 @@ env:
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
jobs: jobs:
# Run initial Gradle builds to push initial cache entries
# These builds should start fresh without cache hits, due to the seed injected into the cache key above.
seed-build: seed-build:
strategy: strategy:
matrix: matrix:
@ -21,11 +19,9 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Build using Gradle wrapper - name: Setup Gradle
uses: ./ uses: ./
with: with:
build-root-directory: __tests__/samples/groovy-dsl
arguments: test
# Add "wrapper" to main cache entry and remove 'wrapper-zips' cache entry # Add "wrapper" to main cache entry and remove 'wrapper-zips' cache entry
# Exclude build-cache from main cache entry # Exclude build-cache from main cache entry
gradle-home-cache-includes: | gradle-home-cache-includes: |
@ -41,6 +37,9 @@ jobs:
["instrumented-jars", "caches/jars-*/*/"], ["instrumented-jars", "caches/jars-*/*/"],
["kotlin-dsl", "caches/*/kotlin-dsl/*/*/"] ["kotlin-dsl", "caches/*/kotlin-dsl/*/*/"]
] ]
- name: Build using Gradle wrapper
working-directory: __tests__/samples/groovy-dsl
run: ./gradlew test
# Test that the gradle-user-home cache will cache dependencies, by running build with --offline # Test that the gradle-user-home cache will cache dependencies, by running build with --offline
verify-build: verify-build:
@ -52,13 +51,10 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Execute Gradle build with --offline - name: Setup Gradle
uses: ./ uses: ./
with: with:
build-root-directory: __tests__/samples/groovy-dsl # Use the same configuration when restoring state from cache
arguments: test --offline
cache-read-only: true
# Need the same configuration when restoring state from cache
gradle-home-cache-includes: | gradle-home-cache-includes: |
caches caches
notifications notifications
@ -72,5 +68,9 @@ jobs:
["instrumented-jars", "caches/jars-*/*/"], ["instrumented-jars", "caches/jars-*/*/"],
["kotlin-dsl", "caches/*/kotlin-dsl/*/*/"] ["kotlin-dsl", "caches/*/kotlin-dsl/*/*/"]
] ]
cache-read-only: true
- name: Execute Gradle build with --offline
working-directory: __tests__/samples/groovy-dsl
run: ./gradlew test --offline

View file

@ -21,19 +21,16 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Build with configuration-cache enabled - name: Setup Gradle
uses: ./ uses: ./
with: - name: Groovy build with configuration-cache enabled
build-root-directory: __tests__/samples/groovy-dsl working-directory: __tests__/samples/groovy-dsl
arguments: test --configuration-cache run: ./gradlew test --configuration-cache
- name: Second build with configuration-cache enabled - name: Kotlin build with configuration-cache enabled
uses: ./ working-directory: __tests__/samples/kotlin-dsl
with: run: ./gradlew test --configuration-cache
build-root-directory: __tests__/samples/kotlin-dsl
arguments: test --configuration-cache
# Test restore configuration-cache configuration-cache-groovy:
configuration-cache:
needs: seed-build needs: seed-build
strategy: strategy:
matrix: matrix:
@ -42,17 +39,18 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Execute Gradle build and verify cached configuration - name: Setup Gradle
uses: ./ uses: ./
with:
cache-read-only: true
- name: Execute Gradle build and verify cached configuration
env: env:
VERIFY_CACHED_CONFIGURATION: true VERIFY_CACHED_CONFIGURATION: true
with: working-directory: __tests__/samples/groovy-dsl
build-root-directory: __tests__/samples/groovy-dsl run: ./gradlew test --configuration-cache
arguments: test --configuration-cache
cache-read-only: true
# Test restore configuration-cache from second build invocation # Test restore configuration-cache from the second build invocation
configuration-cache-2: configuration-cache-kotlin:
needs: seed-build needs: seed-build
strategy: strategy:
matrix: matrix:
@ -61,14 +59,15 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Execute Gradle build and verify cached configuration - name: Setup Gradle
uses: ./ uses: ./
with:
cache-read-only: true
- name: Execute Gradle build and verify cached configuration
env: env:
VERIFY_CACHED_CONFIGURATION: true VERIFY_CACHED_CONFIGURATION: true
with: working-directory: __tests__/samples/kotlin-dsl
build-root-directory: __tests__/samples/kotlin-dsl run: ./gradlew test --configuration-cache
arguments: test --configuration-cache
cache-read-only: true
# Check that the build can run when no extracted cache entries are restored # Check that the build can run when no extracted cache entries are restored
no-extracted-cache-entries-restored: no-extracted-cache-entries-restored:
@ -80,11 +79,11 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Execute Gradle build with no cache extracted cache entries restored - name: Setup Gradle with no cache extracted cache entries restored
uses: ./ uses: ./
with: with:
build-root-directory: __tests__/samples/groovy-dsl
arguments: test --configuration-cache
cache-read-only: true cache-read-only: true
gradle-home-extracted-cache-entries: '[]' gradle-home-extracted-cache-entries: '[]'
- name: Check execute Gradle build with configuration cache enabled (but not restored)
working-directory: __tests__/samples/groovy-dsl
run: ./gradlew test --configuration-cache

View file

@ -10,8 +10,6 @@ env:
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}- GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}-
jobs: jobs:
# Run initial Gradle builds to push initial cache entries
# These builds should start fresh without cache hits, due to the seed injected into the cache key above.
seed-build: seed-build:
strategy: strategy:
matrix: matrix:
@ -20,11 +18,11 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Build using Gradle wrapper - name: Setup Gradle
uses: ./ uses: ./
with: - name: Build using Gradle wrapper
build-root-directory: __tests__/samples/groovy-dsl working-directory: __tests__/samples/groovy-dsl
arguments: test run: ./gradlew test
# Test that the gradle-user-home cache will cache dependencies, by running build with --offline # Test that the gradle-user-home cache will cache dependencies, by running build with --offline
dependencies-cache: dependencies-cache:
@ -36,12 +34,13 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Execute Gradle build with --offline - name: Setup Gradle
uses: ./ uses: ./
with: with:
build-root-directory: __tests__/samples/groovy-dsl
arguments: test --offline
cache-read-only: true cache-read-only: true
- name: Execute Gradle build with --offline
working-directory: __tests__/samples/groovy-dsl
run: ./gradlew test --offline
# Test that the gradle-user-home cache will cache and restore local build-cache # Test that the gradle-user-home cache will cache and restore local build-cache
build-cache: build-cache:
@ -53,12 +52,13 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Execute Gradle build and verify tasks from cache - name: Setup Gradle
uses: ./ uses: ./
with: with:
build-root-directory: __tests__/samples/groovy-dsl
arguments: test -DverifyCachedBuild=true
cache-read-only: true cache-read-only: true
- name: Execute Gradle build and verify tasks from cache
working-directory: __tests__/samples/groovy-dsl
run: ./gradlew test -DverifyCachedBuild=true
# Check that the build can run when Gradle User Home is not fully restored # Check that the build can run when Gradle User Home is not fully restored
no-extracted-cache-entries-restored: no-extracted-cache-entries-restored:
@ -70,11 +70,12 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Execute Gradle build with no extracted cache entries restored - name: Setup Gradle with no extracted cache entries restored
uses: ./ uses: ./
with: with:
build-root-directory: __tests__/samples/groovy-dsl
arguments: test
cache-read-only: true cache-read-only: true
gradle-home-extracted-cache-entries: '[]' gradle-home-extracted-cache-entries: '[]'
- name: Check executee Gradle build
working-directory: __tests__/samples/groovy-dsl
run: ./gradlew test

View file

@ -8,7 +8,7 @@ on:
env: env:
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}- GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}-
GRADLE_USER_HOME: custom/gradle/home GRADLE_USER_HOME: ${{github.workspace}}/custom/gradle/home
jobs: jobs:
# Run initial Gradle builds to push initial cache entries # Run initial Gradle builds to push initial cache entries
@ -21,11 +21,11 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Build using Gradle wrapper - name: Setup Gradle
uses: ./ uses: ./
with: - name: Build using Gradle wrapper
build-root-directory: __tests__/samples/groovy-dsl working-directory: __tests__/samples/groovy-dsl
arguments: test run: ./gradlew test --info
# Test that the gradle-user-home cache will cache dependencies, by running build with --offline # Test that the gradle-user-home cache will cache dependencies, by running build with --offline
dependencies-cache: dependencies-cache:
@ -37,12 +37,13 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Execute Gradle build with --offline - name: Setup Gradle
uses: ./ uses: ./
with: with:
build-root-directory: __tests__/samples/groovy-dsl
arguments: test --offline
cache-read-only: true cache-read-only: true
- name: Execute Gradle build with --offline
working-directory: __tests__/samples/groovy-dsl
run: ./gradlew test --offline --info
# Test that the gradle-user-home cache will cache and restore local build-cache # Test that the gradle-user-home cache will cache and restore local build-cache
build-cache: build-cache:
@ -54,9 +55,10 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Execute Gradle build and verify tasks from cache - name: Setup Gradle
uses: ./ uses: ./
with: with:
build-root-directory: __tests__/samples/groovy-dsl
arguments: test -DverifyCachedBuild=true
cache-read-only: true cache-read-only: true
- name: Execute Gradle build and verify tasks from cache
working-directory: __tests__/samples/groovy-dsl
run: ./gradlew test -DverifyCachedBuild=true --info

View file

@ -0,0 +1,77 @@
name: Test provision different Gradle versions
on:
pull_request:
types: [assigned, review_requested]
push:
workflow_dispatch:
env:
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}-
jobs:
# Tests for executing with different Gradle versions.
# Each build verifies that it is executed with the expected Gradle version.
provision-gradle:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
include:
- os: windows-latest
script-suffix: '.bat'
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Setup Gradle with v6.9
uses: ./
with:
gradle-version: 6.9
- name: Test uses Gradle v6.9
working-directory: __tests__/samples/no-wrapper
run: gradle help "-DgradleVersionCheck=6.9"
- name: Setup Gradle with v7.1.1
uses: ./
with:
gradle-version: 7.1.1
- name: Test uses Gradle v7.1.1
working-directory: __tests__/samples/no-wrapper
run: gradle help "-DgradleVersionCheck=7.1.1"
- name: Setup Gradle with release-candidate
uses: ./
with:
gradle-version: release-candidate
- name: Test use release-candidate
working-directory: __tests__/samples/no-wrapper
run: gradle help
gradle-versions:
strategy:
matrix:
gradle: [7.3, 6.9, 5.6.4, 4.10.3]
os: [ubuntu-latest, windows-latest]
include:
- gradle: 5.6.4
build-root-suffix: -gradle-5
- gradle: 4.10.3
build-root-suffix: -gradle-4
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Setup Gradle
uses: ./
with:
gradle-version: ${{ matrix.gradle }}
- name: Run Gradle build
id: gradle
working-directory: __tests__/samples/no-wrapper${{ matrix.build-root-suffix }}
run: gradle help "-DgradleVersionCheck=${{matrix.gradle}}"
- name: Check build scan url
if: ${{ !steps.gradle.outputs.build-scan-url }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('No build scan detected')

View file

@ -20,11 +20,11 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Build kotlin-dsl project - name: Setup Gradle
uses: ./ uses: ./
with: - name: Build kotlin-dsl project
build-root-directory: __tests__/samples/kotlin-dsl working-directory: __tests__/samples/kotlin-dsl
arguments: test run: ./gradlew test
# Check that the build can run --offline # Check that the build can run --offline
verify-build: verify-build:
@ -36,8 +36,8 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Build kotlin-dsl project - name: Setup Gradle
uses: ./ uses: ./
with: - name: Build kotlin-dsl project
build-root-directory: __tests__/samples/kotlin-dsl working-directory: __tests__/samples/kotlin-dsl
arguments: test --offline run: ./gradlew test --offline

View file

@ -8,11 +8,10 @@ jobs:
- uses: actions/setup-java@v1 - uses: actions/setup-java@v1
with: with:
java-version: 11 java-version: 11
- uses: gradle/gradle-build-action@v2 - uses: ./
id: gradle - id: gradle
with: working-directory: __tests__/samples/kotlin-dsl
build-root-directory: __tests__/samples/kotlin-dsl run: ./gradlew help
arguments: help
- name: "Comment build scan url" - name: "Comment build scan url"
uses: actions/github-script@v3 uses: actions/github-script@v3
with: with: