|
| 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 | + |
| 57 | + - name: Install Cygwin + bash_completion, no caching |
| 58 | + uses: ./ |
| 59 | + with: |
| 60 | + packages: bash-completion |
| 61 | + package-cache: disabled |
| 62 | + |
| 63 | + - name: Delete the Cygwin installation and downloaded packages |
| 64 | + run: | |
| 65 | + Remove-Item -Force -Recurse C:\cygwin |
| 66 | + Remove-Item -Force -Recurse C:\cygwin-packages |
| 67 | + Remove-Item -Force -Recurse C:\cygwin-packages-checksum.* |
| 68 | +
|
| 69 | + - name: Install Cygwin + brotli, with caching |
| 70 | + uses: ./ |
| 71 | + with: |
| 72 | + packages: brotli |
| 73 | + package-cache: enabled |
| 74 | + |
| 75 | + # This assumes 6 and tests 1 |
| 76 | + - name: Ensure bash-completion not downloaded |
| 77 | + shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0} |
| 78 | + run: | |
| 79 | + for file in /cygdrive/c/cygwin-packages/*/*/*/*/bash-completion-*.tar.*; do |
| 80 | + [[ -f "$file" ]] && exit 1 |
| 81 | + fi |
| 82 | +
|
| 83 | + - name: Delete the Cygwin installation and downloaded packages |
| 84 | + run: | |
| 85 | + Remove-Item -Force -Recurse C:\cygwin |
| 86 | + Remove-Item -Force -Recurse C:\cygwin-packages |
| 87 | + Remove-Item -Force -Recurse C:\cygwin-packages-checksum.* |
| 88 | +
|
| 89 | + - name: Install Cygwin + libyajl2, with caching |
| 90 | + uses: ./ |
| 91 | + with: |
| 92 | + packages: libyajl2 |
| 93 | + package-cache: enabled |
| 94 | + |
| 95 | + # This tests 2 and 6 |
| 96 | + - name: Ensure brotli downloaded |
| 97 | + shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0} |
| 98 | + run: | |
| 99 | + for file in /cygdrive/c/cygwin-packages/*/*/*/*/brotli-*.tar.*; do |
| 100 | + [[ -f "$file" ]] && exit 0 |
| 101 | + fi |
| 102 | + exit 1 |
| 103 | +
|
| 104 | + - name: Delete the Cygwin installation and downloaded packages |
| 105 | + run: | |
| 106 | + Remove-Item -Force -Recurse C:\cygwin |
| 107 | + Remove-Item -Force -Recurse C:\cygwin-packages |
| 108 | + Remove-Item -Force -Recurse C:\cygwin-packages-checksum.* |
| 109 | +
|
| 110 | + - name: Install Cygwin + mksh, saveonly |
| 111 | + uses: ./ |
| 112 | + with: |
| 113 | + packages: mksh |
| 114 | + package-cache: saveonly |
| 115 | + |
| 116 | + # This assumes 2 and tests 7 |
| 117 | + - name: Ensure libyajl2 not downloaded |
| 118 | + shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0} |
| 119 | + run: | |
| 120 | + for file in /cygdrive/c/cygwin-packages/*/*/*/*/libyajl2-*.tar.*; do |
| 121 | + [[ -f "$file" ]] && exit 1 |
| 122 | + fi |
| 123 | +
|
| 124 | + - name: Delete the Cygwin installation and downloaded packages |
| 125 | + run: | |
| 126 | + Remove-Item -Force -Recurse C:\cygwin |
| 127 | + Remove-Item -Force -Recurse C:\cygwin-packages |
| 128 | + Remove-Item -Force -Recurse C:\cygwin-packages-checksum.* |
| 129 | +
|
| 130 | + - name: Install Cygwin + libgif7, restoreonly |
| 131 | + uses: ./ |
| 132 | + with: |
| 133 | + packages: libgif7 |
| 134 | + package-cache: restoreonly |
| 135 | + |
| 136 | + # This tests 3 and 8 |
| 137 | + - name: Ensure mksh downloaded |
| 138 | + shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0} |
| 139 | + run: | |
| 140 | + for file in /cygdrive/c/cygwin-packages/*/*/*/*/mksh-*.tar.*; do |
| 141 | + [[ -f "$file" ]] && exit 1 |
| 142 | + fi |
| 143 | +
|
| 144 | + - name: Delete the Cygwin installation and downloaded packages |
| 145 | + run: | |
| 146 | + Remove-Item -Force -Recurse C:\cygwin |
| 147 | + Remove-Item -Force -Recurse C:\cygwin-packages |
| 148 | + Remove-Item -Force -Recurse C:\cygwin-packages-checksum.* |
| 149 | +
|
| 150 | + - name: Install Cygwin, restoreonly |
| 151 | + uses: ./ |
| 152 | + with: |
| 153 | + package-cache: restoreonly |
| 154 | + |
| 155 | + # This assumes 8 and tests 4 |
| 156 | + - name: Ensure libgif7 not downloaded |
| 157 | + shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0} |
| 158 | + run: | |
| 159 | + for file in /cygdrive/c/cygwin-packages/*/*/*/*/libgif7-*.tar.*; do |
| 160 | + [[ -f "$file" ]] && exit 1 |
| 161 | + fi |
| 162 | +
|
| 163 | + - name: Delete the Cygwin installation and downloaded packages |
| 164 | + run: | |
| 165 | + Remove-Item -Force -Recurse C:\cygwin |
| 166 | + Remove-Item -Force -Recurse C:\cygwin-packages |
| 167 | + Remove-Item -Force -Recurse C:\cygwin-packages-checksum.* |
| 168 | +
|
| 169 | + - name: Install Cygwin, caching disabled |
| 170 | + uses: ./ |
| 171 | + with: |
| 172 | + package-cache: disabled |
| 173 | + |
| 174 | + # This assumes 3 and tests 5 |
| 175 | + - name: Ensure mksh not downloaded |
| 176 | + shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0} |
| 177 | + run: | |
| 178 | + for file in /cygdrive/c/cygwin-packages/*/*/*/*/mksh-*.tar.*; do |
| 179 | + [[ -f "$file" ]] && exit 1 |
| 180 | + fi |
| 181 | +
|
| 182 | + - name: Delete the Cygwin installation and downloaded packages |
| 183 | + run: | |
| 184 | + Remove-Item -Force -Recurse C:\cygwin |
| 185 | + Remove-Item -Force -Recurse C:\cygwin-packages |
| 186 | + Remove-Item -Force -Recurse C:\cygwin-packages-checksum.* |
0 commit comments