Skip to content

Commit

Permalink
Use a different cache key in workflow runs.
Browse files Browse the repository at this point in the history
Related #33
  • Loading branch information
aholmes committed Jan 12, 2024
1 parent df53785 commit 4b69987
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/CICD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down Expand Up @@ -58,7 +58,10 @@ jobs:
id: cache-repository-build
with:
path: ${{ github.workspace }}
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
# Use the same cache between Workflow runs _except_ when the event is a workflow_dispatch.
# This should result in cache keys like "Linux-true-abc123" for all runs _except_ workflow_dispatch,
# and cache keys like "linux-123-abc123" for workflow_dispatch.
key: ${{ runner.os }}-${{ github.event_name != 'workflow_dispatch' || github.run_attempt }}-${{ hashFiles('pyproject.toml', 'src/*/pyproject.toml') }}

Pyright:
name: Static type checking
Expand All @@ -71,12 +74,14 @@ jobs:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v4

- uses: actions/cache/restore@v3
name: Restore repository build
id: restore-repository-build
with:
path: path/to/dependencies
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
key: ${{ runner.os }}-${{ github.event_name != 'workflow_dispatch' || github.run_attempt }}-${{ hashFiles('pyproject.toml', 'src/*/pyproject.toml') }}

- name: Test with pyright
run: |
Expand All @@ -95,12 +100,14 @@ jobs:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v4

- uses: actions/cache/restore@v3
name: Restore repository build
id: restore-repository-build
with:
path: path/to/dependencies
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
key: ${{ runner.os }}-${{ github.event_name != 'workflow_dispatch' || github.run_attempt }}-${{ hashFiles('pyproject.toml', 'src/*/pyproject.toml') }}

- name: Test with pytest and generate reports
run: |
Expand Down Expand Up @@ -134,12 +141,14 @@ jobs:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v4

- uses: actions/cache/restore@v3
name: Restore repository build
id: restore-repository-build
with:
path: path/to/dependencies
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
key: ${{ runner.os }}-${{ github.event_name != 'workflow_dispatch' || github.run_attempt }}-${{ hashFiles('pyproject.toml', 'src/*/pyproject.toml') }}

- name: Check code style
run: |
Expand Down

0 comments on commit 4b69987

Please sign in to comment.