diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2f94666..ab24f0f 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: @@ -10,10 +12,12 @@ on: jobs: build: 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 +25,76 @@ 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 + 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="$repo >> $GITHUB_ENV + echo "client_repo_name="$repo_name >> $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 + 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" + # yamllint disable rule:line-length + - name: Notify job status on PR + if: always() && github.event.action == 'run_test_suite' + uses: actions/github-script@v3 + with: + github-token: ${{secrets.API_TOKEN_GITHUB}} + script: | + github.issues.createComment({ + 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 }}' + }) + - 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}}", + "labels": [ + "bug" + ] + }' diff --git a/configure_test.py b/configure_test.py new file mode 100644 index 0000000..9e5c56b --- /dev/null +++ b/configure_test.py @@ -0,0 +1,31 @@ +import sys + +import yaml + +# Change the value of the skip flag depending on the repository used +# 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: + argv = sys.argv[1:] + value = argv[0] + 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 + else: + if value == "ome_zarr": + 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() diff --git a/scripts/bioformats2raw_fake b/scripts/bioformats2raw_fake index 5025f80..3cff118 100755 --- a/scripts/bioformats2raw_fake +++ b/scripts/bioformats2raw_fake @@ -1,9 +1,9 @@ #!/usr/bin/env bash set -e set -u -image_name=ome_zarr_suite_bf2raw -git clone git://github.com/glencoesoftware/bioformats2raw 1>&2 -cd bioformats2raw +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 diff --git a/sources.yml b/sources.yml index fb60926..4bca9eb 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