From 9fe61e1c00348bbe2287bddf76508e3d35fcee35 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Mon, 23 Aug 2021 14:05:34 +0100 Subject: [PATCH 01/12] use skip flag for turning off tests --- sources.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sources.yml b/sources.yml index fb60926..bc0897d 100644 --- a/sources.yml +++ b/sources.yml @@ -14,37 +14,47 @@ - name: create script: ome_zarr_create + skip: False - name: localfake1 path: data/64x64-fake-v0.1/0 + skip: False - name: localfake2 path: data/64x64-fake-v0.2/0 + skip: False - name: localfake3 path: data/64x64-fake-v0.3/0 + skip: False - name: remotefake1 path: https://s3.embassy.ebi.ac.uk/idr/zarr/test-data/64x64-fake-v0.1/0 + skip: False - name: remotefake2 path: https://s3.embassy.ebi.ac.uk/idr/zarr/test-data/64x64-fake-v0.2/0 + skip: False - name: idr6001240 path: https://s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001240.zarr - + skip: False + - name: bf2rawraw script: bioformats2raw_fake args: - "--compression=raw" - "--nested=true" + skip: False - name: bf2rawcompressed script: bioformats2raw_fake args: - "--compression=blosc" - "--nested=true" + skip: False - name: omeromszarr script: omero_ms_zarr_fake connection: http://localhost:8080/image/1.zarr/ + skip: False From 12dab2ba07c0ac7066e1bc808d30db2158d8ec20 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Mon, 23 Aug 2021 14:06:20 +0100 Subject: [PATCH 02/12] add script to turn test on/off depending on the repo posting event --- configure_test.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 configure_test.py diff --git a/configure_test.py b/configure_test.py new file mode 100644 index 0000000..4f97151 --- /dev/null +++ b/configure_test.py @@ -0,0 +1,26 @@ +import yaml +import sys + +# Change the value of the skip flag depending on the repository used +# repository: +#value = "bioformats2raw", "ome_zarr", "omero_ms_zarr" +ref_value = "ome_zarr" +def main(argv): + value = argv[0] + with open('sources.yml', 'r') as f: + doc = yaml.safe_load(f) + for k in doc: + k['skip'] = True + if 'script' in k: + if k['script'].startswith(value): + k['skip'] = False + else: + if value == ref_value: + k['skip'] = False + + + with open('sources.yml', 'w') as f: + yaml.dump(doc, f, default_flow_style=False, sort_keys=False) + +if __name__ == "__main__": + main(sys.argv[1:]) From f1e4823c12f953adda78a242d6d760f17afd96f3 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Mon, 23 Aug 2021 14:07:05 +0100 Subject: [PATCH 03/12] adjust script to add support for other repo --- scripts/bioformats2raw_fake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/bioformats2raw_fake b/scripts/bioformats2raw_fake index 5025f80..7832957 100755 --- a/scripts/bioformats2raw_fake +++ b/scripts/bioformats2raw_fake @@ -2,8 +2,9 @@ set -e set -u image_name=ome_zarr_suite_bf2raw -git clone git://github.com/glencoesoftware/bioformats2raw 1>&2 -cd bioformats2raw +SUITE=ome-zarr-bf2raw-suite +test -e $SUITE || git clone git://github.com/glencoesoftware/bioformats2raw $SUITE 1>&2 +cd $SUITE docker build -t ${image_name} . 1>&2 cd .. echo $PWD 1>&2 From 9b099f6b3779b14d67b844d72653b84052b1e34d Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Mon, 23 Aug 2021 14:10:48 +0100 Subject: [PATCH 04/12] handle repository dispatch --- .github/workflows/main.yml | 54 +++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2f94666..900f8aa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,6 +2,8 @@ name: Build on: + repository_dispatch: + types: [run_test_suite] push: pull_request: schedule: @@ -9,11 +11,16 @@ on: jobs: build: + strategy: + matrix: + repo: ['jburel/omero-ms-zarr'] runs-on: ubuntu-latest + env: + ms_suite: omero-ms-zarr-suite + bf_suite: ome-zarr-bf2raw-suite + zarr_suite: ome-zarr-py-suite steps: - - uses: actions/checkout@v2 - - name: Setup miniconda uses: conda-incubator/setup-miniconda@v2 with: @@ -21,7 +28,48 @@ jobs: channels: conda-forge,ome environment-file: environment.yml python-version: 3.9 - + - name: Set testing environment + if: github.event.action == 'run_test_suite' + shell: bash + run: | + # Set the parameters to be used in the response + echo "client_repo="${{ github.event.client_payload.repo }} >> $GITHUB_ENV + echo "client_ref="${{ github.event.client_payload.ref }} >> $GITHUB_ENV + echo "client_sha="${{ github.event.client_payload.sha }} >> $GITHUB_ENV + echo "client_number="${{ github.event.client_payload.number }} >> $GITHUB_ENV + repo=${{ github.event.client_payload.repo }} + # Checkout the sha from the specified repository. + # Only run the tests matching the specified repository. + if [[ $repo =~ 'omero-ms-zarr' ]]; then + git clone git://github.com/$repo ${{env.ms_suite}} + cd ${{env.ms_suite}} + git checkout ${{ github.event.client_payload.sha }} + cd .. + python configure_test.py omero_ms_zarr + elif [[ $repo =~ 'bioformats2raw' ]]; then + git clone git://github.com/$repo ${{env.bf_suite}} + cd ${{env.bf_suite}} + git checkout ${{ github.event.client_payload.sha }} + cd .. + python configure_test.py bioformats2raw + elif [[ $repo =~ 'ome-zarr-py' ]]; then + conda activate test + git clone git://github.com/$repo ${{env.zarr_suite}} + cd ${{env.zarr_suite}} + git checkout ${{ github.event.client_payload.sha }} + pip install -e . + cd .. + conda deactivate + python configure_test.py ome_zarr + fi - name: Run pytest shell: bash -l {0} run: pytest -vxk "not omero" + - name: Notify job status + if: always() && github.event.action == 'run_test_suite' + uses: peter-evans/repository-dispatch@v1 + with: + token: ${{ secrets.API_TOKEN_GITHUB }} + event-type: test_suite_failure + repository: ${{ matrix.repo }} + client-payload: '{"status": "${{ job.status }}", "ref": "${{env.client_ref}}", "repo": "${{env.client_repo}}", "number": "${{env.client_number}}", "repo_test": "${{github.repository}}", "run_id": ${{github.run_id}}}' From 1ead12c28eb76c280d78b9ad4afcd04a7d2e1d34 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Wed, 1 Sep 2021 09:02:29 +0100 Subject: [PATCH 05/12] send comment --- .github/workflows/main.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 900f8aa..b81a55f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,9 +67,19 @@ jobs: run: pytest -vxk "not omero" - name: Notify job status if: always() && github.event.action == 'run_test_suite' - uses: peter-evans/repository-dispatch@v1 + uses: actions/github-script@v3 with: - token: ${{ secrets.API_TOKEN_GITHUB }} - event-type: test_suite_failure - repository: ${{ matrix.repo }} - client-payload: '{"status": "${{ job.status }}", "ref": "${{env.client_ref}}", "repo": "${{env.client_repo}}", "number": "${{env.client_number}}", "repo_test": "${{github.repository}}", "run_id": ${{github.run_id}}}' + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.issues.createComment({ + issue_number: 115, + owner: context.repo.owner, + repo: "glencoesoftware/bioformats2raw", + body: 'https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}: ${{ job.status }}' + }) + #uses: peter-evans/repository-dispatch@v1 + #with: + # token: ${{ secrets.API_TOKEN_GITHUB }} + # event-type: test_suite_failure + # repository: ${{ matrix.repo }} + # client-payload: '{"status": "${{ job.status }}", "ref": "${{env.client_ref}}", "repo": "${{env.client_repo}}", "number": "${{env.client_number}}", "repo_test": "${{github.repository}}", "run_id": ${{github.run_id}}}' From 49677a2bf8f9f937c2b07225d809fd1f6bfd6795 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Mon, 27 Sep 2021 11:09:53 +0100 Subject: [PATCH 06/12] Do not post event back to repo --- .github/workflows/main.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b81a55f..7c0fe5c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,11 +33,17 @@ jobs: shell: bash run: | # Set the parameters to be used in the response + repo=${{ github.event.client_payload.repo }} + owner=${{ github.event.client_payload.owner }} + repo_name=${repo#"$owner"} + repo_name=${repo_name#"/"} echo "client_repo="${{ github.event.client_payload.repo }} >> $GITHUB_ENV + echo "client_repo_name="$repo_name >> $GITHUB_ENV + echo "client_owner="${{ github.event.client_payload.owner }} >> $GITHUB_ENV echo "client_ref="${{ github.event.client_payload.ref }} >> $GITHUB_ENV echo "client_sha="${{ github.event.client_payload.sha }} >> $GITHUB_ENV echo "client_number="${{ github.event.client_payload.number }} >> $GITHUB_ENV - repo=${{ github.event.client_payload.repo }} + # Checkout the sha from the specified repository. # Only run the tests matching the specified repository. if [[ $repo =~ 'omero-ms-zarr' ]]; then @@ -69,17 +75,11 @@ jobs: if: always() && github.event.action == 'run_test_suite' uses: actions/github-script@v3 with: - github-token: ${{secrets.GITHUB_TOKEN}} + github-token: ${{secrets.API_TOKEN_GITHUB}} script: | github.issues.createComment({ - issue_number: 115, - owner: context.repo.owner, - repo: "glencoesoftware/bioformats2raw", + issue_number: "${{env.client_number}}", + owner: "${{env.client_owner}}", + repo: "${{env.client_repo_name}}", body: 'https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}: ${{ job.status }}' }) - #uses: peter-evans/repository-dispatch@v1 - #with: - # token: ${{ secrets.API_TOKEN_GITHUB }} - # event-type: test_suite_failure - # repository: ${{ matrix.repo }} - # client-payload: '{"status": "${{ job.status }}", "ref": "${{env.client_ref}}", "repo": "${{env.client_repo}}", "number": "${{env.client_number}}", "repo_test": "${{github.repository}}", "run_id": ${{github.run_id}}}' From 7da0784b5a02eb452dca4b267307d25411350265 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Mon, 27 Sep 2021 11:14:05 +0100 Subject: [PATCH 07/12] Remove ref to perso repo --- .github/workflows/main.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7c0fe5c..d7edfbf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,9 +11,6 @@ on: jobs: build: - strategy: - matrix: - repo: ['jburel/omero-ms-zarr'] runs-on: ubuntu-latest env: ms_suite: omero-ms-zarr-suite From ba24f613e43fea3cad7df1fdb51f317d94c71bed Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Mon, 27 Sep 2021 12:16:13 +0100 Subject: [PATCH 08/12] fix formatting --- .github/workflows/main.yml | 16 ++++++++++------ configure_test.py | 30 +++++++++++++++++------------- sources.yml | 2 +- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d7edfbf..eba5851 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,15 +32,18 @@ jobs: # Set the parameters to be used in the response repo=${{ github.event.client_payload.repo }} owner=${{ github.event.client_payload.owner }} + ref=${{ github.event.client_payload.ref }} + sha=${{ github.event.client_payload.sha }} + number=${{ github.event.client_payload.number }} repo_name=${repo#"$owner"} repo_name=${repo_name#"/"} - echo "client_repo="${{ github.event.client_payload.repo }} >> $GITHUB_ENV + echo "client_repo="$repo >> $GITHUB_ENV echo "client_repo_name="$repo_name >> $GITHUB_ENV - echo "client_owner="${{ github.event.client_payload.owner }} >> $GITHUB_ENV - echo "client_ref="${{ github.event.client_payload.ref }} >> $GITHUB_ENV - echo "client_sha="${{ github.event.client_payload.sha }} >> $GITHUB_ENV - echo "client_number="${{ github.event.client_payload.number }} >> $GITHUB_ENV - + echo "client_owner="$owner >> $GITHUB_ENV + echo "client_ref="$ref >> $GITHUB_ENV + echo "client_sha="$sha >> $GITHUB_ENV + echo "client_number="$number >> $GITHUB_ENV + # Checkout the sha from the specified repository. # Only run the tests matching the specified repository. if [[ $repo =~ 'omero-ms-zarr' ]]; then @@ -68,6 +71,7 @@ jobs: - name: Run pytest shell: bash -l {0} run: pytest -vxk "not omero" + # yamllint disable rule:line-length - name: Notify job status if: always() && github.event.action == 'run_test_suite' uses: actions/github-script@v3 diff --git a/configure_test.py b/configure_test.py index 4f97151..77586a7 100644 --- a/configure_test.py +++ b/configure_test.py @@ -1,26 +1,30 @@ -import yaml import sys +import yaml + # Change the value of the skip flag depending on the repository used -# repository: -#value = "bioformats2raw", "ome_zarr", "omero_ms_zarr" +# repository: +# value = "bioformats2raw", "ome_zarr", "omero_ms_zarr" ref_value = "ome_zarr" -def main(argv): + + +def main() -> None: + argv = sys.argv[1:] value = argv[0] - with open('sources.yml', 'r') as f: + with open("sources.yml") as f: doc = yaml.safe_load(f) for k in doc: - k['skip'] = True - if 'script' in k: - if k['script'].startswith(value): - k['skip'] = False + k["skip"] = True + if "script" in k: + if k["script"].startswith(value): + k["skip"] = False else: if value == ref_value: - k['skip'] = False - + k["skip"] = False - with open('sources.yml', 'w') as f: + with open("sources.yml", "w") as f: yaml.dump(doc, f, default_flow_style=False, sort_keys=False) + if __name__ == "__main__": - main(sys.argv[1:]) + main() diff --git a/sources.yml b/sources.yml index bc0897d..4bca9eb 100644 --- a/sources.yml +++ b/sources.yml @@ -39,7 +39,7 @@ - name: idr6001240 path: https://s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001240.zarr skip: False - + - name: bf2rawraw script: bioformats2raw_fake args: From 7b69dc43e9170edd2e318ad92d51c7bcb12fb487 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Tue, 5 Oct 2021 13:52:55 +0100 Subject: [PATCH 09/12] add creation of issue on failure --- .github/workflows/main.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eba5851..9fb6d4e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -72,7 +72,7 @@ jobs: shell: bash -l {0} run: pytest -vxk "not omero" # yamllint disable rule:line-length - - name: Notify job status + - name: Notify job status on PR if: always() && github.event.action == 'run_test_suite' uses: actions/github-script@v3 with: @@ -84,3 +84,13 @@ jobs: repo: "${{env.client_repo_name}}", body: 'https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}: ${{ job.status }}' }) + - name: Create issue + if: failure() && github.event.action == 'run_test_suite' + run: | + curl -X "POST" "https://api.github.com/repos/ome/${{env.client_repo_name}}/issues?state=all" \ + -H "Cookie: logged_in=no" \ + -H "Authorization: token ${{secrets.API_TOKEN_GITHUB}}" \ + -H "Content-Type: text/plain; charset=utf-8" \ + -d $'{ + "title": "Test suite failure for PR #${{env.client_number}}", + "body": "Test suite status: ${{ job.status }} see https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"}' From cb14a8f00dd8b7cc752a132837e63bd3c155e93b Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Tue, 5 Oct 2021 16:39:07 +0100 Subject: [PATCH 10/12] add bug label --- .github/workflows/main.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9fb6d4e..ab24f0f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -93,4 +93,8 @@ jobs: -H "Content-Type: text/plain; charset=utf-8" \ -d $'{ "title": "Test suite failure for PR #${{env.client_number}}", - "body": "Test suite status: ${{ job.status }} see https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"}' + "body": "Test suite status: ${{ job.status }} see https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}", + "labels": [ + "bug" + ] + }' From 72f1299e4812d9e5aa27513348d8b46437f544f0 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Wed, 6 Oct 2021 12:23:20 +0100 Subject: [PATCH 11/12] review explanation --- configure_test.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/configure_test.py b/configure_test.py index 77586a7..9e5c56b 100644 --- a/configure_test.py +++ b/configure_test.py @@ -3,9 +3,10 @@ import yaml # Change the value of the skip flag depending on the repository used -# repository: -# value = "bioformats2raw", "ome_zarr", "omero_ms_zarr" -ref_value = "ome_zarr" +# repository. Supported value: +# "bioformats2raw": do not skip the tests using bioformats2raw script +# "ome_zarr": do not skip the tests using ome-zarr-py +# "omero_ms_zarr": : do not skip the tests using omero-ms-zarr def main() -> None: @@ -19,7 +20,7 @@ def main() -> None: if k["script"].startswith(value): k["skip"] = False else: - if value == ref_value: + if value == "ome_zarr": k["skip"] = False with open("sources.yml", "w") as f: From a30af52cfa26146b80aec8aedbf03dec1e56a8b3 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Wed, 6 Oct 2021 12:24:32 +0100 Subject: [PATCH 12/12] use variable --- scripts/bioformats2raw_fake | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/bioformats2raw_fake b/scripts/bioformats2raw_fake index 7832957..3cff118 100755 --- a/scripts/bioformats2raw_fake +++ b/scripts/bioformats2raw_fake @@ -1,10 +1,9 @@ #!/usr/bin/env bash set -e set -u -image_name=ome_zarr_suite_bf2raw -SUITE=ome-zarr-bf2raw-suite -test -e $SUITE || git clone git://github.com/glencoesoftware/bioformats2raw $SUITE 1>&2 -cd $SUITE +image_name=ome-zarr-suite-bf2raw +test -e $image_name || git clone git://github.com/glencoesoftware/bioformats2raw $image_name 1>&2 +cd $image_name docker build -t ${image_name} . 1>&2 cd .. echo $PWD 1>&2