Skip to content

Commit 87163d0

Browse files
authored
ci(tests): Use poetry cache action (#316)
As of yesterday, `@actions/setup-python@v3` supports this via v3.1.0: [Release](https://github.com/actions/setup-python/releases/tag/v3.1.0), [Tag](https://github.com/actions/setup-python/tree/v3.1.0), actions/setup-python#281 ```yaml steps: - uses: actions/checkout@v3 - name: Install poetry run: pipx install poetry - uses: actions/setup-python@v3 with: python-version: '3.9' cache: 'poetry' - run: poetry install - run: poetry run pytest ``` See also: python-poetry/poetry#4205
2 parents 623a393 + 601ffef commit 87163d0

File tree

3 files changed

+17
-71
lines changed

3 files changed

+17
-71
lines changed

.github/workflows/docs.yml

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
matrix:
1313
python-version: ["3.10"]
1414
steps:
15-
- uses: actions/checkout@v1
15+
- uses: actions/checkout@v3
1616
- name: Filter changed file paths to outputs
1717
uses: dorny/paths-filter@v2.7.0
1818
id: changes
@@ -33,49 +33,21 @@ jobs:
3333
if: steps.changes.outputs.docs == 'true' || steps.changes.outputs.root_docs == 'true' || steps.changes.outputs.python_files == 'true'
3434
run: echo "PUBLISH=$(echo true)" >> $GITHUB_ENV
3535

36-
- name: Set up Python ${{ matrix.python-version }}
37-
uses: actions/setup-python@v1
38-
with:
39-
python-version: ${{ matrix.python-version }}
40-
41-
- name: Get full Python version
42-
id: full-python-version
43-
shell: bash
44-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
45-
4636
- name: Install poetry
4737
run: |
4838
curl -O -sSL https://install.python-poetry.org/install-poetry.py
4939
python install-poetry.py -y --version 1.1.12
5040
echo "PATH=${HOME}/.poetry/bin:${PATH}" >> $GITHUB_ENV
5141
rm install-poetry.py
5242
53-
- name: Add ~/.local/bin to PATH
54-
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
55-
56-
- name: Get poetry cache paths from config
57-
run: |
58-
echo "poetry_virtualenvs_path=$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^\"//' -e 's/\"$//')" >> $GITHUB_ENV
59-
echo "poetry_virtualenvs_path=$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^\"//' -e 's/\"$//')" >> $GITHUB_ENV
60-
61-
- name: Configure poetry
62-
shell: bash
63-
run: poetry config virtualenvs.in-project true
64-
65-
- name: Set up cache
66-
uses: actions/cache@v2
67-
id: cache
43+
- name: Set up Python ${{ matrix.python-version }}
44+
uses: actions/setup-python@v3
6845
with:
69-
path: |
70-
.venv
71-
{{ env.poetry_cache_dir }}
72-
{{ env.poetry_virtualenvs_path }}
73-
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
46+
python-version: ${{ matrix.python-version }}
47+
cache: 'poetry'
7448

75-
- name: Ensure cache is healthy
76-
if: steps.cache.outputs.cache-hit == 'true'
77-
shell: bash
78-
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
49+
- name: Add ~/.local/bin to PATH
50+
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
7951

8052
- name: Install dependencies [w/ docs]
8153
run: poetry install --extras "docs lint"

.github/workflows/tests.yml

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,22 @@ jobs:
99
matrix:
1010
python-version: [ '3.10' ]
1111
steps:
12-
- uses: actions/checkout@v1
13-
- name: Set up Python ${{ matrix.python-version }}
14-
uses: actions/setup-python@v1
15-
with:
16-
python-version: ${{ matrix.python-version }}
17-
18-
- name: Get full Python version
19-
id: full-python-version
20-
shell: bash
21-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
22-
12+
- uses: actions/checkout@v3
2313
- name: Install poetry
2414
run: |
2515
curl -O -sSL https://install.python-poetry.org/install-poetry.py
2616
python install-poetry.py -y --version 1.1.12
2717
echo "PATH=${HOME}/.poetry/bin:${PATH}" >> $GITHUB_ENV
2818
rm install-poetry.py
2919
30-
- name: Add ~/.local/bin to PATH
31-
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
32-
33-
- name: Get poetry cache paths from config
34-
run: |
35-
echo "poetry_virtualenvs_path=$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^\"//' -e 's/\"$//')" >> $GITHUB_ENV
36-
echo "poetry_virtualenvs_path=$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^\"//' -e 's/\"$//')" >> $GITHUB_ENV
37-
38-
- name: Configure poetry
39-
shell: bash
40-
run: poetry config virtualenvs.in-project true
41-
42-
- name: Set up cache
43-
uses: actions/cache@v2
44-
id: cache
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v3
4522
with:
46-
path: |
47-
.venv
48-
${{ env.poetry_cache_dir }}
49-
${{ env.poetry_virtualenvs_path }}
50-
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
23+
python-version: ${{ matrix.python-version }}
24+
cache: 'poetry'
5125

52-
- name: Ensure cache is healthy
53-
if: steps.cache.outputs.cache-hit == 'true'
54-
shell: bash
55-
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
26+
- name: Add ~/.local/bin to PATH
27+
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
5628

5729
- name: Install dependencies
5830
run: poetry install -E "docs test coverage lint format"
@@ -63,6 +35,6 @@ jobs:
6335
- name: Test with pytest
6436
run: poetry run py.test --cov=./ --cov-report=xml
6537

66-
- uses: codecov/codecov-action@v1
38+
- uses: codecov/codecov-action@v2
6739
with:
6840
token: ${{ secrets.CODECOV_TOKEN }}

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ $ pip install --user --upgrade --pre libvcs
5151

5252
- Add codeql analysis (:issue:`303`)
5353
- git test suite: Lots of parametrization (:issue:`309`)
54+
- CI: Use poetry caching from
55+
[@actions/setup v3.1](https://github.com/actions/setup-python/releases/tag/v3.1.0), (:issue:`316`)
5456
- New constants for `str` -> class mappings
5557

5658
- {data}`libvcs.shortcuts.DEFAULT_VCS_CLASS_MAP`

0 commit comments

Comments
 (0)