Skip to content

Commit 8803455

Browse files
committed
ci: poetry with venv
1 parent 492f83e commit 8803455

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

.github/workflows/tests.yml

+31-9
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ jobs:
4444
run: poetry run pytest --black .
4545

4646
run_pytest:
47-
name: "pytest ${{ matrix.os }} | python ${{ matrix.os }}"
47+
name: "pytest ${{ matrix.os }} | ${{ matrix.python-version }}"
4848
runs-on: ${{ matrix.os }}
49+
defaults:
50+
run:
51+
shell: bash
4952
strategy:
5053
fail-fast: false
5154
matrix:
@@ -55,24 +58,43 @@ jobs:
5558
steps:
5659
- uses: actions/checkout@v4
5760

61+
- name: Set up python
62+
uses: actions/setup-python@v5
63+
with:
64+
python-version: "${{ matrix.python-version }}"
65+
5866
- name: Set up poetry
5967
uses: snok/install-poetry@v1
6068
with:
61-
python-version: ${{ matrix.python-version }}
62-
cache: true
69+
virtualenvs-create: true
70+
virtualenvs-in-project: true
6371

64-
- name: Install Python dependencies
65-
run: poetry install
72+
- name: Load cached venv
73+
id: cached-pip-wheels
74+
uses: actions/cache@v3
75+
with:
76+
path: ~/.cache
77+
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
78+
79+
- name: Install dependencies
80+
run: poetry install --no-interaction --no-root
81+
82+
- name: Install app
83+
run: poetry install --no-interaction
6684

6785
- name: Run tests without coverage
6886
if: ${{ matrix.os != 'ubuntu-latest' && matrix.python-version != '3.11' }}
69-
working-directory: tests/
70-
run: poetry run pytest --junitxml report.xml --cov=. -vv
87+
run: |
88+
source .venv/bin/activate
89+
cd tests/
90+
poetry run pytest --junitxml report.xml --cov=. -vv
7191
7292
- name: Run tests with coverage
7393
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' }}
74-
working-directory: tests/
75-
run: poetry run pytest --junitxml report.xml --cov=. -vv
94+
run: |
95+
source .venv/bin/activate
96+
cd tests/
97+
poetry run pytest --junitxml report.xml --cov=. -vv
7698
7799
- name: Upload to Codecov
78100
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' }}

0 commit comments

Comments
 (0)