Skip to content

Commit 98ceab7

Browse files
cdce8pPierre-Sassoulas
authored andcommitted
Update Primer venv caching [ci] (#7708)
* Use release version for astroid * Use better cache key * Mirror create environment * Update comments
1 parent d56f848 commit 98ceab7

File tree

5 files changed

+14
-17
lines changed

5 files changed

+14
-17
lines changed

.github/workflows/primer_comment.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ jobs:
5050
path: venv
5151
key:
5252
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
53-
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}
53+
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{ hashFiles('pyproject.toml',
54+
'requirements_test.txt', 'requirements_test_min.txt') }}
5455
- name: Fail job if Python cache restore failed
5556
if: steps.cache-venv.outputs.cache-hit != 'true'
5657
run: |

.github/workflows/primer_run_main.yaml

+3-9
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ jobs:
3737
python-version: ${{ matrix.python-version }}
3838
check-latest: true
3939

40-
- name: Get latest astroid commit
41-
id: get-astroid-sha
42-
run: |
43-
curl https://api.github.com/repos/PyCQA/astroid/commits |
44-
python -c "import json, sys; print(json.load(sys.stdin)[0]['sha'])" > astroid_sha.txt
45-
4640
# Create a re-usable virtual environment
4741
- name: Create Python virtual environment cache
4842
id: cache-venv
@@ -51,15 +45,15 @@ jobs:
5145
path: venv
5246
key:
5347
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
54-
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}
48+
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{ hashFiles('pyproject.toml',
49+
'requirements_test.txt', 'requirements_test_min.txt') }}
5550
- name: Create Python virtual environment
51+
if: steps.cache-venv.outputs.cache-hit != 'true'
5652
run: |
5753
python -m venv venv
5854
. venv/bin/activate
5955
python -m pip install -U pip setuptools wheel
6056
pip install -U -r requirements_test.txt
61-
# Use bleeding-edge astroid
62-
pip install git+https://github.com/PyCQA/astroid.git
6357
6458
# Cache primer packages
6559
- name: Get commit string

.github/workflows/primer_run_pr.yaml

+8-4
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,16 @@ jobs:
6060
path: venv
6161
key:
6262
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
63-
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}
64-
- name: Fail job if Python cache restore failed
63+
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{ hashFiles('pyproject.toml',
64+
'requirements_test.txt', 'requirements_test_min.txt') }}
65+
# Create environment must match step in 'Primer / Main'
66+
- name: Create Python virtual environment
6567
if: steps.cache-venv.outputs.cache-hit != 'true'
6668
run: |
67-
echo "Failed to restore Python venv from cache"
68-
exit 1
69+
python -m venv venv
70+
. venv/bin/activate
71+
python -m pip install -U pip setuptools wheel
72+
pip install -U -r requirements_test.txt
6973
7074
# Cache primer packages
7175
- name: Download last 'main' run info

pyproject.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ requires-python = ">=3.7.2"
3434
dependencies = [
3535
"dill>=0.2",
3636
"platformdirs>=2.2.0",
37-
# Also upgrade requirements_test_min.txt and all the CACHE_VERSION for primer tests
38-
# in github actions if you are bumping astroid.
37+
# Also upgrade requirements_test_min.txt.
3938
# Pinned to dev of second minor update to allow editable installs and fix primer issues,
4039
# see https://github.com/PyCQA/astroid/issues/1341
4140
"astroid>=2.12.12,<=2.14.0-dev0",

requirements_test_min.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
-e .[testutils,spelling]
22
# astroid dependency is also defined in pyproject.toml
3-
# You need to increment the CACHE_VERSION for primer tests in github actions too
43
astroid==2.12.12 # Pinned to a specific version for tests
54
typing-extensions~=4.3
65
py~=1.11.0

0 commit comments

Comments
 (0)