|
| 1 | +name: Validate cache with cache-dependency-path option |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - releases/* |
| 8 | + paths-ignore: |
| 9 | + - '**.md' |
| 10 | + pull_request: |
| 11 | + paths-ignore: |
| 12 | + - '**.md' |
| 13 | + |
| 14 | +defaults: |
| 15 | + run: |
| 16 | + shell: bash |
| 17 | + |
| 18 | +jobs: |
| 19 | + gradle1-save: |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + os: [macos-latest, windows-latest, ubuntu-latest] |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v3 |
| 28 | + - name: Run setup-java with the cache for gradle |
| 29 | + uses: ./ |
| 30 | + id: setup-java |
| 31 | + with: |
| 32 | + distribution: 'adopt' |
| 33 | + java-version: '11' |
| 34 | + cache: gradle |
| 35 | + cache-dependency-path: __tests__/cache/gradle1/*.gradle* |
| 36 | + - name: Create files to cache |
| 37 | + # Need to avoid using Gradle daemon to stabilize the save process on Windows |
| 38 | + # https://github.com/actions/cache/issues/454#issuecomment-840493935 |
| 39 | + run: | |
| 40 | + gradle downloadDependencies --no-daemon -p __tests__/cache/gradle1 |
| 41 | + if [ ! -d ~/.gradle/caches ]; then |
| 42 | + echo "::error::The ~/.gradle/caches directory does not exist unexpectedly" |
| 43 | + exit 1 |
| 44 | + fi |
| 45 | + gradle1-restore: |
| 46 | + runs-on: ${{ matrix.os }} |
| 47 | + strategy: |
| 48 | + fail-fast: false |
| 49 | + matrix: |
| 50 | + os: [macos-latest, windows-latest, ubuntu-latest] |
| 51 | + needs: gradle1-save |
| 52 | + steps: |
| 53 | + - name: Checkout |
| 54 | + uses: actions/checkout@v3 |
| 55 | + - name: Run setup-java with the cache for gradle |
| 56 | + uses: ./ |
| 57 | + id: setup-java |
| 58 | + with: |
| 59 | + distribution: 'adopt' |
| 60 | + java-version: '11' |
| 61 | + cache: gradle |
| 62 | + cache-dependency-path: __tests__/cache/gradle1/*.gradle* |
| 63 | + - name: Confirm that ~/.gradle/caches directory has been made |
| 64 | + run: | |
| 65 | + if [ ! -d ~/.gradle/caches ]; then |
| 66 | + echo "::error::The ~/.gradle/caches directory does not exist unexpectedly" |
| 67 | + exit 1 |
| 68 | + fi |
| 69 | + ls ~/.gradle/caches/ |
| 70 | + gradle2-restore: |
| 71 | + runs-on: ${{ matrix.os }} |
| 72 | + strategy: |
| 73 | + fail-fast: false |
| 74 | + matrix: |
| 75 | + os: [macos-latest, windows-latest, ubuntu-latest] |
| 76 | + needs: gradle1-save |
| 77 | + steps: |
| 78 | + - name: Checkout |
| 79 | + uses: actions/checkout@v3 |
| 80 | + - name: Run setup-java with the cache for gradle |
| 81 | + uses: ./ |
| 82 | + id: setup-java |
| 83 | + with: |
| 84 | + distribution: 'adopt' |
| 85 | + java-version: '11' |
| 86 | + cache: gradle |
| 87 | + cache-dependency-path: __tests__/cache/gradle2/*.gradle* |
| 88 | + - name: Confirm that ~/.gradle/caches directory has not been made |
| 89 | + run: | |
| 90 | + if [ -d ~/.gradle/caches ]; then |
| 91 | + echo "::error::The ~/.gradle/caches directory exists unexpectedly" |
| 92 | + exit 1 |
| 93 | + fi |
0 commit comments