Skip to content

Commit e1624a2

Browse files
authored
Finsberg/change testing workflow (#33)
* Remove building docs from testing workflow since this is already tested in the build_docs workflow * Move coverage report to final step * Test multiple versions of python * Only upload artifact from coverage report for python3.10 on ubuntu * Run test CI only on push to master or PR to master * Move mypy and pytest configurations to pyproject.toml and flake8 configurations to .flake8 * Add list of folders to be checked by mypy
1 parent 43e3753 commit e1624a2

File tree

3 files changed

+41
-45
lines changed

3 files changed

+41
-45
lines changed

setup.cfg renamed to .flake8

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# flake8 does not support pyproject.toml, see:
22
# https://github.com/PyCQA/flake8/issues/234
33
[flake8]
4-
exclude = docs
5-
max-line-length = 100
6-
7-
4+
exclude = docs,venv
5+
max-line-length = 100

.github/workflows/test_package.yml

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
# The CI is executed on every push on every branch
66
branches:
7-
- "**"
7+
- main
88
pull_request:
99
# The CI is executed on every pull request to the main branch
1010
branches:
@@ -22,69 +22,57 @@ jobs:
2222
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
2323
runs-on: ubuntu-22.04
2424

25+
strategy:
26+
matrix:
27+
python-version: ["3.8", "3.9", "3.10"]
28+
2529
steps:
2630
# This action sets the current path to the root of your github repo
2731
- uses: actions/checkout@v3
28-
29-
- uses: actions/setup-python@v4
32+
33+
- name: Set up Python ${{ matrix.python-version }}
34+
uses: actions/setup-python@v4
3035
with:
31-
python-version: '3.10'
36+
python-version: ${{ matrix.python-version }}
3237

3338
- name: "Install code"
34-
run: pip install .[test,docs]
39+
run: python -m pip install .[test]
3540

3641
- name: Flake8 code
37-
run: flake8 .
42+
run: python -m flake8
3843

3944
- name: Mypy check
40-
run: |
41-
pip install mypy
42-
python -m mypy . --exclude=build
43-
44-
- name: Generate coverage report
45-
run: python -m pytest --cov=mypackage test
46-
47-
- name: Generate html report
48-
run: python -m coverage html
49-
50-
- name: Upload coverage report as artifact
51-
uses: actions/upload-artifact@v3
52-
with:
53-
name: code-coverage-report
54-
path: htmlcov
55-
if-no-files-found: error
56-
57-
- name: Build documentation
58-
run: |
59-
make doc
60-
61-
- name: Upload documentation
62-
uses: actions/upload-artifact@v3
63-
with:
64-
name: documentation
65-
path: docs/_build/html
66-
if-no-files-found: error
67-
45+
run: python -m mypy
6846

6947
test-code:
7048
# This code depends on the result of check-code
7149
needs: check-code
7250
runs-on: ${{ matrix.os }}
73-
51+
7452
strategy:
7553
matrix:
76-
os: [ubuntu-22.04, windows-latest, macos-12]
77-
54+
os: [ubuntu-22.04, windows-latest, macos-12]
55+
python-version: ["3.8", "3.9", "3.10"]
56+
7857
steps:
79-
- uses: actions/setup-python@v4
58+
- name: Set up Python ${{ matrix.python-version }}
59+
uses: actions/setup-python@v4
8060
with:
81-
python-version: '3.10'
61+
python-version: ${{ matrix.python-version }}
8262

8363
- uses: actions/checkout@v3
84-
64+
8565
- name: "Install mypackage"
8666
run: pip install .[test]
8767

8868
- name: Run tests
8969
run: |
90-
python -m pytest test/
70+
python -m pytest
71+
72+
- name: Upload coverage report as artifact
73+
if: matrix.os == 'ubuntu-22.04' && matrix.python-version == '3.10'
74+
uses: actions/upload-artifact@v3
75+
with:
76+
name: code-coverage-report
77+
path: htmlcov
78+
if-no-files-found: error

pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,14 @@ ignore_missing_imports = true # Does not show errors when importing untyped libr
4040
exclude = [ # We only want mypy to consider files that are not generated in installing or building documentation
4141
"docs/",
4242
"build/"
43+
]
44+
files = [ # Folder to which files that should be checked by mypy
45+
"src",
46+
"test"
47+
]
48+
49+
[tool.pytest.ini_options]
50+
addopts = "--cov=mypackage --cov-report html --cov-report term-missing -v"
51+
testpaths = [
52+
"test"
4353
]

0 commit comments

Comments
 (0)