From f272de70aa9a16ca51cbdd7f9d638f4f635e133c Mon Sep 17 00:00:00 2001 From: Tim Dawborn Date: Thu, 20 Mar 2025 23:20:35 +1000 Subject: [PATCH 1/2] Move the logic that invokes `setup-fortran.sh` out of the action YAML into its own script so that it can be reused. --- action.sh | 38 ++++++++++++++++++++++++++++++++++++++ action.yml | 38 ++------------------------------------ 2 files changed, 40 insertions(+), 36 deletions(-) create mode 100644 action.sh diff --git a/action.sh b/action.sh new file mode 100644 index 0000000..1fcf76f --- /dev/null +++ b/action.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +set -ex + +compiler=${COMPILER:-gcc} +platform=$(uname -s | tr '[:upper:]' '[:lower:]') + +if [[ "$RUNNER_OS" == "macOS" ]] && [[ "$compiler" == "intel" ]]; then + echo "Compiler 'intel' not supported on macOS, falling back to 'intel-classic'" + compiler="intel-classic" +fi + +source ./setup-fortran.sh + +case $compiler in + gcc) + version=${VERSION:-13} + install_gcc $platform + ;; + intel-classic) + version=${VERSION:-2023.2.0} + install_intel $platform true + ;; + intel) + version=${VERSION:-2025.0} + install_intel $platform false + ;; + nvidia-hpc) + version=${VERSION:-25.1} + install_nvidiahpc $platform + ;; + lfortran) + version=${VERSION:-0.45.0} + install_lfortran $platform + ;; + *) + exit 1 + ;; +esac diff --git a/action.yml b/action.yml index 0653675..8c2e3a7 100644 --- a/action.yml +++ b/action.yml @@ -69,42 +69,8 @@ runs: COMPILER: ${{ inputs.compiler }} VERSION: ${{ inputs.version }} run: | - action_path=$(echo '/${{ github.action_path }}' | sed -e 's/\\/\//g' -e 's/://') - source "$action_path/setup-fortran.sh" - - compiler=${COMPILER:-gcc} - platform=$(uname -s | tr '[:upper:]' '[:lower:]') - - if [[ "$RUNNER_OS" == "macOS" ]] && [[ "$compiler" == "intel" ]]; then - echo "Compiler 'intel' not supported on macOS, falling back to 'intel-classic'" - compiler="intel-classic" - fi - - case $compiler in - gcc) - version=${VERSION:-13} - install_gcc $platform - ;; - intel-classic) - version=${VERSION:-2023.2.0} - install_intel $platform true - ;; - intel) - version=${VERSION:-2025.0} - install_intel $platform false - ;; - nvidia-hpc) - version=${VERSION:-25.1} - install_nvidiahpc $platform - ;; - lfortran) - version=${VERSION:-0.45.0} - install_lfortran $platform - ;; - *) - exit 1 - ;; - esac + cd $(echo '/${{ github.action_path }}' | sed -e 's/\\/\//g' -e 's/://') + source ./action.sh echo "FC=${FC}" >> $GITHUB_ENV echo "CC=${CC}" >> $GITHUB_ENV From ea97680e57d416146202caa8717ae2e6a0210847 Mon Sep 17 00:00:00 2001 From: Tim Dawborn Date: Thu, 20 Mar 2025 23:30:27 +1000 Subject: [PATCH 2/2] Rename file. --- action.yml | 2 +- action.sh => main.sh | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename action.sh => main.sh (100%) diff --git a/action.yml b/action.yml index 8c2e3a7..d5ef748 100644 --- a/action.yml +++ b/action.yml @@ -70,7 +70,7 @@ runs: VERSION: ${{ inputs.version }} run: | cd $(echo '/${{ github.action_path }}' | sed -e 's/\\/\//g' -e 's/://') - source ./action.sh + source ./main.sh echo "FC=${FC}" >> $GITHUB_ENV echo "CC=${CC}" >> $GITHUB_ENV diff --git a/action.sh b/main.sh similarity index 100% rename from action.sh rename to main.sh