-
Notifications
You must be signed in to change notification settings - Fork 8
132 lines (111 loc) · 3.92 KB
/
runtests.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
name: TestCode
on:
push:
branches:
- master
pull_request:
branches:
- master
paths:
- 'pyproject.toml'
- '**.py'
- '.github/workflows/runtests.yml'
env:
# used to manually trigger cache reset. Just increment if needed.
CACHE_NUMBER: 1
# Cancel previous runs when this one starts.
concurrency:
group: TestCode-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
jobs:
# Runs the tests on combinations of the supported python/os matrix.
test_code:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
# only run if CI isn't turned off
if: github.event_name == 'push' || !contains(github.event.pull_request.labels.*.name, 'no_ci')
env:
# set path of test environment for caching
prefix: ${{ startsWith(matrix.os, 'ubuntu') && '/usr/share/miniconda3/envs/dascore'
|| startsWith(matrix.os, 'macos') && '/Users/runner/miniconda3/envs/dascore'
|| startsWith(matrix.os, 'windows') && 'C:\Miniconda3\envs\dascore' }}
# set individual cache key (only the start of it)
cache_key: ${{ matrix.os }}-py${{ matrix.python-version }}
# set conda environment file with dependencies
env_file: ".github/test_conda_env.yml"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # need this so tags are pulled and versions work
- name: Get year week
id: date
run: echo "date=$(date +'%Y:%U')" >> $GITHUB_STATE
- name: setup conda env
uses: conda-incubator/[email protected]
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: test
use-mamba: true
python-version: ${{ matrix.python-version }}
- name: Cache conda env
uses: actions/cache@v3
with:
path: ${{ env.prefix }}
key: ${{ env.cache_key }}-hash${{ hashFiles(env.env_file) }}-${{ steps.date.outputs.date }}-${{ env.CACHE_NUMBER }}
id: cache
- name: Update environment
run: mamba env update -n test -f ${{ env.env_file }}
if: steps.cache.outputs.cache-hit != 'true'
- name: install obsplus
shell: bash -l {0}
run: |
python -m pip install -e .[test]
- name: print package info
shell: bash -l {0}
run: |
conda info -a
conda list
- name: download test data
shell: bash -l {0}
run: |
if [ ! -d ~/opsdata ]; then
git clone https://github.com/d-chambers/opsdata_test
mv opsdata_test ~/opsdata
fi
# Runs test suite and calculates coverage
- name: run test suite
shell: bash -l {0}
run: |
pytest -s --cov obsplus --cov-append --cov-report=xml
# Runs examples in docstrings
- name: test docstrings
shell: bash -l {0}
run: |
pytest src --doctest-modules
# Runs the documentation notebooks
- name: test notebook docs
shell: bash -l {0}
run: |
pytest docs --nbval
# upload coverage
- name: upload coverage
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: PR_tests
fail_ci_if_error: false
# This is a very useful step for debugging, it allows you to ssh into the CI
# machine (https://github.com/marketplace/actions/debugging-with-tmate).
# Make sure to open the log before the job starts else you cant see the tmate
# url. See https://github.com/mxschmitt/action-tmate/issues/1.
# Also, the CI machine will close on a non-zero exit code (annoying). This can
# be overcome by coalescing the null command like so:
# $ some-command-that-can-fail || :
#
#- name: Setup tmate session
# uses: mxschmitt/action-tmate@v3