-
Notifications
You must be signed in to change notification settings - Fork 23
124 lines (106 loc) · 3.5 KB
/
build.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
# -----------------------
#
# Run a full build-and-test from the git repo
# using a combination of conda and pip to install
# all optional dependencies.
#
# This is the 'full' test suite.
#
# -----------------------
name: Build and test
on:
push:
branches:
- main
- master
- release/**
pull_request:
branches:
- main
- master
- release/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
conda:
name: Python ${{ matrix.python-version }} (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os:
- macOS
- Ubuntu
python-version:
- "3.9"
- "3.10"
- "3.11"
runs-on: ${{ matrix.os }}-latest
# this is needed for conda environments to activate automatically
defaults:
run:
shell: bash -el {0}
steps:
- name: Get source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache conda packages
uses: actions/cache@v4
env:
# increment to reset cache
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ matrix.python-version }}-${{ env.CACHE_NUMBER }}
restore-keys: ${{ runner.os }}-conda-${{ matrix.python-version }}-
- name: Configure conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: test
miniforge-variant: Mambaforge
python-version: ${{ matrix.python-version }}
use-mamba: true
- name: Conda info
run: conda info --all
- name: Install dependencies
run: |
# parse requirements to install as much as possible with conda
mamba create --name pip2conda pip2conda
mamba run -n pip2conda pip2conda \
--all \
--output environment.txt \
--python-version ${{ matrix.python-version }}
echo "-----------------"
cat environment.txt
echo "-----------------"
mamba install --quiet --yes --name test --file environment.txt
- name: Install GWSumm
run: python -m pip install . --no-build-isolation -vv
- name: Package list
run: conda list --name test
- name: Run test suite
run: python -m pytest -ra --color yes --cov gwsumm --pyargs gwsumm --cov-report=xml --junitxml=pytest.xml
- name: Test command-line interfaces
run: |
python -m coverage run --append --source gwsumm -m gwsumm --help
python -m coverage run --append --source gwsumm -m gwsumm day --help
python -m coverage run --append --source gwsumm -m gwsumm week --help
python -m coverage run --append --source gwsumm -m gwsumm month --help
python -m coverage run --append --source gwsumm -m gwsumm gps --help
python -m coverage run --append --source gwsumm -m gwsumm.batch --help
python -m coverage run --append --source gwsumm -m gwsumm.plot.triggers --help
python -m coverage run --append --source gwsumm -m gwsumm.plot.guardian --help
- name: Coverage report
run: python -m coverage report --show-missing
- name: Publish coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: coverage.xml
flags: ${{ runner.os }},python${{ matrix.python-version }}
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: pytest-conda-${{ matrix.os }}-${{ matrix.python-version }}
path: pytest.xml