actions / cache

Cache dependencies and build outputs in GitHub Actions
MIT License
4.49k stars 1.2k forks source link

Exclusions do not work #1356

Open pauldraper opened 6 months ago

pauldraper commented 6 months ago

Exclusions do not work.

Example:

jobs:
  save:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/cache@v3
      with:
        path: |
          cache
          !cache/unwanted
        key: ${{ github.workflow }}/${{ github.run_number }}-${{ github.run_attempt }}
    - run: |
        mkdir -p cache/wanted cache/unwanted
        > cache/wanted/example.txt
        > cache/unwanted/example.txt
  restore:
    needs: [save]
    runs-on: ubuntu-latest
    steps:
    - uses: actions/cache@v3
      with:
        fail-on-cache-miss: true
        path: |
          cache
          !cache/unwanted
        key: ${{ github.workflow }}/${{ github.run_number }}-${{ github.run_attempt }}
    - run: find cache > "$GITHUB_STEP_SUMMARY"
on: workflow_dispatch
name: Example

Outputs:

cache
cache/wanted
cache/wanted/example.txt
cache/unwanted
cache/unwanted/example.txt

Reference: https://github.com/actions/cache/blob/67b839edb68371cc5014f6cea11c9aa77238de78/examples.md#c---nuget


See #1215

miiihi commented 6 months ago

Doesn't work in latest actions/cache@v4 either

miiihi commented 6 months ago

bug originates in toolkit/cache see https://github.com/actions/toolkit/issues/713 for details and possible workarounds

Example in https://github.com/actions/cache/blob/main/examples.md#c---nuget has never worked and should be removed / commented. One would also expect that at least the examples in the documentation are covered with tests...