|
| 1 | +name: Caching tests |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +# Ensure there's only a single version of this running in any repo, so one set |
| 6 | +# of tests won't create or destroy caches that interfere with another run. |
| 7 | +concurrency: caches |
| 8 | + |
| 9 | +jobs: |
| 10 | + clear-caches: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + actions: write |
| 14 | + steps: |
| 15 | + # This will only delete up to 100 caches. That should be far more than |
| 16 | + # is ever needed. |
| 17 | + - name: Delete cache entries |
| 18 | + uses: actions/github-script@v6 |
| 19 | + with: |
| 20 | + script: | |
| 21 | + const response = await github.rest.actions.getActionsCacheList({ |
| 22 | + owner: context.repo.owner, |
| 23 | + repo: context.repo.repo, |
| 24 | + per_page: 100, |
| 25 | + key: 'cygwin-install-action-packages-' |
| 26 | + }); |
| 27 | + for (const cache of response.data.actions_caches) { |
| 28 | + await github.rest.actions.deleteActionsCacheById({ |
| 29 | + owner: context.repo.owner, |
| 30 | + repo: context.repo.repo, |
| 31 | + cache_id: cache.id |
| 32 | + }); |
| 33 | + } |
| 34 | +
|
| 35 | + test-caching: |
| 36 | + runs-on: windows-latest |
| 37 | + |
| 38 | + needs: clear-caches |
| 39 | + |
| 40 | + # Ordering is important here to ensure the correct things are in the |
| 41 | + # correct caches at the correct times. |
| 42 | + # |
| 43 | + # This also relies on having six Cygwin packages that don't have any |
| 44 | + # cross-dependencies (and ideally are small and have few dependencies of |
| 45 | + # their own), so we can distinguish what's cached at what step. |
| 46 | + # |
| 47 | + # We test for the correct behaviour in the following circumstances: |
| 48 | + # |
| 49 | + # option | saves | restores |
| 50 | + # ------------+---------+---------- |
| 51 | + # disabled | no (1) | no (5) |
| 52 | + # enabled | yes (2) | yes (6) |
| 53 | + # saveonly | yes (3) | no (7) |
| 54 | + # restoreonly | no (4) | yes (8) |
| 55 | + steps: |
| 56 | + - name: Checkout |
| 57 | + uses: actions/checkout@v3 |
| 58 | + |
| 59 | + - name: Install Cygwin + bash_completion, no caching |
| 60 | + uses: ./ |
| 61 | + with: |
| 62 | + packages: bash-completion |
| 63 | + package-cache: disabled |
| 64 | + |
| 65 | + - name: Delete the Cygwin installation and downloaded packages |
| 66 | + run: | |
| 67 | + Remove-Item -Force -Recurse C:\cygwin |
| 68 | + Remove-Item -Force -Recurse C:\cygwin-packages |
| 69 | + Remove-Item -Force -Recurse C:\cygwin-packages-checksum.* |
| 70 | +
|
| 71 | + - name: Install Cygwin + brotli, with caching |
| 72 | + uses: ./ |
| 73 | + with: |
| 74 | + packages: brotli |
| 75 | + package-cache: enabled |
| 76 | + |
| 77 | + # This assumes 6 and tests 1 |
| 78 | + - name: Ensure bash-completion not downloaded |
| 79 | + shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0} |
| 80 | + run: | |
| 81 | + for file in /cygdrive/c/cygwin-packages/*/*/*/*/bash-completion-*.tar.*; do |
| 82 | + [[ -f "$file" ]] && exit 1 |
| 83 | + done |
| 84 | + exit 0 |
| 85 | +
|
| 86 | + - name: Delete the Cygwin installation and downloaded packages |
| 87 | + run: | |
| 88 | + Remove-Item -Force -Recurse C:\cygwin |
| 89 | + Remove-Item -Force -Recurse C:\cygwin-packages |
| 90 | + Remove-Item -Force -Recurse C:\cygwin-packages-checksum.* |
| 91 | +
|
| 92 | + - name: Install Cygwin + libyajl2, with caching |
| 93 | + uses: ./ |
| 94 | + with: |
| 95 | + packages: libyajl2 |
| 96 | + package-cache: enabled |
| 97 | + |
| 98 | + # This tests 2 and 6 |
| 99 | + - name: Ensure brotli downloaded |
| 100 | + shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0} |
| 101 | + run: | |
| 102 | + for file in /cygdrive/c/cygwin-packages/*/*/*/*/brotli-*.tar.*; do |
| 103 | + [[ -f "$file" ]] && exit 0 |
| 104 | + done |
| 105 | + exit 1 |
| 106 | +
|
| 107 | + - name: Delete the Cygwin installation and downloaded packages |
| 108 | + run: | |
| 109 | + Remove-Item -Force -Recurse C:\cygwin |
| 110 | + Remove-Item -Force -Recurse C:\cygwin-packages |
| 111 | + Remove-Item -Force -Recurse C:\cygwin-packages-checksum.* |
| 112 | +
|
| 113 | + - name: Install Cygwin + mksh, saveonly |
| 114 | + uses: ./ |
| 115 | + with: |
| 116 | + packages: mksh |
| 117 | + package-cache: saveonly |
| 118 | + |
| 119 | + # This assumes 2 and tests 7 |
| 120 | + - name: Ensure libyajl2 not downloaded |
| 121 | + shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0} |
| 122 | + run: | |
| 123 | + for file in /cygdrive/c/cygwin-packages/*/*/*/*/libyajl2-*.tar.*; do |
| 124 | + [[ -f "$file" ]] && exit 1 |
| 125 | + done |
| 126 | + exit 0 |
| 127 | +
|
| 128 | + - name: Delete the Cygwin installation and downloaded packages |
| 129 | + run: | |
| 130 | + Remove-Item -Force -Recurse C:\cygwin |
| 131 | + Remove-Item -Force -Recurse C:\cygwin-packages |
| 132 | + Remove-Item -Force -Recurse C:\cygwin-packages-checksum.* |
| 133 | +
|
| 134 | + - name: Install Cygwin + libgif7, restoreonly |
| 135 | + uses: ./ |
| 136 | + with: |
| 137 | + packages: libgif7 |
| 138 | + package-cache: restoreonly |
| 139 | + |
| 140 | + # This tests 3 and 8 |
| 141 | + - name: Ensure mksh downloaded |
| 142 | + shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0} |
| 143 | + run: | |
| 144 | + for file in /cygdrive/c/cygwin-packages/*/*/*/*/mksh-*.tar.*; do |
| 145 | + [[ -f "$file" ]] && exit 1 |
| 146 | + done |
| 147 | + exit 0 |
| 148 | +
|
| 149 | + - name: Delete the Cygwin installation and downloaded packages |
| 150 | + run: | |
| 151 | + Remove-Item -Force -Recurse C:\cygwin |
| 152 | + Remove-Item -Force -Recurse C:\cygwin-packages |
| 153 | + Remove-Item -Force -Recurse C:\cygwin-packages-checksum.* |
| 154 | +
|
| 155 | + - name: Install Cygwin, restoreonly |
| 156 | + uses: ./ |
| 157 | + with: |
| 158 | + package-cache: restoreonly |
| 159 | + |
| 160 | + # This assumes 8 and tests 4 |
| 161 | + - name: Ensure libgif7 not downloaded |
| 162 | + shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0} |
| 163 | + run: | |
| 164 | + for file in /cygdrive/c/cygwin-packages/*/*/*/*/libgif7-*.tar.*; do |
| 165 | + [[ -f "$file" ]] && exit 1 |
| 166 | + done |
| 167 | + exit 0 |
| 168 | +
|
| 169 | + - name: Delete the Cygwin installation and downloaded packages |
| 170 | + run: | |
| 171 | + Remove-Item -Force -Recurse C:\cygwin |
| 172 | + Remove-Item -Force -Recurse C:\cygwin-packages |
| 173 | + Remove-Item -Force -Recurse C:\cygwin-packages-checksum.* |
| 174 | +
|
| 175 | + - name: Install Cygwin, caching disabled |
| 176 | + uses: ./ |
| 177 | + with: |
| 178 | + package-cache: disabled |
| 179 | + |
| 180 | + # This assumes 3 and tests 5 |
| 181 | + - name: Ensure mksh not downloaded |
| 182 | + shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0} |
| 183 | + run: | |
| 184 | + for file in /cygdrive/c/cygwin-packages/*/*/*/*/mksh-*.tar.*; do |
| 185 | + [[ -f "$file" ]] && exit 1 |
| 186 | + done |
| 187 | + exit 0 |
| 188 | +
|
| 189 | + - name: Delete the Cygwin installation and downloaded packages |
| 190 | + run: | |
| 191 | + Remove-Item -Force -Recurse C:\cygwin |
| 192 | + Remove-Item -Force -Recurse C:\cygwin-packages |
| 193 | + Remove-Item -Force -Recurse C:\cygwin-packages-checksum.* |
0 commit comments