Skip to content

Finsberg/change testing workflow #33

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 12 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions setup.cfg → .flake8
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# flake8 does not support pyproject.toml, see:
# https://github.com/PyCQA/flake8/issues/234
[flake8]
exclude = docs
max-line-length = 100


exclude = docs,venv
max-line-length = 100
70 changes: 29 additions & 41 deletions .github/workflows/test_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
# The CI is executed on every push on every branch
branches:
- "**"
- main
pull_request:
# The CI is executed on every pull request to the main branch
branches:
Expand All @@ -22,69 +22,57 @@ jobs:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
runs-on: ubuntu-22.04

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]

steps:
# This action sets the current path to the root of your github repo
- uses: actions/checkout@v3

- uses: actions/setup-python@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: ${{ matrix.python-version }}

- name: "Install code"
run: pip install .[test,docs]
run: python -m pip install .[test]

- name: Flake8 code
run: flake8 .
run: python -m flake8

- name: Mypy check
run: |
pip install mypy
python -m mypy . --exclude=build

- name: Generate coverage report
run: python -m pytest --cov=mypackage test

- name: Generate html report
run: python -m coverage html

- name: Upload coverage report as artifact
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: htmlcov
if-no-files-found: error

- name: Build documentation
run: |
make doc

- name: Upload documentation
uses: actions/upload-artifact@v3
with:
name: documentation
path: docs/_build/html
if-no-files-found: error

run: python -m mypy

test-code:
# This code depends on the result of check-code
needs: check-code
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-22.04, windows-latest, macos-12]

os: [ubuntu-22.04, windows-latest, macos-12]
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/setup-python@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: ${{ matrix.python-version }}

- uses: actions/checkout@v3

- name: "Install mypackage"
run: pip install .[test]

- name: Run tests
run: |
python -m pytest test/
python -m pytest

- name: Upload coverage report as artifact
if: matrix.os == 'ubuntu-22.04' && matrix.python-version == '3.10'
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: htmlcov
if-no-files-found: error
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,14 @@ ignore_missing_imports = true # Does not show errors when importing untyped libr
exclude = [ # We only want mypy to consider files that are not generated in installing or building documentation
"docs/",
"build/"
]
files = [ # Folder to which files that should be checked by mypy
"src",
"test"
]

[tool.pytest.ini_options]
addopts = "--cov=mypackage --cov-report html --cov-report term-missing -v"
testpaths = [
"test"
]