-
Notifications
You must be signed in to change notification settings - Fork 43
140 lines (126 loc) · 4.55 KB
/
auto_formatting_tests_and_coverage.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
130
131
132
133
134
135
136
137
138
139
140
name: (Auto) Tests
on:
push:
branches:
- master
- main
pull_request:
branches:
- main
- master
# Run tests every week on sundays
schedule:
- cron: "0 0 * * 0"
jobs:
# Job (1): Run testing in parallel against multiples OSs and Python versions
test:
name: Test
runs-on: ${{ matrix.os }}
# Determines whether the entire workflow should pass/fail based on parallel jobs
continue-on-error: ${{ matrix.experimental }}
defaults:
# This ensures each step gets properly configured bash shell for conda commands to work
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
# OSs to test
os: [ubuntu-latest, macos-latest]
# Python versions to test
python-version: [3.8, 3.9, '3.10', 3.11]
# By default everything should pass for the workflow to pass
experimental: [false]
include:
# Windows sometimes fails to install due to dependency changes, but eventually sort themselves out. So let these tests fail
- os: windows-latest
python-version: 3.8
experimental: true
- os: windows-latest
python-version: 3.9
experimental: true
- os: windows-latest
python-version: '3.10'
experimental: true
- os: windows-latest
python-version: 3.11
experimental: true
steps:
# Step up miniconda
- name: Download and setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}
# Check out latest code on github
- name: Checkout Code
uses: actions/checkout@v2
# Install common sci-py packages via conda as well as testing packages and requirements
# TODO: unpin pandas version when deepdish adds support for 1.2: https://github.com/uchicago-cs/deepdish/issues/45
- name: Install Dependencies
run: |
conda activate test
conda env list
pip install -r requirements-dev.txt
pip install -r optional-dependencies.txt
# Check code formatting
- name: Check code formatting
run: |
conda activate test
black --version
black --check --diff --verbose nltools
# Actually run the tests with coverage
- name: Run Tests
run: |
conda activate test
coverage run --source=nltools -m pytest -rs
# Send coverage to coveralls.io but waiting on parallelization to finish
# Not using the official github action in the marketplace to upload because it requires a .lcov file, which pytest doesn't generate. It's just easier to use the coveralls python library which does the same thing, but works with pytest.
- name: Upload Coverage
# The coveralls python package has some 422 server issues with uploads from github-actions so try both service providers, for more see:
# https://github.com/TheKevJames/coveralls-python/issues/252
run: coveralls --service=github || coveralls --service=github-actions
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: $${{ matrix}}
COVERALLS_PARALLEL: true
# Job (2): Send a finish notification to coveralls.io to integrate coverage across parallel tests
coveralls:
name: Coveralls.io Upload
needs: test
runs-on: ubuntu-latest
container: python:3-slim
continue-on-error: true
steps:
- name: Finished
run: |
pip3 install --upgrade coveralls
coveralls --service=github --finish || coveralls --service=github-actions --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Job (3): Build docs, but don't deploy. This is effectively another layer of testing because of our sphinx-gallery auto-examples
docs:
name: Build docs and auto-examples
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Download and setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
python-version: 3.8
- name: Checkout Code
uses: actions/checkout@v2
- name: Install Dependencies
run: |
conda activate test
conda env list
pip install -r requirements-dev.txt
pip install -r optional-dependencies.txt
- name: Build docs
run: |
cd docs
make clean
make html