From 9b4a7cdb79966c8fd9e4d59e951511bc95caba24 Mon Sep 17 00:00:00 2001 From: Fabrice Normandin Date: Wed, 15 May 2024 14:13:25 -0400 Subject: [PATCH] Tweak build workflow (#123) * Tweak build workflow to not run on readme changes Signed-off-by: Fabrice Normandin * Update the codecov Gh Action version Signed-off-by: Fabrice Normandin * Upload coverage report as a single last step Signed-off-by: Fabrice Normandin * Specify artifact name and directory for upload Signed-off-by: Fabrice Normandin * Update the upload-artifact step version to v4 Signed-off-by: Fabrice Normandin * Use unique artifact names Signed-off-by: Fabrice Normandin --------- Signed-off-by: Fabrice Normandin --- .github/workflows/build.yml | 71 +++++++++++++++++------- .github/workflows/full_cluster_tests.yml | 21 ++++++- .github/workflows/testing.yml | 15 ++--- 3 files changed, 74 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7fcf1467..e8b5b4a0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: @@ -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 @@ -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: @@ -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 diff --git a/.github/workflows/full_cluster_tests.yml b/.github/workflows/full_cluster_tests.yml index 98748621..6d98bd45 100644 --- a/.github/workflows/full_cluster_tests.yml +++ b/.github/workflows/full_cluster_tests.yml @@ -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 diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 176845ec..4da4de68 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -12,9 +12,6 @@ on: required: false type: number default: 30 - secrets: - CODECOV_TOKEN: - required: true workflow_dispatch: @@ -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