-
Notifications
You must be signed in to change notification settings - Fork 7
118 lines (99 loc) · 3.39 KB
/
lint_and_run_tests.yml
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# SPDX-FileCopyrightText: TNG Technology Consulting GmbH <https://www.tngtech.com>
#
# SPDX-License-Identifier: Apache-2.0
name: Lint and Test
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
linter:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: cache poetry install
uses: actions/cache@v3
with:
path: ~/.local
key: poetry-${{ matrix.os }}-${{ matrix.python-version }}-1.4.0-0
- name: Install poetry
uses: snok/install-poetry@v1
with:
version: 1.4.0
virtualenvs-create: true
virtualenvs-in-project: true
- name: cache deps
id: cache-deps
uses: actions/cache@v3
with:
path: .venv
key: pydeps-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
# We use a cache for the projects dependencies but want to avoid caching the projects code.
# --no-root installs all dependencies but not the project itself which we do in the next step.
- name: Install package dependencies
run: poetry install --no-interaction --no-root
if: steps.cache--deps.outputs.cache-hit != 'true'
- run: poetry install --no-interaction
- name: Run isort
run: poetry run isort src/ tests/ --check
- name: Run black
run: poetry run black src/ tests/ --check
- name: Run flake8
run: poetry run flake8 src/ tests/
- name: Run mypy
run: poetry run python -m mypy src/ tests/
test:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: cache poetry install
uses: actions/cache@v3
with:
path: ~/.local
key: poetry-${{ matrix.os }}-${{ matrix.python-version }}-1.4.0-0
- name: Install poetry
uses: snok/install-poetry@v1
with:
version: 1.4.0
virtualenvs-create: true
virtualenvs-in-project: true
- name: cache deps
id: cache-deps
uses: actions/cache@v3
with:
path: .venv
key: pydeps-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
# We use a cache for the projects dependencies but want to avoid caching the projects code.
# --no-root installs all dependencies but not the project itself which we do in the next step.
- name: Install package dependencies
run: poetry install --no-interaction --no-root
if: steps.cache--deps.outputs.cache-hit != 'true'
- run: poetry install --no-interaction
- name: Run tests
run: poetry run pytest