Migrating Quicktest to PyTest and adding dockerized self hosted runner #3
Workflow file for this run
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: quicktest-docker | |
on: | |
pull_request: | |
branches: | |
- dev | |
- main | |
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: | |
# Set up Python using setup-python@v3 action | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
# Check if FastSurfer environment already exists | |
- name: Check Environment | |
run: | | |
if [ ! -f "$MAMBAPATH" ]; then | |
echo "FastSurfer environment does not exist. Creating FastSurfer Environment..." | |
echo "PROCEED=true" >> $GITHUB_OUTPUT | |
else | |
echo "FastSurfer environment exists. Skipping FastSurfer Environment creation..." | |
echo "PROCEED=false" >> $GITHUB_OUTPUT | |
fi | |
id: check-environment | |
# Create FastSurfer environment if it does not exist | |
- name: Create FastSurfer Environment | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-file: env/fastsurfer.yml | |
micromamba-root-path: /home/micromamba | |
micromamba-binary-path: /home/micromamba-bin/micromamba | |
log-level: debug | |
cache-downloads: true | |
cache-environment: true | |
init-shell: none | |
if: steps.check-environment.outputs.PROCEED == 'true' | |
# Set up cache for python packages | |
- name: Cache Python packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
# Install required python packages | |
- name: Install package | |
run: | | |
python -m pip install --progress-bar off --upgrade pip \ | |
setuptools wheel | |
python -m pip install --progress-bar off .[test] | |
# Check if FastSurfer output already exists | |
- name: Check FastSurfer Output Directory | |
run: | | |
if [ -d "$RUNNER_FS_OUTPUT/subject1" ]; then | |
echo "FastSurfer output directory for subject1 exists. Finishing job..." | |
echo "PROCEED=false" >> $GITHUB_OUTPUT | |
exit 0 | |
else | |
echo "FastSurfer output directory for subject1 does not exist. Running FastSurfer..." | |
echo "PROCEED=true" >> $GITHUB_OUTPUT | |
fi | |
id: check-fastsurfer-output | |
# Run FastSurfer | |
- name: Run FastSurfer | |
run: | | |
echo "Running FastSurfer..." | |
export FREESURFER_HOME=/freesurfer | |
source $FREESURFER_HOME/SetUpFreeSurfer.sh | |
git config --global --add safe.directory \ | |
/home/actions-runner/_work/FastSurfer/FastSurfer | |
./brun_fastsurfer.sh --subject_list $RUNNER_FS_MRI_DATA/subjects_list.txt \ | |
--sd $RUNNER_FS_OUTPUT \ | |
--parallel --threads 4 --3T --parallel_subjects surf | |
if: steps.check-fastsurfer-output.outputs.PROCEED == 'true' | |
# Run pytest | |
run-pytest: | |
runs-on: self-hosted | |
needs: run-fastsurfer | |
steps: | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
- name: Cache Python packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Run pytest | |
run: python -m pytest test/quicktest |