-
Notifications
You must be signed in to change notification settings - Fork 4
91 lines (81 loc) · 3.23 KB
/
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
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: tests
on:
workflow_call:
jobs:
test_pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install poetry
run: pipx install poetry==1.8.3
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: '3.10'
cache: 'poetry'
- run: |
poetry config virtualenvs.in-project false
poetry config cache-dir ~/cache/.poetry
- name: Install dependencies
run: poetry install --with docs
- name: Test pages
run: poetry run sphinx-build -a -E docs/source/ docs/build/
static_analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: install poetry
run: pipx install poetry==1.8.3
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: '3.10'
cache: 'poetry'
- name: Install dependencies from poetry
run: poetry install --no-root
- name: Run black
run: poetry run black cdxev tests --check
- name: Run isort
run: poetry run isort cdxev/ tests/ --check-only
- name: Run flake8
run: poetry run flake8 cdxev tests
- name: Run mypy
run: poetry run mypy --install-types --non-interactive --config-file=pyproject.toml
- name: Run bandit
run: poetry run bandit -c pyproject.toml -r cdxev
pytest:
runs-on: ubuntu-latest
needs: static_analysis
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: install poetry
run: pipx install poetry==1.8.3
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: '3.10'
cache: 'poetry'
- name: Install package
run: poetry install
- name: Run pytest
run: poetry run coverage run -m pytest --junitxml=reports/unittest.xml
- name: Check coverage
run: poetry run coverage report --fail-under=95
- name: Save test results
run: poetry run coverage xml -o reports/py-coverage.cobertura.xml
- name: Archive test results
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: test-report
path: reports/unittest.xml
- name: Archive code coverage results
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: code-coverage-report
path: reports/py-coverage.cobertura.xml
- name: Coverage commit
if: ${{ success() && GITHUB.EVENT_NAME == 'pull_request' && !github.event.pull_request.head.repo.fork }}
uses: MishaKav/pytest-coverage-comment@81882822c5b22af01f91bd3eacb1cefb6ad73dc2 # v1.1.53
with:
junitxml-path: reports/unittest.xml
pytest-xml-coverage-path: reports/py-coverage.cobertura.xml
report-only-changed-files: true