-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (100 loc) · 3.01 KB
/
core-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
name: core-tests
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.10"]
steps:
- uses: actions/checkout@v4
- name: Pipx cache for poetry
uses: actions/cache@v4
with:
path: |
/opt/pipx/venvs/poetry
/opt/pipx_bin/poetry
key: pipx-venvs-poetry
- name: Install poetry
run: |
pipx install poetry
pipx list --verbose
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- run: |
poetry install
- name: Unit tests with pytest
run: |
poetry run pytest
env:
COVERAGE_FILE: .coverage.${{ matrix.python-version }}
- name: Upload coverage data
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: coverage-data-${{ matrix.python-version }}
if-no-files-found: warn
path: ./.coverage*
compression-level: 0 # no compression
retention-days: 1
- name: Static typechecking with mypy
if: ${{ !startsWith(matrix.python-version, 'pypy') }}
run: |
poetry run mypy ./zammadoo
- name: Static code analysis with pylint
if: ${{ !startsWith(matrix.python-version, 'pypy') }}
run: |
poetry run pylint ./zammadoo
process-test-data:
if: success() || failure()
runs-on: ubuntu-latest
needs: test
env:
TOTAL_COVERAGE: '-'
steps:
- uses: actions/checkout@v4
- name: Download coverage data
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Pipx cache for coverage
uses: actions/cache@v4
with:
path: |
/opt/pipx/venvs/coverage
/opt/pipx_bin/coverage
key: pipx-venvs-coverage
- name: Install Python coverage
run: |
pipx install coverage[toml]
pipx list --verbose
- name: Merge coverage data and compute total coverage
continue-on-error: true
run: |
coverage combine .coverage.*
coverage json
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "TOTAL_COVERAGE=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
coverage report
- name: Update coverage badge
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: 1a66c9e88a9e4267f7e0b1d185be98f4
filename: 'covbadge.json'
label: coverage
message: ${{ env.TOTAL_COVERAGE }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.TOTAL_COVERAGE }}
isError: ${{ env.TOTAL_COVERAGE == '-' }}