-
Notifications
You must be signed in to change notification settings - Fork 11
227 lines (221 loc) · 7.57 KB
/
main.yaml
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
name: Build and test
on:
push:
paths-ignore:
- "README.md"
- "LICENSE"
- "MANIFEST"
- "docs/**"
- ".github/workflows/docs.yml"
branches:
- main
tags:
- "*"
pull_request:
paths-ignore:
- "README.md"
- "LICENSE"
- "MANIFEST"
- "docs/**"
- ".github/workflows/docs.yml"
branches:
- main
jobs:
conda-package:
name: Build Conda package
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Create build environment
run: |
source $CONDA/bin/activate
conda env create -f etc/build-environment.yml
- name: conda Build
run: |
source $CONDA/bin/activate && conda activate build-conda-project
VERSION=`hatch version` conda build -c conda-forge --output-folder conda-build conda.recipe
- name: Upload the build artifact
uses: actions/upload-artifact@v3
with:
name: package-${{ github.sha }}
path: conda-build
build-wheel-and-sdist:
name: Build the wheel and sdist
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4
with:
python-version: "3.10"
- name: Install build dependencies
run: pip install build
- name: Build the package
run: python -m build
- name: Upload the build artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
with:
name: builds-${{ github.sha }}
path: dist/*
if-no-files-found: error
retention-days: 7
test:
name: Test (conda ${{ matrix.conda-version }}, Python ${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: [3.9, "3.10", "3.11", "3.12"]
conda-version: ["4.14", "22.9", "22.11", "23.5", "23.9", "24.1" , "24.4"]
exclude:
# Python 3.11
- conda-version: "4.14"
python-version: "3.11"
- conda-version: "22.9"
python-version: "3.11"
# Python 3.12
- conda-version: "4.14"
python-version: "3.12"
- conda-version: "22.9"
python-version: "3.12"
- conda-version: "22.11"
python-version: "3.12"
- conda-version: "23.5"
python-version: "3.12"
- conda-version: "23.9"
python-version: "3.12"
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- name: Download conda standalone
shell: bash
run: |
if [ $RUNNER_OS == 'Linux' ]; then
curl https://repo.anaconda.com/pkgs/misc/conda-execs/conda-4.10.3-linux-64.exe -o conda.exe
elif [ $RUNNER_OS == 'Windows' ]; then
curl https://repo.anaconda.com/pkgs/misc/conda-execs/conda-4.10.3-win-64.exe -o conda.exe
elif [ $RUNNER_OS == 'macOS' ]; then
curl https://repo.anaconda.com/pkgs/misc/conda-execs/conda-4.10.3-osx-64.exe -o conda.exe
fi
chmod +x conda.exe
./conda.exe config --set auto_update_conda false
./conda.exe clean -ay
./conda.exe info
- name: Setup miniconda
shell: bash -l {0}
run: |
./conda.exe create -p $HOME/miniconda conda=${{ matrix.conda-version }} python=${{ matrix.python-version }}
- name: Install Libmamba
shell: bash -l {0}
run: |
if [[ ! "${{ matrix.conda-version }}" =~ ^("4.9"|"4.10"|"4.11")$ ]]; then
if [ $RUNNER_OS == 'Windows' ]; then
source $HOME/miniconda/Scripts/activate root && \
conda install conda-libmamba-solver -p $HOME/miniconda
else
source $HOME/miniconda/bin/activate root && \
conda install conda-libmamba-solver -p $HOME/miniconda
fi
fi
- name: Update with test dependencies
shell: bash -l {0}
run: |
if [ $RUNNER_OS == 'Windows' ]; then
source $HOME/miniconda/Scripts/activate root && conda env update -f etc/test-environment.yml -p $HOME/miniconda && $HOME/miniconda/Scripts/pip install --no-deps .
else
source $HOME/miniconda/bin/activate root && conda env update -f etc/test-environment.yml -p $HOME/miniconda && $HOME/miniconda/bin/pip install --no-deps .
fi
- name: py.test
shell: bash -l {0}
env:
CONDA_DEFAULT_CHANNELS: conda-forge
run: |
if [ $RUNNER_OS == 'Windows' ]; then
source $HOME/miniconda/Scripts/activate root && \
conda --version && \
py.test \
-xv \
--cov-report xml:./coverage.xml \
--cov conda_project \
tests
else
source $HOME/miniconda/bin/activate root && \
conda --version && \
py.test \
-xv \
--cov-report xml:./coverage.xml \
--cov conda_project \
tests
fi
- uses: codecov/codecov-action@v2
with:
files: ./coverage.xml
env_vars: OS,PYTHON
upload:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Retrieve the source code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download the build artifacts
uses: actions/download-artifact@v2
with:
name: package-${{ github.sha }}
path: conda-bld
- name: Upload to anaconda.org
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
GITHUB_REF: ${{ github.ref }}
run: |
source $CONDA/bin/activate
conda install -y anaconda-client
[[ "$GITHUB_REF" =~ ^refs/tags/ ]] || export LABEL="--label dev"
anaconda --verbose --token $ANACONDA_TOKEN upload --user defusco $LABEL conda-bld/noarch/conda-project*.tar.bz2 --force
- name: Clean up older artifacts
uses: glassechidna/artifact-cleaner@master
with:
minimumAge: 86400
publish-to-pypi:
name: Publish to PyPI
if: startsWith(github.event.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: [check]
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Setup Python
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4
- name: Download the build artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3
with:
name: builds-${{ github.sha }}
path: ~/dist
- name: Install build dependencies
run: pip install twine
- name: Upload to PyPI with twine
run: python -m twine upload ~/dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN}}
# This check job runs to ensure all tests have passed, such that we can use it as a "wildcard" for branch
# protection to ensure all tests pass before a PR can be merged.
check:
if: always()
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Decide whether all required jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}