@@ -14,65 +14,95 @@ concurrency:
14
14
group : ${{ github.workflow }}-${{ github.ref }}
15
15
cancel-in-progress : true
16
16
17
+ defaults :
18
+ run :
19
+ shell : bash -l {0}
20
+
17
21
jobs :
18
22
pre-commit :
19
23
runs-on : ubuntu-latest
20
24
steps :
21
- - uses : actions/checkout@v3
22
- - uses : actions/setup-python@v4
25
+ - uses : actions/checkout@v4
26
+ - uses : actions/setup-python@v5
23
27
with :
24
28
python-version : 3.x
25
29
-
uses :
pre-commit/[email protected]
26
30
31
+ combine-environments :
32
+ runs-on : ubuntu-latest
33
+
34
+ steps :
35
+ - uses : actions/checkout@v4
36
+ - uses : actions/setup-python@v5
37
+ with :
38
+ python-version : 3.x
39
+ - name : Install conda-merge
40
+ run : |
41
+ python -m pip install conda-merge
42
+ - name : Combine environments
43
+ run : |
44
+ for SUFFIX in ci integration; do
45
+ conda-merge ci/environment-$SUFFIX.yml environment.yml > ci/combined-environment-$SUFFIX.yml || exit
46
+ done
47
+ - uses : actions/upload-artifact@v4
48
+ with :
49
+ name : combined-environments
50
+ path : ci/combined-environment-*.yml
51
+
27
52
unit-tests :
28
- name : unit-tests (3.11)
53
+ name : unit-tests
54
+ needs : combine-environments
29
55
runs-on : ubuntu-latest
30
- defaults :
31
- run :
32
- shell : bash -l {0}
56
+ strategy :
57
+ matrix :
58
+ python-version : ['3.11']
33
59
34
60
steps :
35
- - uses : actions/checkout@v3
36
- - name : Install Conda environment with Micromamba
37
- uses : mamba-org/provision-with-micromamba@v15
61
+ - uses : actions/checkout@v4
62
+ - uses : actions/download-artifact@v4
63
+ with :
64
+ name : combined-environments
65
+ path : ci
66
+ - name : Get current date
67
+ id : date
68
+ run : echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}"
69
+ - uses : mamba-org/setup-micromamba@v1
38
70
with :
39
- environment-file : environment.yml
71
+ environment-file : ci/combined- environment-ci .yml
40
72
environment-name : DEVELOP
41
- channels : conda-forge
42
- cache-env : true
43
- cache-env -key : ubuntu-latest-3.11
44
- extra-specs : |
45
- python=3.11
73
+ cache-environment : true
74
+ cache-environment-key : environment-${{ steps.date.outputs.date }}
75
+ cache-downloads -key : downloads-${{ steps.date.outputs.date }}
76
+ create-args : >-
77
+ python=${{ matrix.python-version }}
46
78
- name : Install package
47
79
run : |
48
80
python -m pip install --no-deps -e .
49
81
- name : Run tests
50
82
run : |
51
- make test COV_REPORT=xml
52
- - name : Run doc tests
53
- run : |
54
- make doc-test COV_REPORT=xml
55
- - name : Upload code coverage to Codecov
56
-
83
+ make unit-tests COV_REPORT=xml
57
84
58
85
type-check :
59
- needs : [unit-tests]
86
+ needs : [combine-environments, unit-tests]
60
87
runs-on : ubuntu-latest
61
- defaults :
62
- run :
63
- shell : bash -l {0}
64
88
65
89
steps :
66
- - uses : actions/checkout@v3
67
- - name : Install Conda environment with Micromamba
68
- uses : mamba-org/provision-with-micromamba@v15
90
+ - uses : actions/checkout@v4
91
+ - uses : actions/download-artifact@v4
92
+ with :
93
+ name : combined-environments
94
+ path : ci
95
+ - name : Get current date
96
+ id : date
97
+ run : echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}"
98
+ - uses : mamba-org/setup-micromamba@v1
69
99
with :
70
- environment-file : environment.yml
100
+ environment-file : ci/combined- environment-ci .yml
71
101
environment-name : DEVELOP
72
- channels : conda-forge
73
- cache-env : true
74
- cache-env -key : ubuntu-latest-3.11
75
- extra-specs : |
102
+ cache-environment : true
103
+ cache-environment-key : environment-${{ steps.date.outputs.date }}
104
+ cache-downloads -key : downloads-${{ steps.date.outputs.date }}
105
+ create-args : >-
76
106
python=3.11
77
107
- name : Install package
78
108
run : |
@@ -81,55 +111,125 @@ jobs:
81
111
run : |
82
112
make type-check
83
113
114
+ docs-build :
115
+ needs : [combine-environments, unit-tests]
116
+ runs-on : ubuntu-latest
117
+
118
+ steps :
119
+ - uses : actions/checkout@v4
120
+ - uses : actions/download-artifact@v4
121
+ with :
122
+ name : combined-environments
123
+ path : ci
124
+ - name : Get current date
125
+ id : date
126
+ run : echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}"
127
+ - uses : mamba-org/setup-micromamba@v1
128
+ with :
129
+ environment-file : ci/combined-environment-ci.yml
130
+ environment-name : DEVELOP
131
+ cache-environment : true
132
+ cache-environment-key : environment-${{ steps.date.outputs.date }}
133
+ cache-downloads-key : downloads-${{ steps.date.outputs.date }}
134
+ create-args : >-
135
+ python=3.11
136
+ - name : Install package
137
+ run : |
138
+ python -m pip install --no-deps -e .
139
+ - name : Build documentation
140
+ run : |
141
+ make docs-build
142
+
84
143
integration-tests :
85
- needs : [unit-tests]
144
+ needs : [combine-environments, unit-tests]
145
+ if : |
146
+ success() && true
86
147
runs-on : ubuntu-latest
87
- defaults :
88
- run :
89
- shell : bash -l {0}
90
148
91
149
strategy :
92
150
matrix :
93
- python-version : ['3.10', '3.9']
94
- extra : ['']
95
151
include :
96
152
- python-version : ' 3.9'
97
- extra : -minver
153
+ extra : -integration
98
154
99
155
steps :
100
- - uses : actions/checkout@v3
101
- - name : Install Conda environment with Micromamba
102
- uses : mamba-org/provision-with-micromamba@v15
156
+ - uses : actions/checkout@v4
157
+ - uses : actions/download-artifact@v4
158
+ with :
159
+ name : combined-environments
160
+ path : ci
161
+ - name : Get current date
162
+ id : date
163
+ run : echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}"
164
+ - uses : mamba-org/setup-micromamba@v1
103
165
with :
104
- environment-file : environment${{ matrix.extra }}.yml
166
+ environment-file : ci/combined- environment${{ matrix.extra }}.yml
105
167
environment-name : DEVELOP${{ matrix.extra }}
106
- channels : conda-forge
107
- cache-env : true
108
- cache-env -key : ubuntu-latest- ${{ matrix.python-version }}${{ matrix.extra }}.
109
- extra-specs : |
168
+ cache-environment : true
169
+ cache-environment-key : environment-${{ steps.date.outputs.date }}
170
+ cache-downloads -key : downloads- ${{ steps.date.outputs.date }}
171
+ create-args : >-
110
172
python=${{ matrix.python-version }}
111
173
- name : Install package
112
174
run : |
113
175
python -m pip install --no-deps -e .
114
176
- name : Run tests
115
177
run : |
116
- make test COV_REPORT=xml
117
- - name : Upload code coverage to Codecov
118
-
178
+ make unit-tests COV_REPORT=xml
119
179
120
180
distribution :
121
181
runs-on : ubuntu-latest
122
- needs : [integration-tests, type-check]
182
+ needs : [unit-tests, type-check, docs-build, integration-tests]
183
+ if : |
184
+ always() &&
185
+ needs.unit-tests.result == 'success' &&
186
+ needs.type-check.result == 'success' &&
187
+ needs.docs-build.result == 'success' &&
188
+ (needs.integration-tests.result == 'success' || needs.integration-tests.result == 'skipped')
123
189
124
190
steps :
125
- - uses : actions/checkout@v3
126
- - name : Build distributions
191
+ - uses : actions/checkout@v4
192
+ - uses : actions/setup-python@v5
193
+ with :
194
+ python-version : ' 3.11'
195
+ - name : Install package
196
+ run : |
197
+ python -m pip install --upgrade pip
198
+ python -m pip install build twine
199
+ - name : Build distribution
127
200
run : |
128
- $CONDA/bin/python -m pip install build
129
- $CONDA/bin/python -m build
130
- - name : Publish a Python distribution to PyPI
131
- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
132
- uses : pypa/gh-action-pypi-publish@release/v1
201
+ python -m build
202
+ - name : Check wheels
203
+ run : |
204
+ cd dist || exit
205
+ python -m pip install xarray_sentinel*.whl || exit
206
+ python -m twine check --strict * || exit
207
+ python -c "import xarray_sentinel" || exit
208
+ cd ..
209
+ - uses : actions/upload-artifact@v4
210
+ with :
211
+ name : distribution
212
+ path : dist
213
+
214
+ upload-to-pypi :
215
+ runs-on : ubuntu-latest
216
+ needs : distribution
217
+ if : |
218
+ always() &&
219
+ needs.distribution.result == 'success' &&
220
+ github.event_name == 'push' &&
221
+ startsWith(github.ref, 'refs/tags')
222
+ environment :
223
+ name : pypi
224
+ url : https://pypi.org/p/xarray-sentinel
225
+ permissions :
226
+ id-token : write # IMPORTANT: this permission is mandatory for trusted publish
227
+
228
+ steps :
229
+ - uses : actions/download-artifact@v4
230
+ with :
231
+ name : distribution
232
+ path : dist
233
+
133
234
with :
134
- user : __token__
135
- password : ${{ secrets.PYPI_API_TOKEN }}
235
+ verbose : true
0 commit comments