Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repo dispatch #18

Merged
merged 12 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 75 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
name: Build

on:
repository_dispatch:
types: [run_test_suite]
push:
pull_request:
schedule:
Expand All @@ -10,18 +12,89 @@ 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:
auto-update-conda: true
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
jburel marked this conversation as resolved.
Show resolved Hide resolved
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"
]
}'
30 changes: 30 additions & 0 deletions configure_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import sys

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"
jburel marked this conversation as resolved.
Show resolved Hide resolved


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 == 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()
5 changes: 3 additions & 2 deletions scripts/bioformats2raw_fake
Original file line number Diff line number Diff line change
Expand Up @@ -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
jburel marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
10 changes: 10 additions & 0 deletions sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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