Skip to content

Commit

Permalink
Add much more comprehensive cache testing
Browse files Browse the repository at this point in the history
  • Loading branch information
me-and committed Jan 10, 2023
1 parent 8ad2694 commit 0066f67
Show file tree
Hide file tree
Showing 2 changed files with 193 additions and 31 deletions.
193 changes: 193 additions & 0 deletions .github/workflows/cache-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
name: Caching tests

on: [push, pull_request]

# Ensure there's only a single version of this running in any repo, so one set
# of tests won't create or destroy caches that interfere with another run.
concurrency: caches

jobs:
clear-caches:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
# This will only delete up to 100 caches. That should be far more than
# is ever needed.
- name: Delete cache entries
uses: actions/github-script@v6
with:
script: |
const response = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 100,
key: 'cygwin-install-action-packages-'
});
for (const cache of response.data.actions_caches) {
await github.rest.actions.deleteActionsCacheById({
owner: context.repo.owner,
repo: context.repo.repo,
cache_id: cache.id
});
}
test-caching:
runs-on: windows-latest

needs: clear-caches

# Ordering is important here to ensure the correct things are in the
# correct caches at the correct times.
#
# This also relies on having six Cygwin packages that don't have any
# cross-dependencies (and ideally are small and have few dependencies of
# their own), so we can distinguish what's cached at what step.
#
# We test for the correct behaviour in the following circumstances:
#
# option | saves | restores
# ------------+---------+----------
# disabled | no (1) | no (5)
# enabled | yes (2) | yes (6)
# saveonly | yes (3) | no (7)
# restoreonly | no (4) | yes (8)
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Cygwin + bash_completion, no caching
uses: ./
with:
packages: bash-completion
package-cache: disabled

- name: Delete the Cygwin installation and downloaded packages
run: |
Remove-Item -Force -Recurse C:\cygwin
Remove-Item -Force -Recurse C:\cygwin-packages
Remove-Item -Force -Recurse C:\cygwin-packages-checksum.*
- name: Install Cygwin + brotli, with caching
uses: ./
with:
packages: brotli
package-cache: enabled

# This assumes 6 and tests 1
- name: Ensure bash-completion not downloaded
shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0}
run: |
for file in /cygdrive/c/cygwin-packages/*/*/*/*/bash-completion-*.tar.*; do
[[ -f "$file" ]] && exit 1
done
exit 0
- name: Delete the Cygwin installation and downloaded packages
run: |
Remove-Item -Force -Recurse C:\cygwin
Remove-Item -Force -Recurse C:\cygwin-packages
Remove-Item -Force -Recurse C:\cygwin-packages-checksum.*
- name: Install Cygwin + libyajl2, with caching
uses: ./
with:
packages: libyajl2
package-cache: enabled

# This tests 2 and 6
- name: Ensure brotli downloaded
shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0}
run: |
for file in /cygdrive/c/cygwin-packages/*/*/*/*/brotli-*.tar.*; do
[[ -f "$file" ]] && exit 0
done
exit 1
- name: Delete the Cygwin installation and downloaded packages
run: |
Remove-Item -Force -Recurse C:\cygwin
Remove-Item -Force -Recurse C:\cygwin-packages
Remove-Item -Force -Recurse C:\cygwin-packages-checksum.*
- name: Install Cygwin + mksh, saveonly
uses: ./
with:
packages: mksh
package-cache: saveonly

# This assumes 2 and tests 7
- name: Ensure libyajl2 not downloaded
shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0}
run: |
for file in /cygdrive/c/cygwin-packages/*/*/*/*/libyajl2-*.tar.*; do
[[ -f "$file" ]] && exit 1
done
exit 0
- name: Delete the Cygwin installation and downloaded packages
run: |
Remove-Item -Force -Recurse C:\cygwin
Remove-Item -Force -Recurse C:\cygwin-packages
Remove-Item -Force -Recurse C:\cygwin-packages-checksum.*
- name: Install Cygwin + libgif7, restoreonly
uses: ./
with:
packages: libgif7
package-cache: restoreonly

# This tests 3 and 8
- name: Ensure mksh downloaded
shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0}
run: |
for file in /cygdrive/c/cygwin-packages/*/*/*/*/mksh-*.tar.*; do
[[ -f "$file" ]] && exit 1
done
exit 0
- name: Delete the Cygwin installation and downloaded packages
run: |
Remove-Item -Force -Recurse C:\cygwin
Remove-Item -Force -Recurse C:\cygwin-packages
Remove-Item -Force -Recurse C:\cygwin-packages-checksum.*
- name: Install Cygwin, restoreonly
uses: ./
with:
package-cache: restoreonly

# This assumes 8 and tests 4
- name: Ensure libgif7 not downloaded
shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0}
run: |
for file in /cygdrive/c/cygwin-packages/*/*/*/*/libgif7-*.tar.*; do
[[ -f "$file" ]] && exit 1
done
exit 0
- name: Delete the Cygwin installation and downloaded packages
run: |
Remove-Item -Force -Recurse C:\cygwin
Remove-Item -Force -Recurse C:\cygwin-packages
Remove-Item -Force -Recurse C:\cygwin-packages-checksum.*
- name: Install Cygwin, caching disabled
uses: ./
with:
package-cache: disabled

# This assumes 3 and tests 5
- name: Ensure mksh not downloaded
shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0}
run: |
for file in /cygdrive/c/cygwin-packages/*/*/*/*/mksh-*.tar.*; do
[[ -f "$file" ]] && exit 1
done
exit 0
- name: Delete the Cygwin installation and downloaded packages
run: |
Remove-Item -Force -Recurse C:\cygwin
Remove-Item -Force -Recurse C:\cygwin-packages
Remove-Item -Force -Recurse C:\cygwin-packages-checksum.*
31 changes: 0 additions & 31 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,34 +228,3 @@ jobs:
shell: bash
env:
SHELLOPTS: igncr

caching:
runs-on: windows-latest

name: 'Test use of the cache'

steps:
- run: git config --global core.autocrlf input
- uses: actions/checkout@v2
- name: Install Cygwin and bash-completion
uses: ./
with:
packages: bash-completion
package-cache: enabled
add-to-path: false
- name: Delete Cygwin installation and cache
run: |
Remove-Item -Force -Recurse C:\cygwin
Remove-Item -Force -Recurse C:\cygwin-packages
- name: Reinstall Cygwin only
uses: ./
with:
package-cache-key: enabled
add-to-path: false
- name: Find bash-completion in the package cache
shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0}
run: |
for file in /cygdrive/c/cygwin-packages/*/*/*/bash-completion/bash-completion-*.tar.*; do
[[ -f "$file" ]] && exit 0 # File actually exists
done
exit 1 # No such downloaded file

0 comments on commit 0066f67

Please sign in to comment.