Skip to content

Merge pull request #361 from bonachea/ci-lfortran-08-22 #450

Merge pull request #361 from bonachea/ci-lfortran-08-22

Merge pull request #361 from bonachea/ci-lfortran-08-22 #450

Workflow file for this run

name: Build
on:
push:
paths-ignore: &paths_ignore
- 'docs/**'
- '**.txt'
- '**.md'
pull_request:
paths-ignore: *paths_ignore
workflow_dispatch:
inputs:
fflags:
description: 'Additional FFLAGS'
type: string
required: false
cflags:
description: 'Additional CFLAGS'
type: string
required: false
install_args:
description: 'Additional install/configure args'
type: string
required: false
julienne_args:
description: 'Additional Julienne driver args'
type: string
required: false
env_vars:
description: 'Environment vars: k1=v1 k2=v2'
type: string
default: ''
required: false
concurrency:
# De-duplicate concurrent workflow runs on the same branch/ref
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}-${{ ( github.event_name == 'workflow_dispatch' && github.run_id ) || 'auto' }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
defaults:
run:
shell: bash --noprofile --norc -e -x -o pipefail {0}
jobs:
setup: # establish default configuration values, independent of repo/org
name: Setup
runs-on: ubuntu-latest
outputs:
# The LLVM Flang version on Homebrew : https://formulae.brew.sh/formula/flang
BREW_FLANG_VERSION: ${{ steps.vars.outputs.BREW_FLANG_VERSION }}
steps:
- name: Set default configuration variables
id: vars
run: echo "BREW_FLANG_VERSION=22" >> $GITHUB_OUTPUT
build:
name: ${{ matrix.compiler }}-${{ matrix.version || needs.setup.outputs.BREW_FLANG_VERSION }} ${{ ( matrix.network != 'smp' && matrix.network ) || '' }} (${{ matrix.os }}) ${{ matrix.label }}
needs: setup
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ macos-14, macos-15, macos-15-intel, macos-26, macos-26-intel, ubuntu-24.04 ]
compiler: [ gfortran ]
version: [ 13, 14, 15, 16 ]
network: [ smp ]
include:
# --- Other selected GFortran+Linux combos ---
- os: ubuntu-26.04
compiler: gfortran
version: 16
- os: ubuntu-26.04-arm
compiler: gfortran
version: 16
- os: ubuntu-24.04-arm
compiler: gfortran
version: 16
# --- flang coverage ---
- os: macos-14
compiler: flang
brew_via_install: 1
- os: macos-15
compiler: flang
brew_via_install: 1
- os: macos-15-intel
compiler: flang
brew_via_install: 1
- os: macos-26
compiler: flang
brew_via_install: 1
- os: macos-26-intel
compiler: flang
brew_via_install: 1
- os: ubuntu-24.04
compiler: flang
label: Homebrew
brew_via_install: 1
- os: ubuntu-26.04-arm
label: Homebrew
compiler: flang
brew_via_install: 1
# https://hub.docker.com/r/snowstep/llvm/tags
- os: ubuntu-24.04
compiler: flang
version: latest
container: snowstep/llvm:ubuntu-24.04-latest
#container: snowstep/llvm:debian-12-latest
# https://hub.docker.com/r/phhargrove/llvm-flang/tags
- os: ubuntu-24.04-arm
compiler: flang
version: 23
container: phhargrove/llvm-flang:23.1.0_rc3-latest-arm64
- os: ubuntu-24.04
compiler: flang
version: 23
container: phhargrove/llvm-flang:23.1.0_rc3-latest
- os: ubuntu-24.04
compiler: flang
version: 22
container: phhargrove/llvm-flang:22.1.3-latest
- os: ubuntu-24.04
compiler: flang
version: 21
container: phhargrove/llvm-flang:21.1.0-latest
- os: ubuntu-24.04
compiler: flang
version: 20
container: phhargrove/llvm-flang:20.1.0-latest
- os: ubuntu-24.04
compiler: flang
version: 19
FFLAGS: -mmlir -allow-assumed-rank
container: phhargrove/llvm-flang:19.1.1-latest
# --- lfortran coverage ---
# https://github.com/lfortran/lfortran/pkgs/container/lfortran
- os: ubuntu-22.04
compiler: lfortran
version: latest
container: ghcr.io/lfortran/lfortran:latest
- os: ubuntu-22.04
compiler: lfortran
version: 0.64
container: ghcr.io/lfortran/lfortran:v0.64.0
- os: ubuntu-22.04
compiler: lfortran
version: 0.63
container: ghcr.io/lfortran/lfortran:v0.63.0
# https://hub.docker.com/r/phhargrove/lfortran/tags
- os: ubuntu-24.04
compiler: lfortran
version: 0.63
container: phhargrove/lfortran:0.63.0-1
# --- PRIF-old coverage ---
- os: ubuntu-24.04
compiler: flang
version: 21
label: PRIF-0.5
FFLAGS: -DFORCE_PRIF_0_5
container: phhargrove/llvm-flang:21.1.0-latest
- os: ubuntu-24.04
compiler: flang
version: 21
label: PRIF-0.6
FFLAGS: -DFORCE_PRIF_0_6
container: phhargrove/llvm-flang:21.1.0-latest
- os: ubuntu-24.04
compiler: flang
version: 21
label: PRIF-0.7
FFLAGS: -DFORCE_PRIF_0_7
container: phhargrove/llvm-flang:21.1.0-latest
# --- udp coverage for selected configs ---
- os: macos-26
compiler: gfortran
version: 16
network: udp
- os: macos-15
compiler: gfortran
version: 14
network: udp
- os: ubuntu-24.04
compiler: gfortran
version: 16
network: udp
- os: ubuntu-24.04
compiler: gfortran
version: 14
network: udp
- os: macos-15-intel
compiler: flang
network: udp
- os: macos-15
compiler: flang
network: udp
- os: macos-26-intel
compiler: flang
network: udp
- os: macos-26
compiler: flang
network: udp
- os: ubuntu-24.04
compiler: flang
version: 20
network: udp
container: phhargrove/llvm-flang:20.1.0-latest
- os: ubuntu-24.04
compiler: flang
version: 21
network: udp
container: phhargrove/llvm-flang:21.1.0-latest
- os: ubuntu-24.04
compiler: flang
version: 22
network: udp
container: phhargrove/llvm-flang:22.1.0-latest
- os: ubuntu-24.04-arm
compiler: flang
network: udp
version: 23
container: phhargrove/llvm-flang:23.1.0_rc3-latest-arm64
- os: ubuntu-24.04
compiler: flang
version: 23
network: udp
container: phhargrove/llvm-flang:23.1.0_rc3-latest
- os: ubuntu-24.04
compiler: flang
version: latest
network: udp
container: snowstep/llvm:ubuntu-24.04-latest
#container: snowstep/llvm:debian-12-latest
container:
image: ${{ matrix.container }}
options: --shm-size=2gb
env:
COMPILER_VERSION: ${{ matrix.version || needs.setup.outputs.BREW_FLANG_VERSION }}
FFLAGS: ${{ matrix.FFLAGS }} ${{ inputs.fflags }}
CFLAGS: ${{ matrix.CFLAGS }} ${{ inputs.cflags }}
PREFIX: install
NETWORK_ARG: ${{ matrix.network && format('--network={0}',matrix.network) || '' }}
CURL_OPTIONS: -L --retry 10 --retry-all-errors --fail
GASNET_CONFIGURE_ARGS: --enable-rpath --enable-debug
GASNET_SPAWN_VERBOSE: 1
GASNET_SPAWNFN: L
GASNET_MASTERIP: 127.0.0.1
CAF_IMAGES: 8
steps:
- name: Checkout code
uses: actions/checkout@v1
##########################################################################
# Establish Dependencies
- name: Install Ubuntu Container Dependencies
if: ${{ contains(matrix.os, 'ubuntu') && matrix.container != '' && !contains(matrix.container, 'phhargrove') }}
run: |
apt update
apt install -y build-essential pkg-config make git curl
- name: Install Ubuntu Native Dependencies
if: ${{ contains(matrix.os, 'ubuntu') && matrix.container == '' && !matrix.brew_via_install }}
run: |
sudo apt update
sudo apt install -y build-essential pkg-config make
if [[ ${COMPILER_VERSION} -lt 15 ]] || type -p gfortran-${COMPILER_VERSION} ; then
sudo apt install -y gfortran-${COMPILER_VERSION} g++-${COMPILER_VERSION}
else
curl $CURL_OPTIONS https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh -o install-homebrew.sh
chmod +x install-homebrew.sh
env CI=1 ./install-homebrew.sh
HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew"
${HOMEBREW_PREFIX}/bin/brew install -v gcc@${COMPILER_VERSION} binutils
ls -al ${HOMEBREW_PREFIX}/bin
echo "PATH=${HOMEBREW_PREFIX}/bin:${PATH}" >> "$GITHUB_ENV"
: Homebrew GCC@15 needs binutils 2.44+
HOMEBREW_BINUTILS=$(ls -d ${HOMEBREW_PREFIX}/Cellar/binutils/2.*/bin )
ls -al ${HOMEBREW_BINUTILS}
echo "FFLAGS=${FFLAGS:+"$FFLAGS" }-B ${HOMEBREW_BINUTILS}" >> "$GITHUB_ENV"
echo "CFLAGS=${CFLAGS:+"$CFLAGS" }-B ${HOMEBREW_BINUTILS}" >> "$GITHUB_ENV"
echo "CXXFLAGS=${CXXFLAGS:+"$CXXFLAGS" }-B ${HOMEBREW_BINUTILS}" >> "$GITHUB_ENV"
echo "LDFLAGS=${LDFLAGS:+"$LDFLAGS" }-B ${HOMEBREW_BINUTILS}" >> "$GITHUB_ENV"
fi
- name: Fix macOS Homebrew Configuration
if: ${{ contains(matrix.os, 'macos') }}
run: |
# silence Homebrew tap trust warnings:
(set +e ; brew untap -f aws/tap hashicorp/tap 2>&1 | perl -pe 's/#*.warning./warn: /' ; brew trust azure/bicep )
- name: Install macOS Dependencies
if: ${{ contains(matrix.os, 'macos') && !matrix.brew_via_install }}
run: |
brew update
# fpm binary distribution for macOS requires gfortran shared libraries from gcc@12
brew install gcc@12
if [[ ${{ matrix.compiler }} == 'gfortran' && ${COMPILER_VERSION} -gt 15 ]] ; then
brew install gcc@${COMPILER_VERSION}
fi
- name: Install LLVM flang on macOS
if: ${{ contains(matrix.os, 'macos') && matrix.compiler == 'flang' && !matrix.brew_via_install }}
run: |
brew install llvm@${COMPILER_VERSION} flang
# Prepend homebrew clang to PATH:
echo "PATH=$(brew --prefix)/opt/llvm/bin:${PATH}" >> "$GITHUB_ENV"
- name: Setup FPM
if: ${{ !matrix.brew_via_install && !(runner.os == 'Linux' && runner.arch == 'ARM64') }}
uses: fortran-lang/setup-fpm@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fpm-version: latest
- name: Build FPM
if: ${{ !matrix.brew_via_install && runner.os == 'Linux' && runner.arch == 'ARM64' }}
run: |
export FPM_VERSION=0.13.0
curl --retry 5 -LOsS https://github.com/fortran-lang/fpm/releases/download/v$FPM_VERSION/fpm-$FPM_VERSION.F90
mkdir fpm-temp
gfortran-14 -o fpm-temp/fpm fpm-$FPM_VERSION.F90
echo "PATH=${PWD}/fpm-temp:${PATH}" >> "$GITHUB_ENV"
##########################################################################
# Set Install Variables
- name: Set gfortran variables
if: ${{ matrix.compiler == 'gfortran' }}
run: |
echo "FC=gfortran-${COMPILER_VERSION}" >> "$GITHUB_ENV"
echo "CC=gcc-${COMPILER_VERSION}" >> "$GITHUB_ENV"
echo "CXX=g++-${COMPILER_VERSION}" >> "$GITHUB_ENV"
# XCode 26 / gfortran bug workaround
if [[ ${{ matrix.os }} =~ macos-26 ]] ; then
echo "GASNET_CONFIGURE_ARGS=$GASNET_CONFIGURE_ARGS --enable-force-posix-realtime" >> "$GITHUB_ENV"
fi
- name: Set flang variables
if: ${{ matrix.compiler == 'flang' }}
run: |
if [ -z "${{ matrix.brew_via_install }}" ] ; then
echo "FC=flang-new" >> "$GITHUB_ENV"
echo "CC=clang" >> "$GITHUB_ENV"
echo "CXX=clang++" >> "$GITHUB_ENV"
fi
- name: Setup lfortran dependencies and variables
if: ${{ matrix.compiler == 'lfortran' }}
run: |
apt update
apt install -y llvm clang
if [ ${{ contains(matrix.container, 'ghcr.io/lfortran') }} = true ]; then
ls -alR /app
# Add container lfortran to PATH:
PATH="/app/bin:$PATH"
echo "/app/bin" >> "$GITHUB_PATH"
fi
echo "FC=lfortran" >> "$GITHUB_ENV"
echo "CC=clang" >> "$GITHUB_ENV"
echo "CXX=clang++" >> "$GITHUB_ENV"
HEADER_NAME=ISO_Fortran_binding.h
HEADER_TARGET=include/$HEADER_NAME
HEADER_SOURCE=$(lfortran --print-c-include-dir)/$HEADER_NAME
echo "#include <$HEADER_SOURCE>" > $HEADER_TARGET
find / -name $HEADER_NAME -exec ls -al {} \; -exec md5sum {} \; -exec head {} \; -exec echo --- \;
- name: Set Caffeine variables
run: |
# docker instances cannot handle high levels of subjob parallelism
if test -n "${{ matrix.container }}"; then
echo "SUBJOB_PREFIX=CAF_IMAGES=2" >> "$GITHUB_ENV"
fi
# disable shared-memory bypass with network=udp to simulate multi-node runs
if test "${{ matrix.network }}" = "udp"; then
echo "GASNET_SUPERNODE_MAXSIZE=1" >> "$GITHUB_ENV"
fi
- name: Set Workflow Dispatch Environment
if: github.event_name == 'workflow_dispatch'
run: |
for setting in ${{ inputs.env_vars }}; do
echo $setting >> "$GITHUB_ENV"
done
##########################################################################
# Caffeine Install
- name: Version info (pre-build)
run: |
set +x
echo == TOOL VERSIONS ==
echo Platform version info:
uname -a
if test -r /etc/os-release ; then grep -e NAME -e VERSION /etc/os-release ; fi
if test -x /usr/bin/sw_vers ; then /usr/bin/sw_vers ; fi
if test -d /dev/shm ; then df -h /dev/shm ; fi
echo
echo PATH="$PATH"
for tool in ${FC} ${CC} ${CXX} fpm ; do
if command -v $tool > /dev/null 2>&1 ; then
( echo ; set -x ; w=$(which $tool) ; ls -al $w ; ls -alhL $w ; $tool --version )
fi
done
if [[ ${{ matrix.compiler }} == flang ]] && false ; then
# Report any libflang_rt appearing in common places:
echo
if [ -n "${FC}" ] ; then
RDIR="$(${FC} -print-resource-dir)"
fi
if command -v brew ; then
BDIR="$(brew --prefix)"
fi
set -x
find $RDIR $BDIR /usr/lib/ -name '*flang_rt*' -exec ls -al {} \; | sort | uniq
fi
- name: Build Caffeine (install.sh)
run: |
for var in FC CC CXX FFLAGS CPPFLAGS CFLAGS CXXFLAGS LDFLAGS LIBS GASNET_CONFIGURE_ARGS ; do
eval echo "$var=\$$var"; done
./install.sh --prefix=${PREFIX} ${NETWORK_ARG} --verbose \
${{ inputs.install_args }} ${{ matrix.install_filter }}
if ! grep -q 'NATIVEFLAGS=""' run-fpm.sh ; then
echo "NATIVE_MULTI_IMAGE=true" >> "$GITHUB_ENV"
fi
##########################################################################
# Caffeine Testing
- name: Version info (run-fpm)
run: |
./run-fpm.sh info
- name: Run examples
run: |
echo CAF_IMAGES=${CAF_IMAGES}
./run-fpm.sh run --verbose --example hello
- name: Run native multi-image test (with Caffeine)
if: ${{ env.NATIVE_MULTI_IMAGE == 'true' }}
run: |
./run-fpm.sh run --verbose 2>&1 | tee output
test ${PIPESTATUS[0]} = 0
if [[ "${{ matrix.network }}" != "udp" ]] ; then
# ignore intermittent INEXACT exceptions from AMUDP at exit time
! grep -q "IEEE arithmetic exceptions signaled" output
fi
- name: Run native multi-image test (stand-alone)
if: ${{ matrix.compiler == 'gfortran' && matrix.version >= '16' }}
run: |
make -C app gcc GFORTRAN=$FC
- name: Run unit tests
run: |
while (( CAF_IMAGES > 0 )); do
echo CAF_IMAGES=${CAF_IMAGES}
./run-fpm.sh test --verbose -- ${{ inputs.julienne_args }}
sleep 1
CAF_IMAGES=$(( CAF_IMAGES / 2 ))
done
- name: Run exit/failure tests
run: |
echo CAF_IMAGES=${CAF_IMAGES}
./run-fpm.sh run --verbose --example stop_with_no_code
( set +e ; ./run-fpm.sh run --verbose --example stop_with_integer_code ; test $? = 99 )
( set +e ; ./run-fpm.sh run --verbose --example error_stop_with_integer_code ; test $? = 100 )
( set +e
export CAF_IMAGES=1
./run-fpm.sh run --verbose --example fail_image 2>&1 | tee output
test ${PIPESTATUS[0]} > 0 && grep -q "FAIL IMAGE" output
)
( set +e
./run-fpm.sh run --verbose --example out_of_memory 2>&1 | tee output
test ${PIPESTATUS[0]} > 0 && grep -q "out of memory" output
)
( set +e
./run-fpm.sh run --verbose --example out_of_memory -- --coarray 2>&1 | tee output
test ${PIPESTATUS[0]} > 0 && grep -q "out of memory" output
)
unset GASNET_SPAWN_VERBOSE
for ((i=1; i<=4; i++)); do
(set +e
./run-fpm.sh run --verbose --example exit_case -- $i 2>&1 | tee output
test ${PIPESTATUS[0]} = $((i + 100))
grep -q "stdout from image $CAF_IMAGES" output
grep -q "stderr from image $CAF_IMAGES" output
)
done
- name: Add Linux Brew to PATH
if: ${{ contains(matrix.os, 'ubuntu') && matrix.brew_via_install }}
run: |
# the first install.sh command established Linux Brew, so add it to the
# PATH to prevent pointless overwrites in the second install.sh below
HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew"
( set +e ; ls -al ${HOMEBREW_PREFIX}/bin ; exit 0 )
echo "PATH=${HOMEBREW_PREFIX}/bin:${PATH}" >> "$GITHUB_ENV"
- name: Build and Test Caffeine (thread-safe)
run: |
for var in FC CC CXX FFLAGS CPPFLAGS CFLAGS LDFLAGS LIBS GASNET_CONFIGURE_ARGS ; do
eval echo "$var=\$$var"; done
./install.sh --prefix=${PREFIX} ${NETWORK_ARG} --enable-threads --verbose \
${{ inputs.install_args }} ${{ matrix.install_filter }}
./run-fpm.sh test --verbose -- ${{ inputs.julienne_args }}