Skip to content

Commit a6ee716

Browse files
authored
Move the logic that invokes setup-fortran.sh out of the action YAML and into a reusable script (#123)
1 parent f33d0d4 commit a6ee716

File tree

2 files changed

+40
-36
lines changed

2 files changed

+40
-36
lines changed

action.yml

+2-36
Original file line numberDiff line numberDiff line change
@@ -69,42 +69,8 @@ runs:
6969
COMPILER: ${{ inputs.compiler }}
7070
VERSION: ${{ inputs.version }}
7171
run: |
72-
action_path=$(echo '/${{ github.action_path }}' | sed -e 's/\\/\//g' -e 's/://')
73-
source "$action_path/setup-fortran.sh"
74-
75-
compiler=${COMPILER:-gcc}
76-
platform=$(uname -s | tr '[:upper:]' '[:lower:]')
77-
78-
if [[ "$RUNNER_OS" == "macOS" ]] && [[ "$compiler" == "intel" ]]; then
79-
echo "Compiler 'intel' not supported on macOS, falling back to 'intel-classic'"
80-
compiler="intel-classic"
81-
fi
82-
83-
case $compiler in
84-
gcc)
85-
version=${VERSION:-13}
86-
install_gcc $platform
87-
;;
88-
intel-classic)
89-
version=${VERSION:-2023.2.0}
90-
install_intel $platform true
91-
;;
92-
intel)
93-
version=${VERSION:-2025.0}
94-
install_intel $platform false
95-
;;
96-
nvidia-hpc)
97-
version=${VERSION:-25.1}
98-
install_nvidiahpc $platform
99-
;;
100-
lfortran)
101-
version=${VERSION:-0.45.0}
102-
install_lfortran $platform
103-
;;
104-
*)
105-
exit 1
106-
;;
107-
esac
72+
cd $(echo '/${{ github.action_path }}' | sed -e 's/\\/\//g' -e 's/://')
73+
source ./main.sh
10874
10975
echo "FC=${FC}" >> $GITHUB_ENV
11076
echo "CC=${CC}" >> $GITHUB_ENV

main.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
compiler=${COMPILER:-gcc}
5+
platform=$(uname -s | tr '[:upper:]' '[:lower:]')
6+
7+
if [[ "$RUNNER_OS" == "macOS" ]] && [[ "$compiler" == "intel" ]]; then
8+
echo "Compiler 'intel' not supported on macOS, falling back to 'intel-classic'"
9+
compiler="intel-classic"
10+
fi
11+
12+
source ./setup-fortran.sh
13+
14+
case $compiler in
15+
gcc)
16+
version=${VERSION:-13}
17+
install_gcc $platform
18+
;;
19+
intel-classic)
20+
version=${VERSION:-2023.2.0}
21+
install_intel $platform true
22+
;;
23+
intel)
24+
version=${VERSION:-2025.0}
25+
install_intel $platform false
26+
;;
27+
nvidia-hpc)
28+
version=${VERSION:-25.1}
29+
install_nvidiahpc $platform
30+
;;
31+
lfortran)
32+
version=${VERSION:-0.45.0}
33+
install_lfortran $platform
34+
;;
35+
*)
36+
exit 1
37+
;;
38+
esac

0 commit comments

Comments
 (0)