-
Notifications
You must be signed in to change notification settings - Fork 1
129 lines (121 loc) · 4.48 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Tests
# define when workflow runs
on:
# run on push to main
push:
# in both cases ignore markdown docs
paths-ignore:
- "docs/**"
- "*.md"
# run on pr vs main
pull_request:
paths-ignore:
- "docs/**"
- "*.md"
# define the jobs that make up the workflow
jobs:
# define a job called tests
tests:
# define the name of a specific job
name: ${{ matrix.session }} ${{ matrix.python-version }} / ${{ matrix.os }}
# needed when we have a matrix config with different op systems
runs-on: ${{ matrix.os }}
# define the matrix of jobs
strategy:
# if any job fails cancel all of them
fail-fast: false
# define our matrix as all op systems and 4 python versions
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9]
session: [mypy, tests]
# configure --session for nox to only run a specifc subset of test
# this is equiv to running e.g. nox --session mypy
# sessions are specified above in the matrix spec
env:
NOXSESSION: ${{ matrix.session }}
steps:
# check out this repo onto github runner
- name: Check out the repository
uses: actions/[email protected]
# setup specified matrix version of python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
# get the version of build tools defined by constraints file
# to keep things replicable and deterministic we pin build tools in CI
- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version
# install both nox and nox-poetry so when nox builds environments
# it pulls in dependencies according to pyproject.toml using poetry
- name: Install Nox
run: |
pip install --constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
# run nox testing using selected python version
# session is passed by env.NOXSESSION above
- name: Run Nox
run: |
nox --force-color --python=${{ matrix.python-version }}
# if we are running 'tests' session then upload coverage data
# this ensures that the coverage reports per runner are stored
# so that the next job (coverage) can grab them and combine them
# so we run coverage tests per matrix build
# but combine them to form one coverage report
- name: Upload coverage data
if: always() && matrix.session == 'tests'
uses: "actions/[email protected]"
with:
name: coverage-data
path: ".coverage.*"
# define job to run coverage report
coverage:
# just need to run on one operating system
runs-on: ubuntu-latest
needs: tests
steps:
# check our repo and use 3.9 python
- name: Check out the repository
uses: actions/[email protected]
- name: Set up Python 3.9
uses: actions/[email protected]
with:
python-version: 3.9
# install CI build tools
- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install Nox
run: |
pip install --constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
# download the coverage artifact produced by tests job, session=tests
- name: Download coverage data
uses: actions/[email protected]
with:
name: coverage-data
# specifically run the noxfile.py coverage session which combines
- name: Combine coverage data and display human readable report
run: |
nox --force-color --session=coverage
# create and upload coverage report
# requires logging into https://codecov.io/ with github first
# then report gets uploaded here and docs can pull it in
# as per top of docs/index.md
- name: Create coverage report
run: |
nox --force-color --session=coverage -- xml
- name: Upload coverage report
uses: codecov/[email protected]