Skip to content

Commit f949e3f

Browse files
authored
ci: Use setup-python v3/4's new caching system (#377)
1 parent 9d19f42 commit f949e3f

File tree

2 files changed

+20
-79
lines changed

2 files changed

+20
-79
lines changed

.github/workflows/docs.yml

+10-40
Original file line numberDiff line numberDiff line change
@@ -34,53 +34,23 @@ jobs:
3434
if: steps.changes.outputs.docs == 'true' || steps.changes.outputs.root_docs == 'true' || steps.changes.outputs.python_files == 'true'
3535
run: echo "PUBLISH=$(echo true)" >> $GITHUB_ENV
3636

37-
- name: Set up Python ${{ matrix.python-version }}
38-
uses: actions/setup-python@v3
39-
with:
40-
python-version: ${{ matrix.python-version }}
41-
42-
- name: Get full Python version
43-
id: full-python-version
44-
shell: bash
45-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
46-
4737
- name: Install poetry
48-
run: |
49-
curl -O -sSL https://install.python-poetry.org/install-poetry.py
50-
python install-poetry.py -y --version 1.1.14
51-
echo "PATH=${HOME}/.poetry/bin:${PATH}" >> $GITHUB_ENV
52-
rm install-poetry.py
38+
run: pipx install "poetry==1.1.14"
5339

54-
- name: Add ~/.local/bin to PATH
55-
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
56-
57-
- name: Get poetry cache paths from config
58-
run: |
59-
echo "poetry_virtualenvs_path=$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^\"//' -e 's/\"$//')" >> $GITHUB_ENV
60-
echo "poetry_virtualenvs_path=$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^\"//' -e 's/\"$//')" >> $GITHUB_ENV
61-
62-
- name: Configure poetry
63-
shell: bash
64-
run: poetry config virtualenvs.in-project true
65-
66-
- name: Set up cache
67-
uses: actions/cache@v3
68-
id: cache
40+
- name: Set up Python ${{ matrix.python-version }}
41+
uses: actions/setup-python@v4
6942
with:
70-
path: |
71-
.venv
72-
{{ env.poetry_cache_dir }}
73-
{{ env.poetry_virtualenvs_path }}
74-
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
75-
76-
- name: Ensure cache is healthy
77-
if: steps.cache.outputs.cache-hit == 'true'
78-
shell: bash
79-
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
43+
python-version: ${{ matrix.python-version }}
44+
cache: 'poetry'
8045

8146
- name: Install dependencies [w/ docs]
8247
run: poetry install --extras "docs lint"
8348

49+
- name: Print python versions
50+
run: |
51+
python -V
52+
poetry run python -V
53+
8454
- name: Build documentation
8555
run: |
8656
pushd docs; make SPHINXBUILD='poetry run sphinx-build' html; popd

.github/workflows/tests.yml

+10-39
Original file line numberDiff line numberDiff line change
@@ -12,53 +12,24 @@ jobs:
1212
python-version: ["3.9", "3.10"]
1313
steps:
1414
- uses: actions/checkout@v3
15-
- name: Set up Python ${{ matrix.python-version }}
16-
uses: actions/setup-python@v3
17-
with:
18-
python-version: ${{ matrix.python-version }}
19-
20-
- name: Get full Python version
21-
id: full-python-version
22-
shell: bash
23-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
2415

2516
- name: Install poetry
26-
run: |
27-
curl -O -sSL https://install.python-poetry.org/install-poetry.py
28-
python install-poetry.py -y --version 1.1.14
29-
echo "PATH=${HOME}/.poetry/bin:${PATH}" >> $GITHUB_ENV
30-
rm install-poetry.py
31-
32-
- name: Add ~/.local/bin to PATH
33-
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
34-
35-
- name: Get poetry cache paths from config
36-
run: |
37-
echo "poetry_virtualenvs_path=$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^\"//' -e 's/\"$//')" >> $GITHUB_ENV
38-
echo "poetry_virtualenvs_path=$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^\"//' -e 's/\"$//')" >> $GITHUB_ENV
39-
40-
- name: Configure poetry
41-
shell: bash
42-
run: poetry config virtualenvs.in-project true
17+
run: pipx install "poetry==1.1.14"
4318

44-
- name: Set up cache
45-
uses: actions/cache@v3
46-
id: cache
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
4721
with:
48-
path: |
49-
.venv
50-
${{ env.poetry_cache_dir }}
51-
${{ env.poetry_virtualenvs_path }}
52-
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
53-
54-
- name: Ensure cache is healthy
55-
if: steps.cache.outputs.cache-hit == 'true'
56-
shell: bash
57-
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
22+
python-version: ${{ matrix.python-version }}
23+
cache: 'poetry'
5824

5925
- name: Install dependencies
6026
run: poetry install -E "docs test coverage lint format"
6127

28+
- name: Print python versions
29+
run: |
30+
python -V
31+
poetry run python -V
32+
6233
- name: Lint with flake8
6334
run: poetry run flake8
6435

0 commit comments

Comments
 (0)