Skip to content

Move the logic that invokes setup-fortran.sh out of the action YAML and into a reusable script #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 2 additions & 36 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./main.sh

echo "FC=${FC}" >> $GITHUB_ENV
echo "CC=${CC}" >> $GITHUB_ENV
Expand Down
38 changes: 38 additions & 0 deletions main.sh
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opted not to put this logic in the bottom of setup-fortran.sh as I figured some people may be using it as something sourceable without side effects currently, and putting this code in there would break those semantics.

Original file line number Diff line number Diff line change
@@ -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
Loading