-
Notifications
You must be signed in to change notification settings - Fork 120
95 lines (87 loc) · 3.17 KB
/
quicktest_runner.yaml
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: quicktest-runner
# File: quicktest_runner.yaml
# Author: Taha Abdullah
# Created on: 2023-07-10
# Functionality: This workflow runs FastSurfer on MRI data and runs pytest to check if the results are acceptable. It
# also checks if the FastSurfer environment and output already exist, and if not, it creates them.
# Usage: This workflow is triggered on a pull request to the dev and main branch. It can also be triggered manually
# with workflow-dispatch.
# Expected/Used Environment Variables:
# - MAMBAPATH: Path to the micromamba binary.
# - MAMBAROOT: Root path for micromamba.
# - RUNNER_FS_OUTPUT: Path to the directory where FastSurfer output is stored.
# - RUNNER_FS_MRI_DATA: Path to the directory where MRI data is stored.
# - FREESURFER_HOME: Path to the freesurfer directory.
# - FS_LICENSE: Path to the FreeSurfer license file.
on:
pull_request:
branches:
- dev
- stable
workflow_dispatch:
jobs:
# Checkout repo
checkout:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
# Create conda environment, install packages, and run Fastsurfer
run-fastsurfer:
runs-on: self-hosted
needs: checkout
steps:
# Check if the Environment Variables used in further steps are present
- name: Check Environment Variables
run: |
REQUIRED_ENV_VARS=(
"MAMBAPATH"
"MAMBAROOT"
"RUNNER_FS_OUTPUT"
"RUNNER_FS_MRI_DATA"
"FREESURFER_HOME"
"FS_LICENSE"
)
for VAR_NAME in "${REQUIRED_ENV_VARS[@]}"; do
if [ -z "${!VAR_NAME}" ]; then
echo "Error: Required environment variable $VAR_NAME is not set"
exit 1
fi
done
if [ ! -f "$FS_LICENSE" ]; then
echo "Error: FreeSurfer license file does not exist at $FS_LICENSE"
exit 1
fi
if [ ! -d "$FREESURFER_HOME" ]; then
echo "Error: FreeSurfer installation directory does not exist at $FREESURFER_HOME"
exit 1
fi
# - name: create env
# run: |
# if [[ "$(md5sum /fastsurfer/fastsurfer-pytest.yml)" != "$(md5sum env/fastsurfer.yml)" ]] ; then
# mamba env create -n "fastsurfer_$GITHUB_SHA" -f env/fastsurfer.yml
# mamba activate "fastsurfer_$GITHUB_SHA"
# fi
- name: Run FastSurfer
run: |
echo "Running FastSurfer..."
export FASTSURFER_HOME=$(pwd)
export THIS_RUN_OUTDIR=${GITHUB_SHA:0:7}
mkdir -p $SUBJECTS_DIR/$THIS_RUN_OUTDIR
./brun_fastsurfer.sh --subject_list $RUNNER_FS_MRI_DATA/subjects_list.txt \
--sd $SUBJECTS_DIR/$THIS_RUN_OUTDIR \
--parallel --threads 4 --3T --parallel_subjects surf
export TEST_DIR=$THIS_RUN_OUTDIR
# - name: cleanup
# run: |
# if [[ "$(md5sum /fastsurfer/fastsurfer.yml)" != "$(md5sum env/fastsurfer.yml)" ]] ; then
# mamba env remove -n "fastsurfer_$GITHUB_SHA"
# fi
# Test fastsurfer output
run-pytest:
runs-on: self-hosted
needs: run-fastsurfer
steps:
- name: Run pytest
run: |
source /venv-pytest/bin/activate
python -m pytest test/quick_test