Skip to content

Commit 31c3b14

Browse files
authored
ci: Use actions/setup-python@v3/4 caching (#797)
1 parent 90709e6 commit 31c3b14

File tree

2 files changed

+20
-82
lines changed

2 files changed

+20
-82
lines changed

.github/workflows/docs.yml

+10-42
Original file line numberDiff line numberDiff line change
@@ -34,58 +34,26 @@ 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-
if: env.PUBLISH == 'true'
45-
shell: bash
46-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
47-
4837
- name: Install poetry
4938
if: env.PUBLISH == 'true'
50-
run: |
51-
curl -O -sSL https://install.python-poetry.org/install-poetry.py
52-
python install-poetry.py -y --version 1.1.14
53-
echo "PATH=${HOME}/.poetry/bin:${PATH}" >> $GITHUB_ENV
54-
rm install-poetry.py
39+
run: pipx install "poetry==1.1.14"
5540

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

8548
- name: Install dependencies [w/ docs]
8649
if: env.PUBLISH == 'true'
8750
run: poetry install --extras "docs lint"
8851

52+
- name: Print python versions
53+
run: |
54+
python -V
55+
poetry run python -V
56+
8957
- name: Build documentation
9058
if: env.PUBLISH == 'true'
9159
run: |

.github/workflows/tests.yml

+10-40
Original file line numberDiff line numberDiff line change
@@ -21,49 +21,14 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v3
2323

24-
- name: Set up Python ${{ matrix.python-version }}
25-
uses: actions/setup-python@v3
26-
with:
27-
python-version: ${{ matrix.python-version }}
28-
29-
- name: Get full Python version
30-
id: full-python-version
31-
shell: bash
32-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
33-
3424
- name: Install poetry
35-
run: |
36-
curl -O -sSL https://install.python-poetry.org/install-poetry.py
37-
python install-poetry.py -y --version 1.1.14
38-
echo "PATH=${HOME}/.poetry/bin:${PATH}" >> $GITHUB_ENV
39-
rm install-poetry.py
40-
41-
- name: Add ~/.local/bin to PATH
42-
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
43-
44-
- name: Get poetry cache paths from config
45-
run: |
46-
echo "poetry_cache_dir=$(poetry config --list | sed -n 's/.*cache-dir = //p' | sed -e 's/^\"//' -e 's/\"$//')" >> $GITHUB_ENV
47-
echo "poetry_virtualenvs_path=$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^\"//' -e 's/\"$//')" >> $GITHUB_ENV
48-
49-
- name: Configure poetry
50-
shell: bash
51-
run: poetry config virtualenvs.in-project true
25+
run: pipx install "poetry==1.1.14"
5226

53-
- name: Set up poetry cache
54-
uses: actions/cache@v3
55-
id: cache
27+
- name: Set up Python ${{ matrix.python-version }}
28+
uses: actions/setup-python@v4
5629
with:
57-
path: |
58-
.venv
59-
${{ env.poetry_cache_dir }}
60-
${{ env.poetry_virtualenvs_path }}
61-
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
62-
63-
- name: Ensure cache is healthy
64-
if: steps.cache.outputs.cache-hit == 'true'
65-
shell: bash
66-
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
30+
python-version: ${{ matrix.python-version }}
31+
cache: 'poetry'
6732

6833
- name: Setup tmux build cache for tmux ${{ matrix.tmux-version }}
6934
id: tmux-build-cache
@@ -97,6 +62,11 @@ jobs:
9762
- name: Lint with mypy
9863
run: poetry run mypy .
9964

65+
- name: Print python versions
66+
run: |
67+
python -V
68+
poetry run python -V
69+
10070
- name: Test with pytest
10171
continue-on-error: ${{ matrix.tmux-version == 'master' }}
10272
run: |

0 commit comments

Comments
 (0)