Test that image layers and compose volumes are getting cached #10
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| setup-and-cache: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/setup-compose-action@v1 | |
| - uses: ./ | |
| with: | |
| volumes: | | |
| node_modules: ${{ hashFiles('package-lock.json') }} | |
| - run: bin/setup | |
| test: | |
| needs: setup-and-cache | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/setup-compose-action@v1 | |
| - uses: ./ | |
| with: | |
| volumes: | | |
| node_modules: ${{ hashFiles('package-lock.json') }} | |
| - name: Verify caches are used | |
| run: | | |
| output=$(bin/setup 2>&1) | |
| # Check that all build steps (except FROM) have a CACHED line | |
| for step in $(echo "$output" | grep -E '^#[0-9]+ \[[0-9]+/[0-9]+\]' | grep -v FROM | grep -oE '^#[0-9]+'); do | |
| if ! echo "$output" | grep -q "^${step} CACHED"; then | |
| echo "::error::Step $step was rebuilt instead of using cache" | |
| echo "$output" | |
| exit 1 | |
| fi | |
| done | |
| echo "All build steps used cache." | |
| if echo "$output" | grep -q "added"; then | |
| echo "::error::Packages were downloaded instead of using cached node_modules" | |
| echo "$output" | |
| exit 1 | |
| fi | |
| echo "node_modules cache was used." |