-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (63 loc) · 2.25 KB
/
test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Test
on:
workflow_call:
inputs:
python_version:
type: string
description: 'Python version'
required: true
workflow_dispatch:
inputs:
python_version:
type: string
description: 'Python version'
required: true
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 5
env:
branch: ${{ github.head_ref || github.ref_name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python_version }}
- name: Restore poetry from cache
id: cache-poetry-restore
uses: actions/cache/restore@v4
with:
path: ~/.local
key: test/poetry/runner/${{ runner.os }}/python/${{ steps.setup-python.outputs.python-version }}
- name: Install poetry
if: ${{steps.cache-poetry-restore.outputs.cache-hit != 'true'}}
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Check poetry version
run: echo POETRY_VERSION=$(poetry --version | grep -oP '\d+.\d+.\d+') >> $GITHUB_ENV
- name: Save poetry cache
id: cache-poetry-save
if: ${{steps.cache-poetry-restore.outputs.cache-hit != 'true'}}
uses: actions/cache/save@v4
with:
path: ~/.local
key: test/poetry/runner/${{ runner.os }}/python/${{ steps.setup-python.outputs.python-version }}/version/${{ env.POETRY_VERSION }}
- name: Cache virtual environment
id: cache-venv
uses: actions/cache@v4
with:
path: .venv
key: test/branch/${{ env.branch }}/runner/${{ runner.os }}/python/${{ steps.setup-python.outputs.python-version }}/hash/${{ hashFiles('poetry.lock') }}
- name: Install dependencies
if: ${{steps.cache-venv.outputs.cache-hit != 'true'}}
run: poetry install --no-interaction --no-root --with=test --with=pydantic --with=dev --with=requests --with=httpx --with=aiohttp
- name: Install project
run: poetry install --no-interaction --only-root
- name: Run pytest
run: poetry run pytest