From 3cbd320f447ec1b93ab36190df5064932e2a4a22 Mon Sep 17 00:00:00 2001 From: Aljen Uitbeijerse Date: Thu, 25 Nov 2021 09:31:29 +0100 Subject: [PATCH] Adapt workflow install step to use a single platform independent wrapper Single-step install and configure, make parameter file name an env var --- .github/workflows/aa_unittest.yml | 14 ++-- .github/workflows/aa_use_case_test.yml | 98 ++++++++------------------ .github/workflows/tools_install.sh | 10 ++- .github/workflows/trigger_install.py | 34 +++++++++ 4 files changed, 77 insertions(+), 79 deletions(-) create mode 100644 .github/workflows/trigger_install.py diff --git a/.github/workflows/aa_unittest.yml b/.github/workflows/aa_unittest.yml index f820609da..a40c49efa 100644 --- a/.github/workflows/aa_unittest.yml +++ b/.github/workflows/aa_unittest.yml @@ -59,20 +59,14 @@ jobs: # MATLAB release to set up R2020a release: R2020a - - name: Install tools under $HOME/tools (SPM, FaceMasking) + - name: Install tools and configure aa run: | - source $GITHUB_WORKSPACE/.github/workflows/tools_install.sh + python trigger_install.py + working-directory: ${{github.workspace}}/.github/workflows env: LOAD_FSL: 0 LOAD_FREESURFER: 0 - - - name: Configure aa - run: | - echo "Free space:" - df -h - mkdir $HOME/.aa - cp $GITHUB_WORKSPACE/.github/workflows/aap_parameters_defaults_GitHub.xml $HOME/.aa/aap_parameters_user.xml - mkdir $HOME/projects + PARAMETER_XML: aap_parameters_defaults_GitHub.xml - name: Run script uses: matlab-actions/run-command@v1 diff --git a/.github/workflows/aa_use_case_test.yml b/.github/workflows/aa_use_case_test.yml index 4ee28b359..f4b79371d 100644 --- a/.github/workflows/aa_use_case_test.yml +++ b/.github/workflows/aa_use_case_test.yml @@ -41,7 +41,7 @@ jobs: run: | git config --global core.autocrlf false git config --global core.eol lf - + - name: Check out repository under $GITHUB_WORKSPACE uses: actions/checkout@v2 @@ -59,12 +59,14 @@ jobs: # MATLAB release to set up R2020a release: R2020a - - name: Install tools under $HOME/tools (SPM, FaceMasking, FSL) + - name: Install tools and configure aa run: | - source $GITHUB_WORKSPACE/.github/workflows/tools_install.sh + python trigger_install.py + working-directory: ${{github.workspace}}/.github/workflows env: LOAD_FSL: 1 LOAD_FREESURFER: 0 + PARAMETER_XML: aap_parameters_defaults_GitHub.xml - name: Retrive test data under $HOME/data/aa_demo run: | @@ -77,14 +79,6 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_EC2_METADATA_DISABLED: true - - name: Configure aa - run: | - echo "Free space:" - df -h - mkdir $HOME/.aa - cp $GITHUB_WORKSPACE/.github/workflows/aap_parameters_defaults_GitHub.xml $HOME/.aa/aap_parameters_user.xml - mkdir $HOME/projects - - name: Run script uses: matlab-actions/run-command@v1 with: @@ -96,7 +90,7 @@ jobs: name: aatest_ds000114_AROMA path: | ~/projects/ - + aatest_ds000114_dartel: name: Testing SPM DARTEL @@ -118,7 +112,7 @@ jobs: run: | git config --global core.autocrlf false git config --global core.eol lf - + - name: Check out repository under $GITHUB_WORKSPACE uses: actions/checkout@v2 @@ -136,12 +130,14 @@ jobs: # MATLAB release to set up R2020a release: R2020a - - name: Install tools under $HOME/tools (SPM, FaceMasking, FSL standards) + - name: Install tools and configure aa run: | - source $GITHUB_WORKSPACE/.github/workflows/tools_install.sh + python trigger_install.py + working-directory: ${{github.workspace}}/.github/workflows env: LOAD_FSL: 0 LOAD_FREESURFER: 0 + PARAMETER_XML: aap_parameters_defaults_GitHub.xml - name: Retrive test data under $HOME/data/aa_demo run: | @@ -154,14 +150,6 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_EC2_METADATA_DISABLED: true - - name: Configure aa - run: | - echo "Free space:" - df -h - mkdir $HOME/.aa - cp $GITHUB_WORKSPACE/.github/workflows/aap_parameters_defaults_GitHub.xml $HOME/.aa/aap_parameters_user.xml - mkdir $HOME/projects - - name: Run script uses: matlab-actions/run-command@v1 with: @@ -195,7 +183,7 @@ jobs: run: | git config --global core.autocrlf false git config --global core.eol lf - + - name: Check out repository under $GITHUB_WORKSPACE uses: actions/checkout@v2 @@ -213,12 +201,14 @@ jobs: # MATLAB release to set up R2020a release: R2020a - - name: Install tools under $HOME/tools (SPM, FSL, FaceMasking) + - name: Install tools and configure aa run: | - source $GITHUB_WORKSPACE/.github/workflows/tools_install.sh + python trigger_install.py + working-directory: ${{github.workspace}}/.github/workflows env: LOAD_FSL: 1 LOAD_FREESURFER: 0 + PARAMETER_XML: aap_parameters_defaults_GitHub.xml - name: Retrive test data under $HOME/data/aa_demo run: | @@ -231,14 +221,6 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_EC2_METADATA_DISABLED: true - - name: Configure aa - run: | - echo "Free space:" - df -h - mkdir $HOME/.aa - cp $GITHUB_WORKSPACE/.github/workflows/aap_parameters_defaults_GitHub.xml $HOME/.aa/aap_parameters_user.xml - mkdir $HOME/projects - - name: Run script uses: matlab-actions/run-command@v1 with: @@ -272,7 +254,7 @@ jobs: run: | git config --global core.autocrlf false git config --global core.eol lf - + - name: Check out repository under $GITHUB_WORKSPACE uses: actions/checkout@v2 @@ -290,12 +272,14 @@ jobs: # MATLAB release to set up R2020a release: R2020a - - name: Install tools under $HOME/tools (SPM, FaceMasking, FSL standards) + - name: Install tools and configure aa run: | - source $GITHUB_WORKSPACE/.github/workflows/tools_install.sh + python trigger_install.py + working-directory: ${{github.workspace}}/.github/workflows env: LOAD_FSL: 0 LOAD_FREESURFER: 0 + PARAMETER_XML: aap_parameters_defaults_GitHub.xml - name: Retrive test data under $HOME/data/aa_demo run: | @@ -310,14 +294,6 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_EC2_METADATA_DISABLED: true - - name: Configure aa - run: | - echo "Free space:" - df -h - mkdir $HOME/.aa - cp $GITHUB_WORKSPACE/.github/workflows/aap_parameters_defaults_GitHub.xml $HOME/.aa/aap_parameters_user.xml - mkdir $HOME/projects - - name: Run script uses: matlab-actions/run-command@v1 with: @@ -351,7 +327,7 @@ jobs: run: | git config --global core.autocrlf false git config --global core.eol lf - + - name: Check out repository under $GITHUB_WORKSPACE uses: actions/checkout@v2 @@ -369,12 +345,14 @@ jobs: # MATLAB release to set up R2020a release: R2020a - - name: Install tools under $HOME/tools (SPM, FaceMasking, FSL standards) + - name: Install tools and configure aa run: | - source $GITHUB_WORKSPACE/.github/workflows/tools_install.sh + python trigger_install.py + working-directory: ${{github.workspace}}/.github/workflows env: LOAD_FSL: 0 LOAD_FREESURFER: 0 + PARAMETER_XML: aap_parameters_defaults_GitHub.xml - name: Retrive test data under $HOME/data/aa_demo run: | @@ -390,14 +368,6 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_EC2_METADATA_DISABLED: true - - name: Configure aa - run: | - echo "Free space:" - df -h - mkdir $HOME/.aa - cp $GITHUB_WORKSPACE/.github/workflows/aap_parameters_defaults_GitHub.xml $HOME/.aa/aap_parameters_user.xml - mkdir $HOME/projects - - name: Run script uses: matlab-actions/run-command@v1 with: @@ -431,7 +401,7 @@ jobs: run: | git config --global core.autocrlf false git config --global core.eol lf - + - name: Check out repository under $GITHUB_WORKSPACE uses: actions/checkout@v2 @@ -449,12 +419,14 @@ jobs: # MATLAB release to set up R2020a release: R2020a - - name: Install tools under $HOME/tools (SPM, FSL, FreeSurfer, FaceMasking) + - name: Install tools and configure aa run: | - source $GITHUB_WORKSPACE/.github/workflows/tools_install.sh + python trigger_install.py + working-directory: ${{github.workspace}}/.github/workflows env: LOAD_FSL: 1 LOAD_FREESURFER: 1 + PARAMETER_XML: aap_parameters_defaults_GitHub.xml - name: Retrive test data under $HOME/data/aa_demo run: | @@ -465,14 +437,6 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_EC2_METADATA_DISABLED: true - - name: Configure aa - run: | - echo "Free space:" - df -h - mkdir $HOME/.aa - cp $GITHUB_WORKSPACE/.github/workflows/aap_parameters_defaults_GitHub.xml $HOME/.aa/aap_parameters_user.xml - mkdir $HOME/projects - - name: Run script uses: matlab-actions/run-command@v1 with: diff --git a/.github/workflows/tools_install.sh b/.github/workflows/tools_install.sh index 7da235b3f..71d51ec5e 100644 --- a/.github/workflows/tools_install.sh +++ b/.github/workflows/tools_install.sh @@ -10,7 +10,7 @@ python $TOOLDIR/get-pip.py --force-reinstall # All MATLAB tools MUST be installed referred by the parameterset source $GITHUB_WORKSPACE/.github/workflows/tools_urls.sh -source $GITHUB_WORKSPACE/aa_tools/toolboxes/installation_scripts/install_tools.sh $GITHUB_WORKSPACE/.github/workflows/aap_parameters_defaults_GitHub.xml $TOOLDIR +source $GITHUB_WORKSPACE/aa_tools/toolboxes/installation_scripts/install_tools.sh $GITHUB_WORKSPACE/.github/workflows/$PARAMETER_XML $TOOLDIR echo "FSL: ${LOAD_FSL}; FREESURFER: ${LOAD_FREESURFER}" @@ -22,4 +22,10 @@ fi if [[ "x${LOAD_FREESURFER}x" == "x1x" ]]; then source $GITHUB_WORKSPACE/aa_tools/toolboxes/installation_scripts/install_freesurfer.sh $TOOLDIR 7.2.0 centos7 "tibor.auer@gmail.com\n7061\n *Ccpi6x7PAIeQ\n FS96pPK5vW.0g" $TEMPLATEDIR -fi \ No newline at end of file +fi + +echo "Free space:" +df -h +mkdir $HOME/.aa +cp $GITHUB_WORKSPACE/.github/workflows/$PARAMETER_XML $HOME/.aa/aap_parameters_user.xml +mkdir $HOME/projects \ No newline at end of file diff --git a/.github/workflows/trigger_install.py b/.github/workflows/trigger_install.py new file mode 100644 index 000000000..110ce9987 --- /dev/null +++ b/.github/workflows/trigger_install.py @@ -0,0 +1,34 @@ +# Note: Assume Python 2.7, since that will have been installed for facemasking requirements. +# +# Using python (instead of matlab) because using system() in matlab gives enormous amount of +# command window output, and there is some problem with the status code from system() + +import sys +import subprocess +import platform + +def main(): + do_install() + +def do_install(): + plt = platform.system() + if plt == "Windows": + print("Your system is Windows") + sys.stdout.flush() + # do x y z + elif plt == "Linux": + print("Your system is Linux") + sys.stdout.flush() + subprocess.check_call('source $GITHUB_WORKSPACE/.github/workflows/tools_install.sh', shell=True, executable="/bin/bash") + + elif plt == "Darwin": + print("Your system is MacOS") + sys.stdout.flush() + # do x y z + else: + print("Unidentified system:") + print(plt) + sys.stdout.flush() + +if __name__=="__main__": + main() \ No newline at end of file