-
Notifications
You must be signed in to change notification settings - Fork 13
104 lines (83 loc) · 2.74 KB
/
ci-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: Tests
on:
push:
branches:
- master
pull_request:
jobs:
static-analysis:
name: Static analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
uses: ./.github/actions/prepare-poetry
with:
python-version: "3.10"
# Post in-line comments for any issues found
# Do not run if coming from a forked repo
# See https://github.com/marketplace/actions/lint-action
- name: Run linters (with annotations)
if: github.event.pull_request.head.repo.full_name == github.repository
uses: wearerequired/lint-action@v2
with:
flake8: true
flake8_command_prefix: poetry run
flake8_dir: resqpy
mypy: true
mypy_command_prefix: poetry run
mypy_args: resqpy
# Alternative step that works with forked repo
- name: Run linters (without annotations)
if: github.event.pull_request.head.repo.full_name != github.repository
run: |
poetry run flake8 .
poetry run mypy resqpy
- name: Code formatting
run: poetry run yapf --diff -r -p .
unit-tests:
name: Unit tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Install dependencies
uses: ./.github/actions/prepare-poetry
with:
python-version: ${{ matrix.python-version }}
- name: Run pytest
run: poetry run pytest --cov=resqpy --cov-report=xml --junitxml=pytest.xml
- name: Upload pytest artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: Unit Test Results (Python ${{ matrix.python-version }})
path: pytest.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
fail_ci_if_error: true
legacy-dependencies:
# Test against older versions of numpy and pandas,
# To ensure resqpy works with the lower bounds of our published constraints
name: Unit tests (older dependencies)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
uses: ./.github/actions/prepare-poetry
with:
python-version: 3.8
- name: Downgrade numpy and pandas
# Use caret-style requirements (~) to fix minor version but allow patches
run: |
poetry add numpy@~1.22 pandas@~1.1
poetry show
- name: Run pytest
run: poetry run pytest