From 15168337e1fbea3b6d1e19331b97b4e8abedf225 Mon Sep 17 00:00:00 2001 From: AlexVCaron Date: Mon, 19 Feb 2024 15:15:32 -0500 Subject: [PATCH 01/12] split workflowin twain so we can re-run only codecov when it fails --- .github/workflows/test.yml | 44 +++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ded929612..843339228 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,18 @@ jobs: test: runs-on: scilus-runners if: github.repository == 'scilus/scilpy' + steps: + # If this runs and does not fails, its because the workflow was relaunched + # with no resuming and we need to delete the artifact since we + # re-executed the tests. Else, it'll fail the job (silently) and the + # remaining workflow will continue + - name: Delete tests and coverage artifact + uses: geekyeggo/delete-artifact@v4 + with: + name: test-coverage-${{ github.run_id }} + failOnError: false + - name: Checkout repository for merge uses: actions/checkout@v4 @@ -55,6 +66,29 @@ jobs: export C_INCLUDE_PATH=$pythonLocation/include/python${{ steps.python-selector.outputs.python-version }}:$C_INCLUDE_PATH pytest --cov-report term-missing:skip-covered + - name: Save test results and coverage + uses: actions/upload-artifact@v4 + id: test-coverage-results + with: + name: test-coverage-${{ github.run_id }} + path: | + .coverage + .test_data/ + + coverage: + runs-on: scilus-runners + if: github.repository == 'scilus/scilpy' + needs: test + + steps: + - name: Checkout repository for merge + uses: actions/checkout@v4 + + - name: Download test results and coverage + uses: actions/download-artifact@v4 + with: + name: test-coverage-${{ github.run_id }} + - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 with: @@ -65,9 +99,9 @@ jobs: fail_ci_if_error: true plugin: pycoverage - - name: Upload test reports and coverage to artifacts - uses: actions/upload-artifact@v4.3.1 + - name: Delete tests and coverage artifact + uses: geekyeggo/delete-artifact@v4 + if: success() with: - name: test-reports - path: | - .test_reports/* + name: test-coverage-${{ github.run_id }} + failOnError: false From 99d5b5a9e1682fda42960492103177cd53b7ede9 Mon Sep 17 00:00:00 2001 From: AlexVCaron Date: Mon, 19 Feb 2024 15:27:36 -0500 Subject: [PATCH 02/12] for a workflow run --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 843339228..ad5101b72 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,9 +23,9 @@ jobs: steps: # If this runs and does not fails, its because the workflow was relaunched - # with no resuming and we need to delete the artifact since we - # re-executed the tests. Else, it'll fail the job (silently) and the - # remaining workflow will continue + # with no resuming and we need to delete the artifact since we + # re-executed the tests. Else, if nothing to do, it'll fail the job + # (silently) and the remaining workflow will continue - name: Delete tests and coverage artifact uses: geekyeggo/delete-artifact@v4 with: From b6c70469a618abc886278853d3b0407cbfca7c30 Mon Sep 17 00:00:00 2001 From: AlexVCaron Date: Mon, 19 Feb 2024 16:18:47 -0500 Subject: [PATCH 03/12] inspect path content after artifact download --- .github/workflows/test.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ad5101b72..f7562be96 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -73,7 +73,7 @@ jobs: name: test-coverage-${{ github.run_id }} path: | .coverage - .test_data/ + .test_reports/ coverage: runs-on: scilus-runners @@ -89,6 +89,16 @@ jobs: with: name: test-coverage-${{ github.run_id }} + - name: Show the content of the workspace where we upload + run: | + echo "what is here : $(pwd)" + ls . + echo "what is in GITHUB_WORKSPACE : $GITHUB_WORKSPACE" + ls $GITHUB_WORKSPACE + echo "what is in github.workspace : ${{ github.workspace }}" + ls ${{ github.workspace }} + exit 1 + - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 with: From 2e0556db18a5448582f36793fd5fd2ab3c455421 Mon Sep 17 00:00:00 2001 From: AlexVCaron Date: Mon, 19 Feb 2024 19:05:18 -0500 Subject: [PATCH 04/12] show hidden --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f7562be96..9926bbe8d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -92,11 +92,11 @@ jobs: - name: Show the content of the workspace where we upload run: | echo "what is here : $(pwd)" - ls . + ls -lha . echo "what is in GITHUB_WORKSPACE : $GITHUB_WORKSPACE" - ls $GITHUB_WORKSPACE + ls -lha $GITHUB_WORKSPACE echo "what is in github.workspace : ${{ github.workspace }}" - ls ${{ github.workspace }} + ls -lha ${{ github.workspace }} exit 1 - name: Upload coverage reports to Codecov From 480f19c4f9de98d6b7cec2ce9b65df112f7d8342 Mon Sep 17 00:00:00 2001 From: AlexVCaron Date: Mon, 19 Feb 2024 21:15:36 -0500 Subject: [PATCH 05/12] download to scilpy path, workspace seems not to point to it --- .github/workflows/test.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9926bbe8d..8133ee7a7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -88,16 +88,7 @@ jobs: uses: actions/download-artifact@v4 with: name: test-coverage-${{ github.run_id }} - - - name: Show the content of the workspace where we upload - run: | - echo "what is here : $(pwd)" - ls -lha . - echo "what is in GITHUB_WORKSPACE : $GITHUB_WORKSPACE" - ls -lha $GITHUB_WORKSPACE - echo "what is in github.workspace : ${{ github.workspace }}" - ls -lha ${{ github.workspace }} - exit 1 + path: ${{ github.workspace }}/scilpy - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 From e9830f00789df440734fef7c3cc17345dd620ddf Mon Sep 17 00:00:00 2001 From: AlexVCaron Date: Mon, 19 Feb 2024 21:58:23 -0500 Subject: [PATCH 06/12] install coverage in upload step --- .github/workflows/test.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8133ee7a7..cb7d8c2fd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -84,11 +84,19 @@ jobs: - name: Checkout repository for merge uses: actions/checkout@v4 + - name: Set up Python for Scilpy + uses: actions/setup-python@v5.0.0 + with: + python-version: 3.10 + cache: 'pip' + + - name: Install pycoverage + run: pip install coverage + - name: Download test results and coverage uses: actions/download-artifact@v4 with: name: test-coverage-${{ github.run_id }} - path: ${{ github.workspace }}/scilpy - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 From c775d2cbc67db81ea10e9345e5bce975331c6b78 Mon Sep 17 00:00:00 2001 From: Alex Valcourt Caron Date: Mon, 19 Feb 2024 23:54:44 -0500 Subject: [PATCH 07/12] python version is a string --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb7d8c2fd..8c7277215 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -87,7 +87,7 @@ jobs: - name: Set up Python for Scilpy uses: actions/setup-python@v5.0.0 with: - python-version: 3.10 + python-version: '3.10' cache: 'pip' - name: Install pycoverage From 08bef630bf8ecb8b5e8d7e5aa3d689bb3a0c54cd Mon Sep 17 00:00:00 2001 From: AlexVCaron Date: Tue, 20 Feb 2024 09:44:38 -0500 Subject: [PATCH 08/12] lean down tests and relaunch with new perm --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8c7277215..c715994ef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: name: test-coverage-${{ github.run_id }} failOnError: false - - name: Checkout repository for merge + - name: Checkout repository at merge uses: actions/checkout@v4 - name: Fetch python version from repository @@ -64,7 +64,7 @@ jobs: - name: Run tests run: | export C_INCLUDE_PATH=$pythonLocation/include/python${{ steps.python-selector.outputs.python-version }}:$C_INCLUDE_PATH - pytest --cov-report term-missing:skip-covered + pytest --cov-report term-missing:skip-covered scripts/tests/test_bids_validate.py - name: Save test results and coverage uses: actions/upload-artifact@v4 @@ -81,10 +81,10 @@ jobs: needs: test steps: - - name: Checkout repository for merge + - name: Checkout repository at merge uses: actions/checkout@v4 - - name: Set up Python for Scilpy + - name: Set up Python for codecov upload uses: actions/setup-python@v5.0.0 with: python-version: '3.10' From da4a9313fa412bb0cf876db12faad84ca5119764 Mon Sep 17 00:00:00 2001 From: AlexVCaron Date: Tue, 20 Feb 2024 10:09:58 -0500 Subject: [PATCH 09/12] set permission to delete artifact --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c715994ef..0ec2a62b9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,6 +16,9 @@ env: MPLBACKEND: agg OPENBLAS_NUM_THREADS: 1 +permissions: + actions: write + jobs: test: runs-on: scilus-runners From 41956e7a654ea557c85e408272424840e0a8e693 Mon Sep 17 00:00:00 2001 From: AlexVCaron Date: Tue, 20 Feb 2024 10:45:56 -0500 Subject: [PATCH 10/12] reduce artifacts retention instead of delete. Exclude legacy main call of scripts from coverage --- .coveragerc | 5 ++++- .github/workflows/test.yml | 22 ++-------------------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/.coveragerc b/.coveragerc index 21b501e1c..7dfe68ff8 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,7 +2,7 @@ branch = True concurrency = multiprocessing data_file = .coverage -source_pkgs = +source_pkgs = scilpy scripts relative_files = True @@ -17,6 +17,9 @@ omit = [report] skip_empty = True skip_covered = True +exclude_also = + if __name__ == "__main__": + main() [html] title = Scilpy Coverage Report diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0ec2a62b9..82a88721b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,25 +16,12 @@ env: MPLBACKEND: agg OPENBLAS_NUM_THREADS: 1 -permissions: - actions: write - jobs: test: runs-on: scilus-runners if: github.repository == 'scilus/scilpy' steps: - # If this runs and does not fails, its because the workflow was relaunched - # with no resuming and we need to delete the artifact since we - # re-executed the tests. Else, if nothing to do, it'll fail the job - # (silently) and the remaining workflow will continue - - name: Delete tests and coverage artifact - uses: geekyeggo/delete-artifact@v4 - with: - name: test-coverage-${{ github.run_id }} - failOnError: false - - name: Checkout repository at merge uses: actions/checkout@v4 @@ -74,6 +61,7 @@ jobs: id: test-coverage-results with: name: test-coverage-${{ github.run_id }} + retention-days: 1 path: | .coverage .test_reports/ @@ -106,14 +94,8 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} flags: unittests - name: scilpy-unittests-${{ github.run_id }} + name: scilpy-unittests-${{ github.run_id }}-${{ github.run_attempt }} verbose: true fail_ci_if_error: true plugin: pycoverage - - name: Delete tests and coverage artifact - uses: geekyeggo/delete-artifact@v4 - if: success() - with: - name: test-coverage-${{ github.run_id }} - failOnError: false From 480e005348b3cef1cdcd21ab5190b509ba5f8597 Mon Sep 17 00:00:00 2001 From: AlexVCaron Date: Tue, 20 Feb 2024 11:05:21 -0500 Subject: [PATCH 11/12] Include the main definition --- .coveragerc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coveragerc b/.coveragerc index 7dfe68ff8..7b98ae4cf 100644 --- a/.coveragerc +++ b/.coveragerc @@ -19,7 +19,7 @@ skip_empty = True skip_covered = True exclude_also = if __name__ == "__main__": - main() + (? Date: Tue, 20 Feb 2024 11:11:07 -0500 Subject: [PATCH 12/12] re-enable whole test suite --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 82a88721b..8e714f6c4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,7 +54,7 @@ jobs: - name: Run tests run: | export C_INCLUDE_PATH=$pythonLocation/include/python${{ steps.python-selector.outputs.python-version }}:$C_INCLUDE_PATH - pytest --cov-report term-missing:skip-covered scripts/tests/test_bids_validate.py + pytest --cov-report term-missing:skip-covered - name: Save test results and coverage uses: actions/upload-artifact@v4