|
name: "Run sct_run_batch -s process_data.sh" |
|
# The tl;dr purpose of this workflow is to: |
|
# - A) Run the batch processing script part of the the SCT Course |
|
# - B) If run manually, then take some of the output files and package them into tutorial-specific datasets. |
|
# |
|
# In-depth explanation: |
|
# Most of SCT's tutorials depend on files generated by previous steps. (For example, 'sct_register_to_template' |
|
# depends on the segmented spinal cord image file generated by `sct_deepseg`. This creates a dilemma: If we want |
|
# SCT's tutorials to stand alone, we need to provide these intermediate files. But, if we want to run the tutorials |
|
# start to finish in a sequence (e.g. during the SCT Course), it would be confusing if the intermediate files |
|
# were already there. |
|
# |
|
# The solution is to only store the minimally-necessary files in the repository, then generate the intermediate files |
|
# using this workflow. That way, we can provide 2 different downloads: |
|
# - 'sct_course_data.zip': Files required to run the SCT course from start to finish. |
|
# - 'registration.zip', 'segmentation.zip', etc.: Files required by individual tutorials. |
|
|
|
on: |
|
pull_request: |
|
|
|
jobs: |
|
run-course-script: |
|
runs-on: ubuntu-latest |
|
steps: |
|
|
|
- name: Checkout spinalcordtoolbox |
|
uses: actions/checkout@v4 |
|
with: |
|
repository: spinalcordtoolbox/spinalcordtoolbox |
|
path: spinalcordtoolbox |
|
|
|
# install_sct edits ~/.bashrc, but those environment changes don't get passed to subsequent steps in GH Actions. |
|
# So, we filter through the .bashrc and pass the values to $GITHUB_ENV and $GITHUB_PATH. |
|
# Relevant documentation: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#environment-files |
|
# This workaround should be replaced by https://github.com/spinalcordtoolbox/spinalcordtoolbox/pull/3198#discussion_r568225392 |
|
- name: Install spinalcordtoolbox |
|
run: | |
|
cd spinalcordtoolbox |
|
./install_sct -iy |
|
cat ~/.bashrc | grep "export SCT_DIR" | cut -d " " -f 2 >> $GITHUB_ENV |
|
cat ~/.bashrc | grep "export PATH" | grep -o "/.*" | cut -d ':' -f 1 >> $GITHUB_PATH |
|
|
|
- name: Pre-download necessary models |
|
run: | |
|
sct_deepseg spinalcord -install |
|
|
|
- name: "Checkout '${{ github.event.repository.name }}'" |
|
uses: actions/checkout@v4 |
|
with: |
|
path: ${{ github.event.repository.name }} |
|
|
|
- name: Run sct_run_batch -s process_data.sh |
|
run: | |
|
cd "${{ github.event.repository.name }}/multi_subject" |
|
sct_run_batch -script process_data.sh -config config.yml |
|
|
|
- name: "Upload CSV files for easier tutorial updating" |
|
uses: actions/upload-artifact@v4 |
|
with: |
|
name: Multi Subject CSV Files |
|
path: ${{ github.event.repository.name }}/multi_subject/output/**/*.csv |
|
|
|
- name: Output full log for sanity checking |
|
if: always() |
|
run: | |
|
cd "${{ github.event.repository.name }}/multi_subject/output/log" |
|
for subxx in sub-01 sub-03 sub-05; do |
|
for logfile in process_data_${subxx}.log err.process_data_${subxx}.log; do |
|
if [[ -e "${logfile}" ]]; then |
|
echo "=== Contents of ${logfile} ===" |
|
cat "${logfile}" |
|
else |
|
echo "=== No file ${logfile} ===" |
|
fi |
|
done |
|
done |
|
|
|
|
|
- name: Check results (no error logs) |
|
if: always() |
|
run: | |
|
cd "${{ github.event.repository.name }}/multi_subject/output/log" |
|
[ "$(compgen -G "process_data_sub-0*.log")" ] # Log files should exist |
|
|
|
- name: Check results (no error logs) |
|
if: always() |
|
run: | |
|
cd "${{ github.event.repository.name }}/multi_subject/output/log" |
|
[ ! "$(compgen -G "err.process_data_sub-0*.log")" ] # Error files should NOT exist |
|
|
|
- name: Check results (warnings in log) |
|
if: always() |
|
run: | |
|
cd "${{ github.event.repository.name }}/multi_subject/output/log" |
|
# ! grep -iF "warning" process_data_sub-01.log |
|
|
|
- name: Check results (errors in log) |
|
if: always() |
|
run: | |
|
cd "${{ github.event.repository.name }}/multi_subject/output/log" |
|
! grep -iF "error" process_data_sub-01.log |