From 46a37edb7b3187af1ce5e680587d8f7bd75239c1 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Wed, 18 Sep 2024 17:39:03 -0300 Subject: [PATCH] Explicitly save cache in primer jobs Refs https://github.com/pylint-dev/pylint/pull/9925#issuecomment-2358249852 --- .github/workflows/primer_run_main.yaml | 27 +++++++++++++++++++++++--- .github/workflows/primer_run_pr.yaml | 24 +++++++++++++++++++++-- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/.github/workflows/primer_run_main.yaml b/.github/workflows/primer_run_main.yaml index 03f64c4052..c6de093794 100644 --- a/.github/workflows/primer_run_main.yaml +++ b/.github/workflows/primer_run_main.yaml @@ -43,9 +43,9 @@ jobs: check-latest: true # Create a re-usable virtual environment - - name: Create Python virtual environment cache + - name: Restore Python virtual environment cache id: cache-venv - uses: actions/cache@v4.0.2 + uses: actions/cache/restore@v4.0.2 with: path: venv key: @@ -60,6 +60,18 @@ jobs: . venv/bin/activate python -m pip install -U pip setuptools wheel pip install -U -r requirements_test.txt + # Save cached Python environment (explicit because cancel-in-progress: true) + - name: Save Python virtual environment to cache + if: steps.cache-venv.outputs.cache-hit != 'true' + id: cache-venv + uses: actions/cache/save@v4.0.2 + with: + path: venv + key: + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ + env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{ hashFiles('pyproject.toml', + 'requirements_test.txt', 'requirements_test_min.txt', + 'requirements_test_pre_commit.txt') }} # Cache primer packages - name: Get commit string @@ -71,7 +83,7 @@ jobs: echo "commitstring=$output" >> $GITHUB_OUTPUT - name: Restore projects cache id: cache-projects - uses: actions/cache@v4.0.2 + uses: actions/cache/restore@v4.0.2 with: path: tests/.pylint_primer_tests/ key: >- @@ -82,6 +94,15 @@ jobs: run: | . venv/bin/activate python tests/primer/__main__.py prepare --clone + - name: Save projects cache + if: steps.cache-projects.outputs.cache-hit != 'true' + id: cache-projects + uses: actions/cache/save@v4.0.2 + with: + path: tests/.pylint_primer_tests/ + key: >- + ${{ runner.os }}-${{ matrix.python-version }}-${{ + steps.commitstring.outputs.commitstring }}-primer - name: Upload commit string uses: actions/upload-artifact@v4.4.0 if: matrix.batchIdx == 0 diff --git a/.github/workflows/primer_run_pr.yaml b/.github/workflows/primer_run_pr.yaml index 80aa16b311..3f6dd50eee 100644 --- a/.github/workflows/primer_run_pr.yaml +++ b/.github/workflows/primer_run_pr.yaml @@ -56,7 +56,7 @@ jobs: # Restore cached Python environment - name: Restore Python virtual environment id: cache-venv - uses: actions/cache@v4.0.2 + uses: actions/cache/restore@v4.0.2 with: path: venv key: @@ -72,6 +72,18 @@ jobs: . venv/bin/activate python -m pip install -U pip setuptools wheel pip install -U -r requirements_test.txt + # Save cached Python environment (explicit because cancel-in-progress: true) + - name: Save Python virtual environment + if: steps.cache-venv.outputs.cache-hit != 'true' + id: cache-venv + uses: actions/cache/save@v4.0.2 + with: + path: venv + key: + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ + env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{ hashFiles('pyproject.toml', + 'requirements_test.txt', 'requirements_test_min.txt', + 'requirements_test_pre_commit.txt') }} # Cache primer packages - name: Download last 'main' run info @@ -140,7 +152,7 @@ jobs: echo "commitstring=$output" >> $GITHUB_OUTPUT - name: Restore projects cache id: cache-projects - uses: actions/cache@v4.0.2 + uses: actions/cache/restore@v4.0.2 with: path: tests/.pylint_primer_tests/ key: >- @@ -151,6 +163,14 @@ jobs: run: | . venv/bin/activate python tests/primer/__main__.py prepare --clone + - name: Save projects cache + if: steps.cache-projects.outputs.cache-hit != 'true' + uses: actions/cache/save@v4.0.2 + with: + path: tests/.pylint_primer_tests/ + key: >- + ${{ runner.os }}-${{ matrix.python-version }}-${{ + steps.commitstring.outputs.commitstring }}-primer - name: Check cache run: | . venv/bin/activate