-
Notifications
You must be signed in to change notification settings - Fork 49
137 lines (120 loc) · 4.38 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
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
# Reference:
# - https://github.com/actions/cache
# - https://github.com/actions/checkout
# - https://github.com/conda-incubator/setup-miniconda
name: ci-tests
on:
pull_request:
push:
branches-ignore:
- "conda-lock-auto-update"
- "pre-commit-ci-update-config"
- "dependabot/*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
run-tests:
name: "Test ${{ matrix.version }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
env:
CYTHON_COVERAGE: 1
ENV_NAME: "ci-tests"
strategy:
matrix:
os: [ubuntu-latest]
version: [py310, py311, py312, py313]
gitpath-prepend: [""]
include:
- os: ubuntu-latest
platform: linux
- os: ubuntu-latest
version: py313
posargs: "--cov-report=xml --cov"
- os: macos-latest
version: py313
platform: osx
# On macos, the up-to-date git may not be first on the path
# N.B. setting includes a final ":", to simplify the path setting command
gitpath-prepend: "/opt/homebrew/bin:"
- os: windows-latest
version: py313
platform: win
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Environment configure"
env:
# Maximum cache period (in weeks) before forcing a cache refresh.
CACHE_WEEKS: 2
run: |
echo "CACHE_PERIOD=$(date +%Y).$(expr $(date +%U) / ${CACHE_WEEKS})" >> ${GITHUB_ENV}
- name: "Conda package cache"
uses: actions/[email protected]
env:
# Increment the build number to force a cache refresh.
CACHE_BUILD: 2
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-pkgs-${{ env.ENV_NAME }}-${{ matrix.version }}-p${{ env.CACHE_PERIOD }}-b${{ env.CACHE_BUILD }}
- name: "Conda install"
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
channels: conda-forge
activate-environment: ${{ env.ENV_NAME }}
auto-update-conda: true
- name: "Conda environment cache"
id: conda-env-cache
uses: actions/[email protected]
env:
# Increment the build number to force a cache refresh.
CACHE_BUILD: 2
with:
path: ${{ env.CONDA }}/envs/${{ env.ENV_NAME }}
key: ${{ runner.os }}-conda-env-${{ env.ENV_NAME }}-${{ matrix.version }}-p${{ env.CACHE_PERIOD }}-b${{ env.CACHE_BUILD }}
- name: "Conda environment update"
if: steps.conda-env-cache.outputs.cache-hit != 'true'
run: |
conda install --name ${{ env.ENV_NAME }} "tox<4"
- name: "Conda info"
run: |
conda info
conda list
- name: "Tox cache"
uses: actions/[email protected]
env:
# Increment the build number to forece a cache refresh.
CACHE_BUILD: 2
TOX_INI: ${{ github.workspace }}/tox.ini
with:
path: ${{ github.workspace }}/.tox
key: ${{ runner.os }}-tox-${{ env.ENV_NAME }}-${{ matrix.version }}-p${{ env.CACHE_PERIOD }}-b${{ env.CACHE_BUILD }}-${{ hashFiles(env.TOX_INI) }}
# setuptools can't find shared library installed by conda on windows
# so we need to prepare environment variables for it
- name: Export environment variables for UDUNITS2 lookup
if: runner.os == 'Windows'
uses: actions/github-script@v7
with:
script: |
const path = require('path')
const base = path.join('.tox/${{ matrix.version }}-${{ matrix.platform }}-test')
core.exportVariable('UDUNITS2_INCDIR', path.join(base, 'Library/include/'));
core.exportVariable('UDUNITS2_LIBDIR', path.join(base, 'Library/lib/'));
core.exportVariable('UDUNITS2_XML_PATH', path.join(base, 'Library/share/udunits/udunits2.xml'));
- name: "Run ${{ matrix.os }} on ${{ matrix.version}} tests"
run: |
export PATH=${{ matrix.gitpath-prepend }}$PATH
which git
git --version
tox -e ${{ matrix.version }}-${{ matrix.platform }}-test -- ${{ matrix.posargs }}
- name: "Upload coverage report to Codecov"
if: contains(matrix.posargs, '--cov')
uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3
with:
token: ${{ secrets.CODECOV_TOKEN }}