-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (67 loc) · 2.15 KB
/
1-pr-check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: PR checks on algorithm submission
on:
pull_request:
paths:
- 'algorithms/*.yaml'
- '.github/workflows/1-pr-check.yml'
push:
paths:
- 'algorithms/*.yaml'
- '.github/workflows/1-pr-check.yml'
jobs:
check_yaml:
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}-algo-checks:main
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
steps:
- uses: actions/checkout@v4
- name: find algorithm files
run: |
{
echo 'FILELIST<<EOF'
find ./algorithms -name '*.yaml' -print
echo EOF
} >> "$GITHUB_ENV"
- name: Convert and validate using jsonschema
run: |
for algo in ${FILELIST}; do
yq -o json $algo > algo.json \
&& jsonschema-cli -i algo.json "config/schema.json"
done
rm algo.json
check_image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: find algorithm files
run: |
{
echo 'FILELIST<<EOF'
find ./algorithms -name '*.yaml' -print
echo EOF
} >> "$GITHUB_ENV"
- name: Pull image
run: |
for algo in ${FILELIST}; do
IMAGE=$(grep '^image: ' $algo | sed 's/^image: \+//' | tr -d \'\")
if ! docker pull $IMAGE ; then
echo "Cannot pull image: $IMAGE"
exit 1
fi
done
- name: Check output
run: |
HEADER_REGEX='onset duration eventType confidence channels dateTime recordingDuration'
for algo in ${FILELIST}; do
IMAGE=$(grep '^image: ' $algo | sed 's/^image: \+//' | tr -d \'\")
OUT=$(tr -cd '[:alnum:]' < <(echo $IMAGE) )
echo "running: $IMAGE"
docker run -v ./tests/data:/data -v /tmp:/output -e INPUT=unipolar.edf -e OUTPUT="${OUT}.tsv" $IMAGE
if ! [[ $(head -n1 "/tmp/${OUT}.tsv") =~ "$HEADER_REGEX" ]]; then
echo "Output does not have the expected header"
exit 1
fi
done