Skip to content

Commit 30fdc5d

Browse files
committed
fix: set correct python env for poetr and add retries
1 parent 9bfa4db commit 30fdc5d

5 files changed

Lines changed: 114 additions & 51 deletions

File tree

.github/workflows/check.yml

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,42 @@ jobs:
2020
matrix:
2121
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
2222
steps:
23-
- uses: actions/checkout@v2
24-
with:
25-
submodules: 'recursive'
26-
- name: Set up Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v5
28-
with:
29-
python-version: ${{ matrix.python-version }}
30-
31-
- name: Setup poetry
32-
uses: abatilo/actions-poetry@v4
33-
with:
34-
poetry-version: '1.8.5'
35-
36-
- name: Setup a local virtual environment
37-
run: |
38-
poetry config virtualenvs.create true --local
39-
poetry config virtualenvs.in-project true --local
40-
41-
- uses: actions/cache@v3
42-
name: Define a cache for the virtual environment based on the dependencies lock file
43-
with:
44-
path: ./.venv
45-
key: venv-${{ hashFiles('poetry.lock') }}
46-
47-
- name: Install dependencies
48-
run: poetry install -E crypto
49-
- name: Generate rest sync code and tests
50-
run: poetry run unasync
51-
- name: Test with pytest
52-
run: poetry run pytest --verbose --tb=short
23+
- uses: actions/checkout@v4
24+
with:
25+
submodules: 'recursive'
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v5
28+
id: setup-python
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
32+
- name: Setup poetry
33+
uses: abatilo/actions-poetry@v4
34+
with:
35+
poetry-version: '2.1.4'
36+
37+
- name: Setup a local virtual environment
38+
run: |
39+
poetry env use ${{ steps.setup-python.outputs.python-path }}
40+
poetry run python --version
41+
poetry config virtualenvs.create true --local
42+
poetry config virtualenvs.in-project true --local
43+
44+
- uses: actions/cache@v4
45+
name: Define a cache for the virtual environment based on the dependencies lock file
46+
id: cache
47+
with:
48+
path: ./.venv
49+
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
50+
51+
- name: Ensure cache is healthy
52+
if: steps.cache.outputs.cache-hit == 'true'
53+
shell: bash
54+
run: poetry run pip --version >/dev/null 2>&1 || (echo "Cache is broken, skip it" && rm -rf .venv)
55+
56+
- name: Install dependencies
57+
run: poetry install -E crypto
58+
- name: Generate rest sync code and tests
59+
run: poetry run unasync
60+
- name: Test with pytest
61+
run: poetry run pytest --verbose --tb=short --reruns 3

.github/workflows/lint.yml

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,40 @@ jobs:
1010
lint:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
14-
with:
15-
submodules: 'recursive'
16-
- name: Set up Python ${{ matrix.python-version }}
17-
uses: actions/setup-python@v2
18-
with:
19-
python-version: '3.8'
20-
- name: Setup poetry
21-
uses: abatilo/actions-poetry@v2.0.0
22-
with:
23-
poetry-version: 1.3.2
24-
- name: Install dependencies
25-
run: poetry install -E crypto
26-
- name: Lint with flake8
27-
run: poetry run flake8
13+
- uses: actions/checkout@v4
14+
with:
15+
submodules: 'recursive'
16+
- name: Set up Python 3.9
17+
uses: actions/setup-python@v5
18+
id: setup-python
19+
with:
20+
python-version: '3.9'
21+
22+
- name: Setup poetry
23+
uses: abatilo/actions-poetry@v4
24+
with:
25+
poetry-version: '2.1.4'
26+
27+
- name: Setup a local virtual environment
28+
run: |
29+
poetry env use ${{ steps.setup-python.outputs.python-path }}
30+
poetry run python --version
31+
poetry config virtualenvs.create true --local
32+
poetry config virtualenvs.in-project true --local
33+
34+
- uses: actions/cache@v4
35+
name: Define a cache for the virtual environment based on the dependencies lock file
36+
id: cache
37+
with:
38+
path: ./.venv
39+
key: venv-${{ runner.os }}-3.9-${{ hashFiles('poetry.lock') }}
40+
41+
- name: Ensure cache is healthy
42+
if: steps.cache.outputs.cache-hit == 'true'
43+
shell: bash
44+
run: poetry run pip --version >/dev/null 2>&1 || (echo "Cache is broken, skip it." && rm -rf .venv)
45+
46+
- name: Install dependencies
47+
run: poetry install
48+
- name: Lint with flake8
49+
run: poetry run flake8

poetry.lock

Lines changed: 32 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ respx = [
6969
]
7070
importlib-metadata = "^4.12"
7171
pytest-timeout = "^2.1.0"
72+
pytest-rerunfailures = [
73+
{ version = "^13.0", python = "~3.7" },
74+
{ version = "^14.0", python = "^3.8" },
75+
]
7276
async-case = { version = "^10.1.0", python = "~3.7" }
7377
tokenize_rt = "*"
7478

setup.cfg

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@ ignore = W503, W504, N818
77
per-file-ignores =
88
# imported but unused
99
__init__.py: F401
10-
11-
exclude =
12-
# Exclude virtual environment check
13-
venv
14-
10+
# Exclude virtual environment check
11+
exclude = .venv,venv,env,.env,.git,__pycache__,.pytest_cache,build,dist,*.egg-info
1512

1613
[tool:pytest]
1714
#log_level = DEBUG

0 commit comments

Comments
 (0)