Skip to content

Commit

Permalink
Update Primer venv caching [ci] (#7708)
Browse files Browse the repository at this point in the history
* Use release version for astroid
* Use better cache key
* Mirror create environment
* Update comments
  • Loading branch information
cdce8p authored and Pierre-Sassoulas committed Nov 17, 2022
1 parent d56f848 commit 98ceab7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/primer_comment.yaml
Expand Up @@ -50,7 +50,8 @@ jobs:
path: venv
key:
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{ hashFiles('pyproject.toml',
'requirements_test.txt', 'requirements_test_min.txt') }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/primer_run_main.yaml
Expand Up @@ -37,12 +37,6 @@ jobs:
python-version: ${{ matrix.python-version }}
check-latest: true

- name: Get latest astroid commit
id: get-astroid-sha
run: |
curl https://api.github.com/repos/PyCQA/astroid/commits |
python -c "import json, sys; print(json.load(sys.stdin)[0]['sha'])" > astroid_sha.txt
# Create a re-usable virtual environment
- name: Create Python virtual environment cache
id: cache-venv
Expand All @@ -51,15 +45,15 @@ jobs:
path: venv
key:
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{ hashFiles('pyproject.toml',
'requirements_test.txt', 'requirements_test_min.txt') }}
- name: Create Python virtual environment
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
python -m venv venv
. venv/bin/activate
python -m pip install -U pip setuptools wheel
pip install -U -r requirements_test.txt
# Use bleeding-edge astroid
pip install git+https://github.com/PyCQA/astroid.git
# Cache primer packages
- name: Get commit string
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/primer_run_pr.yaml
Expand Up @@ -60,12 +60,16 @@ jobs:
path: venv
key:
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}
- name: Fail job if Python cache restore failed
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{ hashFiles('pyproject.toml',
'requirements_test.txt', 'requirements_test_min.txt') }}
# Create environment must match step in 'Primer / Main'
- name: Create Python virtual environment
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
echo "Failed to restore Python venv from cache"
exit 1
python -m venv venv
. venv/bin/activate
python -m pip install -U pip setuptools wheel
pip install -U -r requirements_test.txt
# Cache primer packages
- name: Download last 'main' run info
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Expand Up @@ -34,8 +34,7 @@ requires-python = ">=3.7.2"
dependencies = [
"dill>=0.2",
"platformdirs>=2.2.0",
# Also upgrade requirements_test_min.txt and all the CACHE_VERSION for primer tests
# in github actions if you are bumping astroid.
# Also upgrade requirements_test_min.txt.
# Pinned to dev of second minor update to allow editable installs and fix primer issues,
# see https://github.com/PyCQA/astroid/issues/1341
"astroid>=2.12.12,<=2.14.0-dev0",
Expand Down
1 change: 0 additions & 1 deletion requirements_test_min.txt
@@ -1,6 +1,5 @@
-e .[testutils,spelling]
# astroid dependency is also defined in pyproject.toml
# You need to increment the CACHE_VERSION for primer tests in github actions too
astroid==2.12.12 # Pinned to a specific version for tests
typing-extensions~=4.3
py~=1.11.0
Expand Down

0 comments on commit 98ceab7

Please sign in to comment.