Test coverage: verify correct Gradle version is being used

This commit is contained in:
Daz DeBoer 2021-08-26 17:55:19 -06:00
parent c79d4172e0
commit c01af7a6f6
No known key found for this signature in database
GPG Key ID: DD6B9F0B06683D5D
2 changed files with 21 additions and 5 deletions

View File

@ -1,4 +1,4 @@
# make sure the action works on a clean machine without building # Make sure the action works on a clean machine without building
name: prod name: prod
on: on:
@ -10,6 +10,8 @@ env:
CACHE_KEY_SEED: ${{github.workflow}}#${{github.run_number}}- CACHE_KEY_SEED: ${{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.
basic-build: basic-build:
strategy: strategy:
matrix: matrix:
@ -29,6 +31,9 @@ jobs:
build-root-directory: __tests__/samples/basic build-root-directory: __tests__/samples/basic
arguments: test --configuration-cache arguments: test --configuration-cache
# Tests for executing with different Gradle versions.
# Each build verifies that it is executed with the expected Gradle version.
# These builds will not store cache entries for gradle-user-home or project-dot-gradle
gradle-execution: gradle-execution:
needs: basic-build needs: basic-build
strategy: strategy:
@ -46,19 +51,25 @@ jobs:
with: with:
gradle-version: 6.9 gradle-version: 6.9
build-root-directory: __tests__/samples/no-wrapper build-root-directory: __tests__/samples/no-wrapper
arguments: help arguments: help -DgradleVersionCheck=6.9
gradle-user-home-cache-enabled: read-only
project-dot-gradle-cache-enabled: read-only
- name: Test use Gradle version alias - name: Test use Gradle version alias
uses: ./ uses: ./
with: with:
gradle-version: release-candidate gradle-version: release-candidate
build-root-directory: __tests__/samples/no-wrapper build-root-directory: __tests__/samples/no-wrapper
arguments: help arguments: help -DgradleVersionCheck=7.2
gradle-user-home-cache-enabled: read-only
project-dot-gradle-cache-enabled: read-only
- name: Test use defined Gradle executable - name: Test use defined Gradle executable
uses: ./ uses: ./
with: with:
gradle-executable: __tests__/samples/basic/gradlew${{ matrix.script-suffix }} gradle-executable: __tests__/samples/basic/gradlew${{ matrix.script-suffix }}
build-root-directory: __tests__/samples/no-wrapper build-root-directory: __tests__/samples/no-wrapper
arguments: help arguments: help -DgradleVersionCheck=7.1.1
gradle-user-home-cache-enabled: read-only
project-dot-gradle-cache-enabled: read-only
dependencies-cache: dependencies-cache:
needs: basic-build needs: basic-build

View File

@ -1,3 +1,8 @@
rootProject.name = 'no-wrapper' rootProject.name = 'no-wrapper'
println "Using Gradle version: ${gradle.gradleVersion}" println "Using Gradle version: ${gradle.gradleVersion}"
def gradleVersionCheck = System.properties.gradleVersionCheck
if (gradleVersionCheck && gradle.gradleVersion != gradleVersionCheck) {
throw new RuntimeException("Got the wrong version: expected ${gradleVersionCheck} but was ${gradle.gradleVersion}")
}