-
Notifications
You must be signed in to change notification settings - Fork 41
301 lines (264 loc) · 10.4 KB
/
pytests-upstream.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
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
name: CI tests Upstream
# Daily tests with all un-pinned dependencies
# Allows to be warned when argopy fail tests due to updates in dependencies
on:
schedule:
- cron: "0 0 * * *" # Daily “At 00:00” UTC
workflow_dispatch: # allows you to trigger the workflow run manually
pull_request:
types: [synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
jobs:
detect-ci-trigger:
name: detect upstream ci trigger
runs-on: ubuntu-latest
if: |
github.repository == 'euroargodev/argopy'
&& (github.event_name == 'push' || github.event_name == 'pull_request')
outputs:
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: xarray-contrib/ci-trigger@v1
id: detect-trigger
with:
keyword: "[test-upstream]"
detect-ci-skip:
name: detect upstream ci skip
runs-on: ubuntu-latest
if: |
github.repository == 'euroargodev/argopy'
&& (github.event_name == 'push' || github.event_name == 'pull_request')
outputs:
skipped: ${{ steps.detect-skip.outputs.trigger-found }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: xarray-contrib/ci-trigger@v1.2
id: detect-skip
with:
keyword: "[skip-ci]"
core-free:
# CI tests for environments with core requirements in free versions
name: Core - Free - Py${{matrix.python-version}} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: [detect-ci-trigger, detect-ci-skip]
if: |
always()
&& (
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
|| needs.detect-ci-trigger.outputs.triggered == 'true'
|| needs.detect-ci-skip.outputs.skipped == 'false'
|| contains(github.event.pull_request.labels.*.name, 'release')
)
defaults:
run:
shell: bash -l {0}
# timeout-minutes: 45
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
steps:
- name: Energy Estimation - Initialize
if: ${{matrix.os == 'ubuntu-latest'}}
uses: green-coding-berlin/eco-ci-energy-estimation@v4
with:
task: start-measurement
company-uuid: ${{ secrets.CARBONDB_COMPANY_UUID }}
project-uuid: ${{ secrets.CARBONDB_PROJECT_UUID }}
machine-uuid: ${{ secrets.CARBONDB_MACHINE_UUID_PYTESTS_UPSTREAM }}
continue-on-error: true
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags.
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
aws-region: us-west-1
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/ga-ci-tests-argopy-01
- name: Set environment variables
run: |
echo "CONDA_ENV_FILE=ci/requirements/py${{matrix.python-version}}-core-free.yml" >> $GITHUB_ENV
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
echo "LOG_FILE=argopy-tests-Core-Free-Py${{matrix.python-version}}-${{matrix.os}}.log" >> $GITHUB_ENV
- name: Setup Micromamba ${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@v2
with:
micromamba-version: '1.5.10-0'
environment-name: argopy-tests
environment-file: ${{ env.CONDA_ENV_FILE }}
init-shell: bash
cache-environment: true
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{matrix.python-version}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
create-args: >-
python=${{matrix.python-version}}
- name: Install argopy
run: |
python -m pip install --no-deps -e .
- name: Version info
run: |
micromamba info
micromamba list
- name: Energy Estimation - Measure Tests Setup
if: ${{matrix.os == 'ubuntu-latest'}}
uses: green-coding-berlin/eco-ci-energy-estimation@v4
env:
ELECTRICITY_MAPS_TOKEN: ${{ secrets.ELECTRICITY_MAPS_TOKEN }}
with:
task: get-measurement
label: 'setup core-free'
continue-on-error: true
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest -ra -v -s -c argopy/tests/pytest.ini --durations=10 \
--report-log output-${{ matrix.python-version }}-log.jsonl
- name: Energy Estimation - Measure Tests Exec
if: ${{matrix.os == 'ubuntu-latest'}}
uses: green-coding-berlin/eco-ci-energy-estimation@v4
env:
ELECTRICITY_MAPS_TOKEN: ${{ secrets.ELECTRICITY_MAPS_TOKEN }}
with:
task: get-measurement
label: 'pytest core-free'
continue-on-error: true
- name: Generate and publish a report on failure
if: |
failure()
&& github.repository_owner == 'euroargodev'
uses: xarray-contrib/issue-from-pytest-log@main
with:
log-path: output-${{ matrix.python-version }}-log.jsonl
issue-title: "Upstream CI tests failed: Core - Free - Py${{matrix.python-version}} - ${{ matrix.os }}"
- name: Save tests log as artifact
uses: actions/upload-artifact@v4
with:
name: Argopy-Tests-Core-${{matrix.python-version}}-${{matrix.os}}
path: output-${{ matrix.python-version }}-log.jsonl
retention-days: 90
- name: Energy Estimation - Show Results
if: ${{matrix.os == 'ubuntu-latest'}}
uses: green-coding-berlin/eco-ci-energy-estimation@v4
env:
ELECTRICITY_MAPS_TOKEN: ${{ secrets.ELECTRICITY_MAPS_TOKEN }}
with:
task: display-results
send-data: true
continue-on-error: true
all-free:
# CI tests for environments with all possible requirements in free versions
name: All - Free - Py${{matrix.python-version}} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: [detect-ci-trigger, detect-ci-skip]
if: |
always()
&& (
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
|| needs.detect-ci-trigger.outputs.triggered == 'true'
|| needs.detect-ci-skip.outputs.skipped == 'false'
|| contains(github.event.pull_request.labels.*.name, 'release')
)
defaults:
run:
shell: bash -l {0}
# timeout-minutes: 45
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
steps:
- name: Energy Estimation - Initialize
if: ${{matrix.os == 'ubuntu-latest'}}
uses: green-coding-berlin/eco-ci-energy-estimation@v4
with:
task: start-measurement
company-uuid: ${{ secrets.CARBONDB_COMPANY_UUID }}
project-uuid: ${{ secrets.CARBONDB_PROJECT_UUID }}
machine-uuid: ${{ secrets.CARBONDB_MACHINE_UUID_PYTESTS_UPSTREAM }}
continue-on-error: true
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags.
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
aws-region: us-west-1
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/ga-ci-tests-argopy-01
- name: Set environment variables
run: |
echo "CONDA_ENV_FILE=ci/requirements/py${{matrix.python-version}}-all-free.yml" >> $GITHUB_ENV
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
- name: Setup Micromamba ${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@v2
with:
micromamba-version: '1.5.10-0'
environment-name: argopy-tests
environment-file: ${{ env.CONDA_ENV_FILE }}
init-shell: bash
cache-environment: true
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{matrix.python-version}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
create-args: >-
python=${{matrix.python-version}}
pytest-reportlog
- name: Install argopy
run: |
python -m pip install --no-deps -e .
- name: Version info
run: |
micromamba info
micromamba list
- name: Energy Estimation - Measure Tests Setup
if: ${{matrix.os == 'ubuntu-latest'}}
uses: green-coding-berlin/eco-ci-energy-estimation@v4
env:
ELECTRICITY_MAPS_TOKEN: ${{ secrets.ELECTRICITY_MAPS_TOKEN }}
with:
task: get-measurement
label: 'setup all-free'
continue-on-error: true
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest -ra -v -s -c argopy/tests/pytest.ini --durations=10 \
--report-log output-${{ matrix.python-version }}-log.jsonl
- name: Energy Estimation - Measure Tests Exec
if: ${{matrix.os == 'ubuntu-latest'}}
uses: green-coding-berlin/eco-ci-energy-estimation@v4
env:
ELECTRICITY_MAPS_TOKEN: ${{ secrets.ELECTRICITY_MAPS_TOKEN }}
with:
task: get-measurement
label: 'pytest all-free'
continue-on-error: true
- name: Save tests log as artifact
uses: actions/upload-artifact@v4
with:
name: Argopy-Tests-All-${{matrix.python-version}}-${{matrix.os}}
path: output-${{ matrix.python-version }}-log.jsonl
retention-days: 90
- name: Energy Estimation - Show Results
if: ${{matrix.os == 'ubuntu-latest'}}
uses: green-coding-berlin/eco-ci-energy-estimation@v4
env:
ELECTRICITY_MAPS_TOKEN: ${{ secrets.ELECTRICITY_MAPS_TOKEN }}
with:
task: display-results
send-data: true
continue-on-error: true