From e977669c8c72954d57e1d1611225168335d4db0b Mon Sep 17 00:00:00 2001 From: Daz DeBoer Date: Wed, 8 Dec 2021 10:29:13 -0700 Subject: [PATCH] Update most test workflows to separate config from execution --- .../workflows/integTest-caching-config.yml | 20 ++--- .../integTest-caching-configuration-cache.yml | 53 +++++++------ .../integTest-caching-gradle-home.yml | 31 ++++---- .../workflows/integTest-gradle-user-home.yml | 24 +++--- .../workflows/integTest-gradle-versions.yml | 77 +++++++++++++++++++ .github/workflows/integTest-kotlin-dsl.yml | 16 ++-- .github/workflows/pr-build-scan-comment.yml | 9 +-- 7 files changed, 154 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/integTest-gradle-versions.yml diff --git a/.github/workflows/integTest-caching-config.yml b/.github/workflows/integTest-caching-config.yml index d5190fa..c38b629 100644 --- a/.github/workflows/integTest-caching-config.yml +++ b/.github/workflows/integTest-caching-config.yml @@ -11,8 +11,6 @@ env: GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true 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: strategy: matrix: @@ -21,11 +19,9 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v2 - - name: Build using Gradle wrapper + - name: Setup Gradle uses: ./ with: - build-root-directory: __tests__/samples/groovy-dsl - arguments: test # Add "wrapper" to main cache entry and remove 'wrapper-zips' cache entry # Exclude build-cache from main cache entry gradle-home-cache-includes: | @@ -41,6 +37,9 @@ jobs: ["instrumented-jars", "caches/jars-*/*/"], ["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 verify-build: @@ -52,13 +51,10 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v2 - - name: Execute Gradle build with --offline + - name: Setup Gradle uses: ./ with: - build-root-directory: __tests__/samples/groovy-dsl - arguments: test --offline - cache-read-only: true - # Need the same configuration when restoring state from cache + # Use the same configuration when restoring state from cache gradle-home-cache-includes: | caches notifications @@ -72,5 +68,9 @@ jobs: ["instrumented-jars", "caches/jars-*/*/"], ["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 diff --git a/.github/workflows/integTest-caching-configuration-cache.yml b/.github/workflows/integTest-caching-configuration-cache.yml index dde0db0..a88768d 100644 --- a/.github/workflows/integTest-caching-configuration-cache.yml +++ b/.github/workflows/integTest-caching-configuration-cache.yml @@ -21,19 +21,16 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v2 - - name: Build with configuration-cache enabled + - name: Setup Gradle uses: ./ - with: - build-root-directory: __tests__/samples/groovy-dsl - arguments: test --configuration-cache - - name: Second build with configuration-cache enabled - uses: ./ - with: - build-root-directory: __tests__/samples/kotlin-dsl - arguments: test --configuration-cache + - name: Groovy build with configuration-cache enabled + working-directory: __tests__/samples/groovy-dsl + run: ./gradlew test --configuration-cache + - name: Kotlin build with configuration-cache enabled + working-directory: __tests__/samples/kotlin-dsl + run: ./gradlew test --configuration-cache - # Test restore configuration-cache - configuration-cache: + configuration-cache-groovy: needs: seed-build strategy: matrix: @@ -42,17 +39,18 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v2 - - name: Execute Gradle build and verify cached configuration + - name: Setup Gradle uses: ./ + with: + cache-read-only: true + - name: Execute Gradle build and verify cached configuration env: VERIFY_CACHED_CONFIGURATION: true - with: - build-root-directory: __tests__/samples/groovy-dsl - arguments: test --configuration-cache - cache-read-only: true + working-directory: __tests__/samples/groovy-dsl + run: ./gradlew test --configuration-cache - # Test restore configuration-cache from second build invocation - configuration-cache-2: + # Test restore configuration-cache from the second build invocation + configuration-cache-kotlin: needs: seed-build strategy: matrix: @@ -61,14 +59,15 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v2 - - name: Execute Gradle build and verify cached configuration + - name: Setup Gradle uses: ./ + with: + cache-read-only: true + - name: Execute Gradle build and verify cached configuration env: VERIFY_CACHED_CONFIGURATION: true - with: - build-root-directory: __tests__/samples/kotlin-dsl - arguments: test --configuration-cache - cache-read-only: true + working-directory: __tests__/samples/kotlin-dsl + run: ./gradlew test --configuration-cache # Check that the build can run when no extracted cache entries are restored no-extracted-cache-entries-restored: @@ -80,11 +79,11 @@ jobs: steps: - name: Checkout sources 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: ./ with: - build-root-directory: __tests__/samples/groovy-dsl - arguments: test --configuration-cache cache-read-only: true 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 diff --git a/.github/workflows/integTest-caching-gradle-home.yml b/.github/workflows/integTest-caching-gradle-home.yml index b3a4eee..86ebd57 100644 --- a/.github/workflows/integTest-caching-gradle-home.yml +++ b/.github/workflows/integTest-caching-gradle-home.yml @@ -10,8 +10,6 @@ env: GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}- 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: strategy: matrix: @@ -20,11 +18,11 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v2 - - name: Build using Gradle wrapper + - name: Setup Gradle uses: ./ - with: - build-root-directory: __tests__/samples/groovy-dsl - arguments: test + - 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 dependencies-cache: @@ -36,12 +34,13 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v2 - - name: Execute Gradle build with --offline + - name: Setup Gradle uses: ./ with: - build-root-directory: __tests__/samples/groovy-dsl - arguments: test --offline 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 build-cache: @@ -53,12 +52,13 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v2 - - name: Execute Gradle build and verify tasks from cache + - name: Setup Gradle uses: ./ with: - build-root-directory: __tests__/samples/groovy-dsl - arguments: test -DverifyCachedBuild=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 no-extracted-cache-entries-restored: @@ -70,11 +70,12 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v2 - - name: Execute Gradle build with no extracted cache entries restored + - name: Setup Gradle with no extracted cache entries restored uses: ./ with: - build-root-directory: __tests__/samples/groovy-dsl - arguments: test cache-read-only: true gradle-home-extracted-cache-entries: '[]' + - name: Check executee Gradle build + working-directory: __tests__/samples/groovy-dsl + run: ./gradlew test diff --git a/.github/workflows/integTest-gradle-user-home.yml b/.github/workflows/integTest-gradle-user-home.yml index 6989ef8..47cd34f 100644 --- a/.github/workflows/integTest-gradle-user-home.yml +++ b/.github/workflows/integTest-gradle-user-home.yml @@ -8,7 +8,7 @@ on: env: 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: # Run initial Gradle builds to push initial cache entries @@ -21,11 +21,11 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v2 - - name: Build using Gradle wrapper + - name: Setup Gradle uses: ./ - with: - build-root-directory: __tests__/samples/groovy-dsl - arguments: test + - name: Build using Gradle wrapper + working-directory: __tests__/samples/groovy-dsl + run: ./gradlew test --info # Test that the gradle-user-home cache will cache dependencies, by running build with --offline dependencies-cache: @@ -37,12 +37,13 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v2 - - name: Execute Gradle build with --offline + - name: Setup Gradle uses: ./ with: - build-root-directory: __tests__/samples/groovy-dsl - arguments: test --offline 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 build-cache: @@ -54,9 +55,10 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v2 - - name: Execute Gradle build and verify tasks from cache + - name: Setup Gradle uses: ./ with: - build-root-directory: __tests__/samples/groovy-dsl - arguments: test -DverifyCachedBuild=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 diff --git a/.github/workflows/integTest-gradle-versions.yml b/.github/workflows/integTest-gradle-versions.yml new file mode 100644 index 0000000..628b554 --- /dev/null +++ b/.github/workflows/integTest-gradle-versions.yml @@ -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') + + diff --git a/.github/workflows/integTest-kotlin-dsl.yml b/.github/workflows/integTest-kotlin-dsl.yml index d0d80b2..cb909ae 100644 --- a/.github/workflows/integTest-kotlin-dsl.yml +++ b/.github/workflows/integTest-kotlin-dsl.yml @@ -20,11 +20,11 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v2 - - name: Build kotlin-dsl project + - name: Setup Gradle uses: ./ - with: - build-root-directory: __tests__/samples/kotlin-dsl - arguments: test + - name: Build kotlin-dsl project + working-directory: __tests__/samples/kotlin-dsl + run: ./gradlew test # Check that the build can run --offline verify-build: @@ -36,8 +36,8 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v2 - - name: Build kotlin-dsl project + - name: Setup Gradle uses: ./ - with: - build-root-directory: __tests__/samples/kotlin-dsl - arguments: test --offline + - name: Build kotlin-dsl project + working-directory: __tests__/samples/kotlin-dsl + run: ./gradlew test --offline diff --git a/.github/workflows/pr-build-scan-comment.yml b/.github/workflows/pr-build-scan-comment.yml index 0700026..f6e3337 100644 --- a/.github/workflows/pr-build-scan-comment.yml +++ b/.github/workflows/pr-build-scan-comment.yml @@ -8,11 +8,10 @@ jobs: - uses: actions/setup-java@v1 with: java-version: 11 - - uses: gradle/gradle-build-action@v2 - id: gradle - with: - build-root-directory: __tests__/samples/kotlin-dsl - arguments: help + - uses: ./ + - id: gradle + working-directory: __tests__/samples/kotlin-dsl + run: ./gradlew help - name: "Comment build scan url" uses: actions/github-script@v3 with: