forked from labthings/labthings-fastapi
-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (124 loc) · 4.23 KB
/
test.yml
File metadata and controls
154 lines (124 loc) · 4.23 KB
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
144
145
146
147
148
149
150
151
152
153
154
name: Test
on:
- pull_request
jobs:
base_coverage:
continue-on-error: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.base_ref }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install Dependencies
run: pip install -e . -r dev-requirements.txt
- name: Test with pytest
run: |
pytest --cov=src --cov-report=lcov
mv coverage.lcov base-coverage.lcov
- name: Upload code coverage for base branch
uses: actions/upload-artifact@v4
with:
name: base-coverage.lcov
path: ./base-coverage.lcov
test:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install Dependencies
run: pip install -e . -r dev-requirements.txt
- name: Lint with Ruff
run: ruff check .
- name: Format with Ruff
run: ruff format --check .
- name: Check spelling
run: codespell .
- name: Lint with Flake8 (for docstrings)
if: ${{ contains('3.12,3.13', matrix.python) }}
# Flake8 crashes on Python < 3.12, so we exclude those versions.
# Flake8 is primarily here to lint the docstrings, which
# does not need to happen under multiple versions.
run: flake8 src
- name: Test with pytest
run: pytest --cov=src --cov-report=lcov
- name: Upload code coverage
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python }}
path: ./coverage.lcov
- name: Analyse with MyPy
run: mypy
test-with-unpinned-deps:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install Dependencies
run: pip install -e .[dev]
- name: Lint with Ruff
run: ruff check .
- name: Format with Ruff
if: success() || failure()
run: ruff format --check .
- name: Analyse with MyPy
if: success() || failure()
run: mypy
- name: Test with pytest
if: success() || failure()
run: pytest --cov=src --cov-report=lcov
- name: Check quickstart, including installation
if: success() || failure()
run: bash ./docs/source/quickstart/test_quickstart_example.sh
coverage:
runs-on: ubuntu-latest
needs: [base_coverage, test]
steps:
- name: Download code coverage report
uses: actions/download-artifact@v4
with:
name: coverage-3.12
- name: Download code coverage report for base branch
id: download-base-coverage
continue-on-error: true
uses: actions/download-artifact@v4
with:
name: base-coverage.lcov
- name: Generate Code Coverage report
# Note, due to continue on error (to make job pass) we need to check the
# Status of the step directly not just use success() or failure()
if: steps.download-base-coverage.outcome == 'success'
id: code-coverage
uses: barecheck/code-coverage-action@v1
with:
barecheck-github-app-token: ${{ secrets.BARECHECK_GITHUB_APP_TOKEN }}
lcov-file: "./coverage.lcov"
base-lcov-file: "./base-coverage.lcov"
minimum-ratio: 0
send-summary-comment: true
show-annotations: "warning"
- name: Generate Code Coverage report if base job fails
if: steps.download-base-coverage.outcome == 'failure'
id: code-coverage-without-base
uses: barecheck/code-coverage-action@v1
with:
barecheck-github-app-token: ${{ secrets.BARECHECK_GITHUB_APP_TOKEN }}
lcov-file: "./coverage.lcov"
minimum-ratio: 0
send-summary-comment: true
show-annotations: "warning"