Skip to content

Commit eda03ce

Browse files
authored
Merge pull request #98 from bonachea/ci-2026-09
[NO REVIEW]: CI Updates
2 parents c144397 + c2680f8 commit eda03ce

1 file changed

Lines changed: 45 additions & 14 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -220,26 +220,49 @@ jobs:
220220
FC: ${{ matrix.compiler }}
221221
FFLAGS: ${{ matrix.extra_flags }}
222222
FPM_FLAGS: --profile release --verbose
223+
CURL_OPTIONS: --retry 10 --retry-all-errors --fail -L
224+
BREW_WARNING_FILTER: 's/^[[:punct:]]*warning[[:punct:]]*(You are using macOS)/warn: \1/i'
223225
CHECK_ASSERT: --flag -DASSERTIONS 2>&1 | tee output ; test ${PIPESTATUS[0]} = $ERROR_STOP_CODE && grep -q "Assertion failure" output
224226

225227
steps:
226228
- name: Checkout code
227229
uses: actions/checkout@v6
228230

231+
- name: Install shell functions
232+
run: |
233+
mkdir -p ~/.bash_helpers
234+
cat << 'EOF' > ~/.bash_helpers/custom_functions.sh
235+
retry() {
236+
local retry_cnt=0
237+
local retry_delay
238+
while ! "$@" ; do
239+
retry_cnt=$(expr $retry_cnt + 1)
240+
if [[ $retry_cnt > 5 ]] ; then exit 1 ; fi
241+
( set +x ;
242+
echo "::warning::Command failed: <$@> Pausing before retry $retry_cnt..." );
243+
retry_delay=$(( 5 ** retry_cnt ))
244+
if [[ $retry_delay > 600 ]] ; then retry_delay=600 ; fi
245+
sleep $retry_delay
246+
done
247+
}
248+
EOF
249+
# Register file in BASH_ENV so it automatically loads in all future steps
250+
echo "BASH_ENV=~/.bash_helpers/custom_functions.sh" >> $GITHUB_ENV
251+
229252
- name: Install Ubuntu Native Dependencies
230253
if: ${{ contains(matrix.os, 'ubuntu') && matrix.container == '' && matrix.compiler == 'gfortran' }}
231254
run: |
232-
sudo apt-get update
255+
retry sudo apt-get update
233256
#sudo apt list -a 'gfortran-*'
234-
sudo apt install -y build-essential
257+
retry sudo apt install -y build-essential
235258
if [[ ${COMPILER_VERSION} -lt 15 ]] || type -p gfortran-${COMPILER_VERSION} ; then
236-
sudo apt install -y gfortran-${COMPILER_VERSION}
259+
retry sudo apt install -y gfortran-${COMPILER_VERSION}
237260
else
238-
curl -L https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh -o install-homebrew.sh
261+
curl $CURL_OPTIONS https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh -o install-homebrew.sh
239262
chmod +x install-homebrew.sh
240263
env CI=1 ./install-homebrew.sh
241264
HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew"
242-
${HOMEBREW_PREFIX}/bin/brew install -v gcc@${COMPILER_VERSION} binutils
265+
retry ${HOMEBREW_PREFIX}/bin/brew install -v gcc@${COMPILER_VERSION} binutils
243266
ls -al ${HOMEBREW_PREFIX}/bin
244267
echo "PATH=${HOMEBREW_PREFIX}/bin:${PATH}" >> "$GITHUB_ENV"
245268
: Homebrew GCC@15 needs binutils 2.44+
@@ -253,8 +276,8 @@ jobs:
253276
- name: Install Ubuntu Container Dependencies
254277
if: ${{ contains(matrix.os, 'ubuntu') && matrix.container != '' && !contains(matrix.container, 'phhargrove') }}
255278
run: |
256-
apt update
257-
apt install -y build-essential # pkg-config make git curl
279+
retry apt update
280+
retry apt install -y build-essential # pkg-config make git curl
258281
# Add container lfortran to PATH:
259282
if test "$FC" = "lfortran"; then
260283
echo "/app/bin" >> "$GITHUB_PATH"
@@ -266,7 +289,7 @@ jobs:
266289
if: ${{ contains(matrix.os, 'macos') }}
267290
run: |
268291
# silence Homebrew tap trust warnings:
269-
(set +e ; brew untap -f aws/tap hashicorp/tap 2>&1 | perl -pe 's/#*.warning./warn: /' ; brew trust azure/bicep )
292+
(set +e ; brew untap -f aws/tap hashicorp/tap 2>&1 | perl -pe 's/^::*//;s/^##*//' ; brew trust azure/bicep ; echo )
270293
# set some Homebrew knobs to accelerate installation
271294
# but only when we are not simulating the user environment brew-via-install workflow
272295
if [[ -z "${{ matrix.brew_via_install }}" ]] ; then
@@ -279,17 +302,20 @@ jobs:
279302
- name: Install macOS Dependencies
280303
if: contains(matrix.os, 'macos')
281304
run: |
282-
brew update
305+
retry brew update
283306
# fpm binary distribution for macOS requires gfortran shared libraries from gcc@12
284-
brew install gcc@12
307+
retry brew install gcc@12 \
308+
2>&1 | perl -pe "$BREW_WARNING_FILTER" ; test ${PIPESTATUS[0]} = 0
285309
if [[ ${{ matrix.compiler }} == 'gfortran' && ${COMPILER_VERSION} -gt 15 ]] ; then
286-
brew install gcc@${COMPILER_VERSION}
310+
retry brew install gcc@${COMPILER_VERSION} \
311+
2>&1 | perl -pe "$BREW_WARNING_FILTER" ; test ${PIPESTATUS[0]} = 0
287312
fi
288313
289314
- name: Install LLVM flang on macOS
290315
if: contains(matrix.os, 'macos') && matrix.compiler == 'flang'
291316
run: |
292-
brew install llvm@${COMPILER_VERSION} flang
317+
retry brew install llvm@${COMPILER_VERSION} flang \
318+
2>&1 | perl -pe "$BREW_WARNING_FILTER" ; test ${PIPESTATUS[0]} = 0
293319
# workaround issue #228: clang cannot find homebrew flang's C header
294320
for p in /opt/homebrew /usr/local $(brew --prefix) ; do find $p/Cellar/flang -name ISO_Fortran_binding.h 2>/dev/null || true ; done
295321
echo "CFLAGS=-I$(dirname $(find $(brew --prefix)/Cellar/flang -name ISO_Fortran_binding.h | head -1)) ${CFLAGS}" >> "$GITHUB_ENV"
@@ -328,10 +354,15 @@ jobs:
328354
if: ${{ runner.os == 'Linux' && runner.arch == 'ARM64' }}
329355
run: |
330356
export FPM_VERSION=0.13.0
357+
for suff in -14 -15 -16 "" -13 -12 ; do
358+
GFORTRAN=gfortran$suff
359+
if type -P $GFORTRAN ; then break ; fi
360+
done
361+
[[ -n "$GFORTRAN" ]]
331362
mkdir -p fpm-temp/bin
332363
cd fpm-temp
333-
curl --retry 5 -LOsS https://github.com/fortran-lang/fpm/releases/download/v$FPM_VERSION/fpm-$FPM_VERSION.F90
334-
gfortran-14 -o bin/fpm fpm-$FPM_VERSION.F90
364+
curl $CURL_OPTIONS https://github.com/fortran-lang/fpm/releases/download/v$FPM_VERSION/fpm-$FPM_VERSION.F90 -o fpm.F90
365+
$GFORTRAN -fopenmp -o bin/fpm fpm.F90
335366
echo "PATH=$PWD/bin:${PATH}" >> "$GITHUB_ENV"
336367
337368
- name: Version info

0 commit comments

Comments
 (0)