Skip to content

Commit bcd7e2c

Browse files
authored
Merge pull request #18 from jburel/repo_dispatch
Repo dispatch
2 parents b7d177f + a30af52 commit bcd7e2c

File tree

4 files changed

+119
-5
lines changed

4 files changed

+119
-5
lines changed

.github/workflows/main.yml

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
name: Build
33

44
on:
5+
repository_dispatch:
6+
types: [run_test_suite]
57
push:
68
pull_request:
79
schedule:
@@ -10,18 +12,89 @@ on:
1012
jobs:
1113
build:
1214
runs-on: ubuntu-latest
15+
env:
16+
ms_suite: omero-ms-zarr-suite
17+
bf_suite: ome-zarr-bf2raw-suite
18+
zarr_suite: ome-zarr-py-suite
1319
steps:
14-
1520
- uses: actions/checkout@v2
16-
1721
- name: Setup miniconda
1822
uses: conda-incubator/setup-miniconda@v2
1923
with:
2024
auto-update-conda: true
2125
channels: conda-forge,ome
2226
environment-file: environment.yml
2327
python-version: 3.9
28+
- name: Set testing environment
29+
if: github.event.action == 'run_test_suite'
30+
shell: bash
31+
run: |
32+
# Set the parameters to be used in the response
33+
repo=${{ github.event.client_payload.repo }}
34+
owner=${{ github.event.client_payload.owner }}
35+
ref=${{ github.event.client_payload.ref }}
36+
sha=${{ github.event.client_payload.sha }}
37+
number=${{ github.event.client_payload.number }}
38+
repo_name=${repo#"$owner"}
39+
repo_name=${repo_name#"/"}
40+
echo "client_repo="$repo >> $GITHUB_ENV
41+
echo "client_repo_name="$repo_name >> $GITHUB_ENV
42+
echo "client_owner="$owner >> $GITHUB_ENV
43+
echo "client_ref="$ref >> $GITHUB_ENV
44+
echo "client_sha="$sha >> $GITHUB_ENV
45+
echo "client_number="$number >> $GITHUB_ENV
2446
47+
# Checkout the sha from the specified repository.
48+
# Only run the tests matching the specified repository.
49+
if [[ $repo =~ 'omero-ms-zarr' ]]; then
50+
git clone git://github.com/$repo ${{env.ms_suite}}
51+
cd ${{env.ms_suite}}
52+
git checkout ${{ github.event.client_payload.sha }}
53+
cd ..
54+
python configure_test.py omero_ms_zarr
55+
elif [[ $repo =~ 'bioformats2raw' ]]; then
56+
git clone git://github.com/$repo ${{env.bf_suite}}
57+
cd ${{env.bf_suite}}
58+
git checkout ${{ github.event.client_payload.sha }}
59+
cd ..
60+
python configure_test.py bioformats2raw
61+
elif [[ $repo =~ 'ome-zarr-py' ]]; then
62+
conda activate test
63+
git clone git://github.com/$repo ${{env.zarr_suite}}
64+
cd ${{env.zarr_suite}}
65+
git checkout ${{ github.event.client_payload.sha }}
66+
pip install -e .
67+
cd ..
68+
conda deactivate
69+
python configure_test.py ome_zarr
70+
fi
2571
- name: Run pytest
2672
shell: bash -l {0}
2773
run: pytest -vxk "not omero"
74+
# yamllint disable rule:line-length
75+
- name: Notify job status on PR
76+
if: always() && github.event.action == 'run_test_suite'
77+
uses: actions/github-script@v3
78+
with:
79+
github-token: ${{secrets.API_TOKEN_GITHUB}}
80+
script: |
81+
github.issues.createComment({
82+
issue_number: "${{env.client_number}}",
83+
owner: "${{env.client_owner}}",
84+
repo: "${{env.client_repo_name}}",
85+
body: 'https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}: ${{ job.status }}'
86+
})
87+
- name: Create issue
88+
if: failure() && github.event.action == 'run_test_suite'
89+
run: |
90+
curl -X "POST" "https://api.github.com/repos/ome/${{env.client_repo_name}}/issues?state=all" \
91+
-H "Cookie: logged_in=no" \
92+
-H "Authorization: token ${{secrets.API_TOKEN_GITHUB}}" \
93+
-H "Content-Type: text/plain; charset=utf-8" \
94+
-d $'{
95+
"title": "Test suite failure for PR #${{env.client_number}}",
96+
"body": "Test suite status: ${{ job.status }} see https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}",
97+
"labels": [
98+
"bug"
99+
]
100+
}'

configure_test.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import sys
2+
3+
import yaml
4+
5+
# Change the value of the skip flag depending on the repository used
6+
# repository. Supported value:
7+
# "bioformats2raw": do not skip the tests using bioformats2raw script
8+
# "ome_zarr": do not skip the tests using ome-zarr-py
9+
# "omero_ms_zarr": : do not skip the tests using omero-ms-zarr
10+
11+
12+
def main() -> None:
13+
argv = sys.argv[1:]
14+
value = argv[0]
15+
with open("sources.yml") as f:
16+
doc = yaml.safe_load(f)
17+
for k in doc:
18+
k["skip"] = True
19+
if "script" in k:
20+
if k["script"].startswith(value):
21+
k["skip"] = False
22+
else:
23+
if value == "ome_zarr":
24+
k["skip"] = False
25+
26+
with open("sources.yml", "w") as f:
27+
yaml.dump(doc, f, default_flow_style=False, sort_keys=False)
28+
29+
30+
if __name__ == "__main__":
31+
main()

scripts/bioformats2raw_fake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env bash
22
set -e
33
set -u
4-
image_name=ome_zarr_suite_bf2raw
5-
git clone git://github.com/glencoesoftware/bioformats2raw 1>&2
6-
cd bioformats2raw
4+
image_name=ome-zarr-suite-bf2raw
5+
test -e $image_name || git clone git://github.com/glencoesoftware/bioformats2raw $image_name 1>&2
6+
cd $image_name
77
docker build -t ${image_name} . 1>&2
88
cd ..
99
echo $PWD 1>&2

sources.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,47 @@
1414

1515
- name: create
1616
script: ome_zarr_create
17+
skip: False
1718

1819
- name: localfake1
1920
path: data/64x64-fake-v0.1/0
21+
skip: False
2022

2123
- name: localfake2
2224
path: data/64x64-fake-v0.2/0
25+
skip: False
2326

2427
- name: localfake3
2528
path: data/64x64-fake-v0.3/0
29+
skip: False
2630

2731
- name: remotefake1
2832
path: https://s3.embassy.ebi.ac.uk/idr/zarr/test-data/64x64-fake-v0.1/0
33+
skip: False
2934

3035
- name: remotefake2
3136
path: https://s3.embassy.ebi.ac.uk/idr/zarr/test-data/64x64-fake-v0.2/0
37+
skip: False
3238

3339
- name: idr6001240
3440
path: https://s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001240.zarr
41+
skip: False
3542

3643
- name: bf2rawraw
3744
script: bioformats2raw_fake
3845
args:
3946
- "--compression=raw"
4047
- "--nested=true"
48+
skip: False
4149

4250
- name: bf2rawcompressed
4351
script: bioformats2raw_fake
4452
args:
4553
- "--compression=blosc"
4654
- "--nested=true"
55+
skip: False
4756

4857
- name: omeromszarr
4958
script: omero_ms_zarr_fake
5059
connection: http://localhost:8080/image/1.zarr/
60+
skip: False

0 commit comments

Comments
 (0)