ci(pr-check): add tsv output verification #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |