Unverified Commit f804351b authored by Daz DeBoer's avatar Daz DeBoer Committed by GitHub
Browse files

Merge pull request #131 from gradle/cache-jdks

- Cache downloaded Java Toolchains
- Treat configuration-cache entries as extracted entries
parents c208b4c1 39e51526
Loading
Loading
Loading
Loading
+4 −20
Changes for .github/workflows/integTest-caching-config.yml: 4 added lines, 20 removed lines.
Original line number Diff line number Diff line
@@ -22,21 +22,13 @@ jobs:
    - name: Setup Gradle
      uses: ./
      with:
        # Add "wrapper" to main cache entry and remove 'wrapper-zips' cache entry
        # Exclude build-cache from main cache entry
        # Add "enterprise" to main cache entry but omit "notifications"
        gradle-home-cache-includes: |
            caches
            notifications
            wrapper
            enterprise
        # Exclude build-cache from main cache entry
        gradle-home-cache-excludes: |
            caches/build-cache-1
        gradle-home-extracted-cache-entries: |
            [
              ["generated-gradle-jars", "caches/*/generated-gradle-jars/*.jar"],
              ["dependencies", "caches/modules-*/files-*/*/*/*/*/"],
              ["instrumented-jars", "caches/jars-*/*/"],
              ["kotlin-dsl", "caches/*/kotlin-dsl/*/*/"]
            ]
    - name: Build using Gradle wrapper
      working-directory: __tests__/samples/groovy-dsl
      run: ./gradlew test
@@ -57,17 +49,9 @@ jobs:
        # Use the same configuration when restoring state from cache
        gradle-home-cache-includes: |
            caches
            notifications
            wrapper
            enterprise
        gradle-home-cache-excludes: |
            caches/build-cache-1
        gradle-home-extracted-cache-entries: |
            [
              ["generated-gradle-jars", "caches/*/generated-gradle-jars/*.jar"],
              ["dependencies", "caches/modules-*/files-*/*/*/*/*/"],
              ["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
+57 −19
Changes for .github/workflows/integTest-caching-configuration-cache.yml: 57 added lines, 19 removed lines.
Original line number Diff line number Diff line
@@ -7,13 +7,14 @@ on:
  workflow_dispatch:

env:
  GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}-
  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:
  seed-build-groovy:
    env:
      GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}-groovy-
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
@@ -26,12 +27,11 @@ jobs:
    - 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

  configuration-cache-groovy:
    needs: seed-build
    env:
      GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}-groovy-
    needs: seed-build-groovy
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
@@ -49,9 +49,11 @@ jobs:
      working-directory: __tests__/samples/groovy-dsl
      run: ./gradlew test --configuration-cache

  # Test restore configuration-cache from the second build invocation
  configuration-cache-kotlin:
    needs: seed-build
  # Check that the build can run when no extracted cache entries are restored
  no-extracted-cache-entries-restored:
    env:
      GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}-groovy-
    needs: seed-build-groovy
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
@@ -59,19 +61,54 @@ jobs:
    steps:
    - name: Checkout sources
      uses: actions/checkout@v2
    - name: Setup Gradle
    - name: Setup Gradle with no extracted cache entries restored
      uses: ./
      env: 
        GRADLE_BUILD_ACTION_SKIP_RESTORE: "generated-gradle-jars|wrapper-zips|java-toolchains|instrumented-jars|dependencies|kotlin-dsl"
      with:
        cache-read-only: true
    - name: Execute Gradle build and verify cached configuration
    - name: Check execute Gradle build with configuration cache enabled (but not restored)
      working-directory: __tests__/samples/groovy-dsl
      run: ./gradlew test --configuration-cache

  seed-build-kotlin:
    env:
        VERIFY_CACHED_CONFIGURATION: true
      GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}-kotlin-
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
    - name: Checkout sources
      uses: actions/checkout@v2
    - name: Setup Gradle
      uses: ./
    - name: Kotlin build with configuration-cache enabled
      working-directory: __tests__/samples/kotlin-dsl
      run: ./gradlew help --configuration-cache

  modify-build-kotlin:
    env:
      GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}-kotlin-
    needs: seed-build-kotlin
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
    - name: Checkout sources
      uses: actions/checkout@v2
    - name: Setup Gradle
      uses: ./
    - name: Kotlin build with configuration-cache enabled
      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:
    needs: seed-build
 # Test restore configuration-cache from the third build invocation
  configuration-cache-kotlin:
    env:
      GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}-kotlin-
    needs: modify-build-kotlin
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
@@ -79,11 +116,12 @@ jobs:
    steps:
    - name: Checkout sources
      uses: actions/checkout@v2
    - name: Setup Gradle with no cache extracted cache entries restored
    - name: Setup Gradle
      uses: ./
      with:
        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
    - name: Execute Gradle build and verify cached configuration
      env: 
        VERIFY_CACHED_CONFIGURATION: true
      working-directory: __tests__/samples/kotlin-dsl
      run: ./gradlew test --configuration-cache
+2 −1
Changes for .github/workflows/integTest-caching-gradle-home.yml: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -72,9 +72,10 @@ jobs:
      uses: actions/checkout@v2
    - name: Setup Gradle with no extracted cache entries restored
      uses: ./
      env: 
        GRADLE_BUILD_ACTION_SKIP_RESTORE: "generated-gradle-jars|wrapper-zips|java-toolchains|instrumented-jars|dependencies|kotlin-dsl"
      with:
        cache-read-only: true
        gradle-home-extracted-cache-entries: '[]'
    - name: Check executee Gradle build
      working-directory: __tests__/samples/groovy-dsl
      run: ./gradlew test
+43
Changes for .github/workflows/integTest-caching-java-toolchain.yml: 43 added lines, 0 removed lines.
Original line number Diff line number Diff line
name: Test save/restore java toolchains

on:
  pull_request:
    types: [assigned, review_requested]
  push:
  workflow_dispatch:

env:
  GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: ${{github.workflow}}#${{github.run_number}}-

jobs:
  seed-build:
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
    - name: Checkout sources
      uses: actions/checkout@v2
    - name: Setup Gradle
      uses: ./
    - name: Build using Gradle wrapper
      working-directory: __tests__/samples/java-toolchain
      run: ./gradlew test --info

  # Test that the gradle-user-home cache will cache the toolchain, by running build with --offline
  toolchain-cache:
    needs: seed-build
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
    - name: Checkout sources
      uses: actions/checkout@v2
    - name: Setup Gradle
      uses: ./
      with:
        cache-read-only: true
    - name: Execute Gradle build with --offline
      working-directory: __tests__/samples/java-toolchain
      run: ./gradlew test --info --offline
+17
Changes for __tests__/samples/java-toolchain/build.gradle: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
plugins {
    id 'java'
}

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(16)
    }
}

repositories {
    mavenCentral()
}

dependencies {
    testImplementation('junit:junit:4.12')
}
 No newline at end of file
Loading