Skip to content

Commit

Permalink
Tweak build workflow (#123)
Browse files Browse the repository at this point in the history
* Tweak build workflow to not run on readme changes

Signed-off-by: Fabrice Normandin <normandf@mila.quebec>

* Update the codecov Gh Action version

Signed-off-by: Fabrice Normandin <normandf@mila.quebec>

* Upload coverage report as a single last step

Signed-off-by: Fabrice Normandin <normandf@mila.quebec>

* Specify artifact name and directory for upload

Signed-off-by: Fabrice Normandin <normandf@mila.quebec>

* Update the upload-artifact step version to v4

Signed-off-by: Fabrice Normandin <normandf@mila.quebec>

* Use unique artifact names

Signed-off-by: Fabrice Normandin <normandf@mila.quebec>

---------

Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
  • Loading branch information
lebrice authored May 15, 2024
1 parent c74ee6d commit 9b4a7cd
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 33 deletions.
71 changes: 51 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
name: Python package

on: [push, pull_request]
on:
push:
branches:
- master
paths-ignore:
- 'README.md'
pull_request:
paths-ignore:
- 'README.md'

# https://stackoverflow.com/a/72408109/6388696
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
linting:
Expand Down Expand Up @@ -63,15 +77,11 @@ jobs:
- name: Test with pytest
run: poetry run pytest --cov=milatools --cov-report=xml --cov-append

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
- name: Store coverage report as an artifact
uses: actions/upload-artifact@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
env_vars: PLATFORM,PYTHON
name: codecov-umbrella
fail_ci_if_error: false
name: coverage-reports-unit-${{ matrix.platform }}-${{ matrix.python-version }}
path: ./coverage.xml

mock-slurm-integration-tests:
name: integration tests with a mock slurm cluster
Expand Down Expand Up @@ -133,19 +143,15 @@ jobs:
- name: Launch integration tests
run: poetry run pytest --slow --cov=milatools --cov-report=xml --cov-append -vvv --log-level=DEBUG
timeout-minutes: 5
timeout-minutes: 15
env:
SLURM_CLUSTER: localhost

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
- name: Store coverage report as an artifact
uses: actions/upload-artifact@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: integrationtests
env_vars: PLATFORM,PYTHON
name: codecov-umbrella
fail_ci_if_error: false
name: coverage-reports-mock-${{ matrix.platform }}-${{ matrix.python-version }}
path: ./coverage.xml

real-slurm-integration-tests:

Expand All @@ -164,5 +170,30 @@ jobs:
cluster: ${{ matrix.cluster }}
python-version: ${{ matrix.python-version }}
timeout-minutes: 30
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

# https://about.codecov.io/blog/uploading-code-coverage-in-a-separate-job-on-github-actions/
upload-coverage-codecov:
needs: [real-slurm-integration-tests]
runs-on: ubuntu-latest
name: Upload coverage reports to Codecov
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: coverage-reports-*
merge-multiple: false
# download all the artifacts in this directory (each .coverage.xml will be in a subdirectory)
# Next step if this doesn't work would be to give the coverage files a unique name and use merge-multiple: true
path: coverage_reports
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
# file: ./coverage.xml # Search for all coverage files from each workflow.
# flags: integrationtests
# env_vars: PLATFORM,PYTHON
# name: codecov-umbrella
directory: coverage_reports
fail_ci_if_error: true
21 changes: 19 additions & 2 deletions .github/workflows/full_cluster_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,22 @@ jobs:
cluster: ${{ matrix.cluster }}
python-version: ${{ matrix.python-version }}
timeout-minutes: 60
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# https://about.codecov.io/blog/uploading-code-coverage-in-a-separate-job-on-github-actions/
upload-coverage-codecov:
needs: [real-slurm-integration-tests]
runs-on: ubuntu-latest
name: Upload coverage reports to Codecov
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
# file: ./coverage.xml # Search for all coverage files from each workflow.
flags: integrationtests
# env_vars: PLATFORM,PYTHON
# name: codecov-umbrella
fail_ci_if_error: true
15 changes: 4 additions & 11 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ on:
required: false
type: number
default: 30
secrets:
CODECOV_TOKEN:
required: true

workflow_dispatch:

Expand Down Expand Up @@ -53,12 +50,8 @@ jobs:
env:
SLURM_CLUSTER: ${{ inputs.cluster }}

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
- name: Store coverage report as an artifact
uses: actions/upload-artifact@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: integrationtests
env_vars: PLATFORM,PYTHON
name: codecov-umbrella
fail_ci_if_error: false
name: coverage-reports-integration-${{ inputs.cluster }}-${{ inputs.python-version }}
path: ./coverage.xml

0 comments on commit 9b4a7cd

Please sign in to comment.