Skip to content

Commit 9b4a7cd

Browse files
authored
Tweak build workflow (#123)
* Tweak build workflow to not run on readme changes Signed-off-by: Fabrice Normandin <[email protected]> * Update the codecov Gh Action version Signed-off-by: Fabrice Normandin <[email protected]> * Upload coverage report as a single last step Signed-off-by: Fabrice Normandin <[email protected]> * Specify artifact name and directory for upload Signed-off-by: Fabrice Normandin <[email protected]> * Update the upload-artifact step version to v4 Signed-off-by: Fabrice Normandin <[email protected]> * Use unique artifact names Signed-off-by: Fabrice Normandin <[email protected]> --------- Signed-off-by: Fabrice Normandin <[email protected]>
1 parent c74ee6d commit 9b4a7cd

File tree

3 files changed

+74
-33
lines changed

3 files changed

+74
-33
lines changed

.github/workflows/build.yml

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
name: Python package
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths-ignore:
8+
- 'README.md'
9+
pull_request:
10+
paths-ignore:
11+
- 'README.md'
12+
13+
# https://stackoverflow.com/a/72408109/6388696
14+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
17+
cancel-in-progress: true
418

519
jobs:
620
linting:
@@ -63,15 +77,11 @@ jobs:
6377
- name: Test with pytest
6478
run: poetry run pytest --cov=milatools --cov-report=xml --cov-append
6579

66-
- name: Upload coverage reports to Codecov
67-
uses: codecov/codecov-action@v3
80+
- name: Store coverage report as an artifact
81+
uses: actions/upload-artifact@v4
6882
with:
69-
token: ${{ secrets.CODECOV_TOKEN }}
70-
file: ./coverage.xml
71-
flags: unittests
72-
env_vars: PLATFORM,PYTHON
73-
name: codecov-umbrella
74-
fail_ci_if_error: false
83+
name: coverage-reports-unit-${{ matrix.platform }}-${{ matrix.python-version }}
84+
path: ./coverage.xml
7585

7686
mock-slurm-integration-tests:
7787
name: integration tests with a mock slurm cluster
@@ -133,19 +143,15 @@ jobs:
133143
134144
- name: Launch integration tests
135145
run: poetry run pytest --slow --cov=milatools --cov-report=xml --cov-append -vvv --log-level=DEBUG
136-
timeout-minutes: 5
146+
timeout-minutes: 15
137147
env:
138148
SLURM_CLUSTER: localhost
139149

140-
- name: Upload coverage reports to Codecov
141-
uses: codecov/codecov-action@v3
150+
- name: Store coverage report as an artifact
151+
uses: actions/upload-artifact@v4
142152
with:
143-
token: ${{ secrets.CODECOV_TOKEN }}
144-
file: ./coverage.xml
145-
flags: integrationtests
146-
env_vars: PLATFORM,PYTHON
147-
name: codecov-umbrella
148-
fail_ci_if_error: false
153+
name: coverage-reports-mock-${{ matrix.platform }}-${{ matrix.python-version }}
154+
path: ./coverage.xml
149155

150156
real-slurm-integration-tests:
151157

@@ -164,5 +170,30 @@ jobs:
164170
cluster: ${{ matrix.cluster }}
165171
python-version: ${{ matrix.python-version }}
166172
timeout-minutes: 30
167-
secrets:
168-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
173+
174+
# https://about.codecov.io/blog/uploading-code-coverage-in-a-separate-job-on-github-actions/
175+
upload-coverage-codecov:
176+
needs: [real-slurm-integration-tests]
177+
runs-on: ubuntu-latest
178+
name: Upload coverage reports to Codecov
179+
steps:
180+
- name: Checkout
181+
uses: actions/checkout@v4
182+
- name: Download artifacts
183+
uses: actions/download-artifact@v4
184+
with:
185+
pattern: coverage-reports-*
186+
merge-multiple: false
187+
# download all the artifacts in this directory (each .coverage.xml will be in a subdirectory)
188+
# Next step if this doesn't work would be to give the coverage files a unique name and use merge-multiple: true
189+
path: coverage_reports
190+
- name: Upload coverage reports to Codecov
191+
uses: codecov/codecov-action@v4
192+
with:
193+
token: ${{ secrets.CODECOV_TOKEN }}
194+
# file: ./coverage.xml # Search for all coverage files from each workflow.
195+
# flags: integrationtests
196+
# env_vars: PLATFORM,PYTHON
197+
# name: codecov-umbrella
198+
directory: coverage_reports
199+
fail_ci_if_error: true

.github/workflows/full_cluster_tests.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,22 @@ jobs:
2727
cluster: ${{ matrix.cluster }}
2828
python-version: ${{ matrix.python-version }}
2929
timeout-minutes: 60
30-
secrets:
31-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
30+
# https://about.codecov.io/blog/uploading-code-coverage-in-a-separate-job-on-github-actions/
31+
upload-coverage-codecov:
32+
needs: [real-slurm-integration-tests]
33+
runs-on: ubuntu-latest
34+
name: Upload coverage reports to Codecov
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
- name: Download artifacts
39+
uses: actions/download-artifact@v4
40+
- name: Upload coverage reports to Codecov
41+
uses: codecov/codecov-action@v4
42+
with:
43+
token: ${{ secrets.CODECOV_TOKEN }}
44+
# file: ./coverage.xml # Search for all coverage files from each workflow.
45+
flags: integrationtests
46+
# env_vars: PLATFORM,PYTHON
47+
# name: codecov-umbrella
48+
fail_ci_if_error: true

.github/workflows/testing.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ on:
1212
required: false
1313
type: number
1414
default: 30
15-
secrets:
16-
CODECOV_TOKEN:
17-
required: true
1815

1916
workflow_dispatch:
2017

@@ -53,12 +50,8 @@ jobs:
5350
env:
5451
SLURM_CLUSTER: ${{ inputs.cluster }}
5552

56-
- name: Upload coverage reports to Codecov
57-
uses: codecov/codecov-action@v3
53+
- name: Store coverage report as an artifact
54+
uses: actions/upload-artifact@v4
5855
with:
59-
token: ${{ secrets.CODECOV_TOKEN }}
60-
file: ./coverage.xml
61-
flags: integrationtests
62-
env_vars: PLATFORM,PYTHON
63-
name: codecov-umbrella
64-
fail_ci_if_error: false
56+
name: coverage-reports-integration-${{ inputs.cluster }}-${{ inputs.python-version }}
57+
path: ./coverage.xml

0 commit comments

Comments
 (0)