From 4b69987da64d6c1d0aa2abcc35240c3421879334 Mon Sep 17 00:00:00 2001 From: Aaron Holmes Date: Fri, 12 Jan 2024 15:35:11 -0800 Subject: [PATCH] Use a different cache key in workflow runs. Related #33 --- .github/workflows/CICD.yaml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/CICD.yaml b/.github/workflows/CICD.yaml index 60111450..84b051f4 100644 --- a/.github/workflows/CICD.yaml +++ b/.github/workflows/CICD.yaml @@ -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 @@ -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 @@ -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: | @@ -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: | @@ -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: |