-
Notifications
You must be signed in to change notification settings - Fork 10
143 lines (138 loc) · 5.09 KB
/
test.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# This workflow will lint, run unit tests, test CLI and build with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
# 06.12.2024: modified slightly with inspiration from:
# https://github.com/marketplace/actions/install-poetry-action#testing-using-a-matrix
# https://adamj.eu/tech/2023/11/02/github-actions-faster-python-virtual-environments/
name: Test Python package
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
#----------------------------------------------
# linting
#----------------------------------------------
linting:
name: Linting
# linting has nothing to do with multiple versions of os and python
# (the result will be the same) and therefore separated to save time
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Load pip cache if cache exists
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
restore-keys: ${{ runner.os }}-pip
- name: Install linters
run: python -m pip install black flake8 isort
- name: Lint code
run: |
flake8 ./qats/ --exit-zero --max-complexity=10 --statistics
black .
isort .
#----------------------------------------------
# test using a matrix
#----------------------------------------------
testing:
needs: linting
name: Test with Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
# https://stackoverflow.com/questions/75549995/why-do-the-pyside6-qt-modules-cause-tox-to-fail-during-a-github-action
- name: Install missing libraries on GitHub agent
run: sudo apt update && sudo apt install -y libegl1-mesa-dev
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v4
- name: Set up python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
#----------------------------------------------
# install & configure poetry
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Install dynamic versioning plugin
run: poetry self add "poetry-dynamic-versioning[plugin]"
#----------------------------------------------
# load (restore) cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache/restore@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
#----------------------------------------------
# save cached venv
#----------------------------------------------
- name: Save cached venv
uses: actions/cache/save@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install root project, if required
#----------------------------------------------
- name: Install project
run: poetry install --no-interaction
#----------------------------------------------
# run tests
#----------------------------------------------
- name: Run unit tests
run: |
source .venv/bin/activate
pytest test/
- name: Test CLI
env:
QT_API: pyside6
run: |
source .venv/bin/activate
qats -h
qats app -h
qats config -h
python -m qats -h
- name: Test building package
run: poetry build
- name: Test building documentation
run: |
source .venv/bin/activate
sphinx-build -b html docs/source docs/_build
#----------------------------------------------
# upload artifacts
# (only done for one of the python versions)
#----------------------------------------------
- name: Upload artifacts
if: ${{ matrix.python-version == '3.11' }}
uses: actions/upload-artifact@v4
with:
name: test-builds
path: |
dist/qats-*.tar.gz
dist/qats-*.whl