CMake build #902
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CMake build | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: '0 0 * * 1' # 0h mondays | |
workflow_dispatch: | |
inputs: | |
git-ref: | |
description: Git Ref (Optional) | |
required: false | |
stress-test: | |
description: Stress Test (Optional, true or false) | |
required: false | |
verbose-makefile: | |
description: Verbose Makefile (Optional, true or false) | |
required: false | |
# Show the git ref in the workflow name if it is invoked manually. | |
run-name: ${{ github.event_name == 'workflow_dispatch' && format('Manual run {0} , {1}, {2}', inputs.git-ref, inputs.stress-test, inputs.verbose-makefile) || '' }} | |
permissions: | |
contents: read | |
jobs: | |
# N.B.: It is tempting to use environment variables to define the compiler flags to avoid | |
# repeating them, but this is not supported as of 20240501. See | |
# https://stackoverflow.com/questions/74072206/github-actions-use-variables-in-matrix-definition | |
cmake-main: | |
runs-on: ${{ matrix.os }} | |
continue-on-error: true | |
strategy: | |
fail-fast: false | |
matrix: | |
# See https://github.com/fortran-lang/setup-fortran?tab=readme-ov-file#runner-compatibility | |
# for the toolchains provided by fortran-lang/setup-fortran. We test the latest three on each OS. | |
# First define the toolchains on Linux and macOS. | |
os: [ubuntu-latest, ubuntu-24.04, macos-12, macos-13] | |
toolchain: | |
- {compiler: gcc, version: 11, cflags: '-Wall -Wextra -Wpedantic -Werror', fflags: '-Wall -Wextra -Wpedantic -Werror -fimplicit-none -fcheck=all -fstack-check -Wno-function-elimination'} | |
- {compiler: gcc, version: 12, cflags: '-Wall -Wextra -Wpedantic -Werror', fflags: '-Wall -Wextra -Wpedantic -Werror -fimplicit-none -fcheck=all -fstack-check -Wno-function-elimination'} | |
- {compiler: gcc, version: 13, cflags: '-Wall -Wextra -Wpedantic -Werror', fflags: '-Wall -Wextra -Wpedantic -Werror -fimplicit-none -fcheck=all -fstack-check -Wno-function-elimination'} | |
- {compiler: intel-classic, version: '2021.8', cflags: '-diag-disable=10441 -Wall -w3 -Werror-all', fflags: '-warn all -debug extended -fimplicit-none -standard-semantics'} | |
- {compiler: intel-classic, version: '2021.9', cflags: '-diag-disable=10441 -Wall -w3 -Werror-all', fflags: '-warn all -debug extended -fimplicit-none -standard-semantics'} | |
- {compiler: intel-classic, version: '2021.10', cflags: '-diag-disable=10441 -Wall -w3 -Werror-all', fflags: '-warn all -debug extended -fimplicit-none -standard-semantics'} | |
include: | |
# intel compiler (ifx) does not support macOS. So they are not included above but below. | |
# Zaikun 20240423 | |
# On ubuntu-latest, we want to use '-Wall -w3 -Werror-all' as what we do for the intel-classic | |
# compiler, but the (new) intel c compiler does not recognize '-W3 -Werror-all', even though the | |
# official documentation of the compiler mentions them. Why? | |
- os: ubuntu-latest | |
toolchain: {compiler: intel, version: '2023.2', cflags: '-Wall -Werror', fflags: '-warn all -debug extended -fimplicit-none -standard-semantics'} | |
- os: ubuntu-latest | |
toolchain: {compiler: intel, version: '2024.0', cflags: '-Wall -Werror', fflags: '-warn all -debug extended -fimplicit-none -standard-semantics'} | |
- os: ubuntu-latest | |
toolchain: {compiler: intel, version: '2024.1', cflags: '-Wall -Werror', fflags: '-warn all -debug extended -fimplicit-none -standard-semantics'} | |
- os: ubuntu-24.04 | |
toolchain: {compiler: intel, version: '2023.2', cflags: '-Wall -Werror', fflags: '-warn all -debug extended -fimplicit-none -standard-semantics'} | |
- os: ubuntu-24.04 | |
toolchain: {compiler: intel, version: '2024.0', cflags: '-Wall -Werror', fflags: '-warn all -debug extended -fimplicit-none -standard-semantics'} | |
- os: ubuntu-24.04 | |
toolchain: {compiler: intel, version: '2024.1', cflags: '-Wall -Werror', fflags: '-warn all -debug extended -fimplicit-none -standard-semantics'} | |
# What follows contains the toolchains for Windows, including gcc, intel classic, and intel. | |
- os: windows-latest | |
toolchain: {compiler: gcc, version: 11, cflags: '-Wall -Wextra -Wpedantic -Werror', fflags: '-Wall -Wextra -Wpedantic -Werror -fimplicit-none -fcheck=all -fstack-check -Wno-function-elimination'} | |
- os: windows-latest | |
toolchain: {compiler: gcc, version: 12, cflags: '-Wall -Wextra -Wpedantic -Werror', fflags: '-Wall -Wextra -Wpedantic -Werror -fimplicit-none -fcheck=all -fstack-check -Wno-function-elimination'} | |
- os: windows-latest | |
toolchain: {compiler: gcc, version: 13, cflags: '-Wall -Wextra -Wpedantic -Werror', fflags: '-Wall -Wextra -Wpedantic -Werror -fimplicit-none -fcheck=all -fstack-check -Wno-function-elimination'} | |
# Zaikun 20240423: | |
# 1. On windows-latest, the cflags will not be recognized correctly if we start them with `/` instead | |
# of `-`, even though the former aligns with the official documentation of the compilers. Why? | |
# 2. On windows-latest, we want to use '-Wall -W5 -Werror-all' as what we do for the intel-classic | |
# compiler, but the (new) intel c compiler does not recognize '-W5 -Werror-all', even though the | |
# official documentation of the compiler mentions them. Why? | |
- os: windows-latest | |
toolchain: {compiler: intel, version: '2023.2', cflags: '-Wall -Werror', fflags: '/warn:all /debug:extended /Z7 /fimplicit-none /standard-semantics'} | |
- os: windows-latest | |
toolchain: {compiler: intel, version: '2024.0', cflags: '-Wall -Werror', fflags: '/warn:all /debug:extended /Z7 /fimplicit-none /standard-semantics'} | |
- os: windows-latest | |
toolchain: {compiler: intel, version: '2024.1', cflags: '-Wall -Werror', fflags: '/warn:all /debug:extended /Z7 /fimplicit-none /standard-semantics'} | |
- os: windows-latest | |
toolchain: {compiler: intel, version: '2024.1', cflags: '-Wall -W4 -WX', fflags: '/warn:all /debug:extended /Z7 /fimplicit-none /standard-semantics', cc: cl} | |
# N.B.: As of 20240401, setup-fortran fails constantly with windows-latest and intel-classic | |
# 2021.8. Thus this combination is not included. | |
- os: windows-latest | |
toolchain: {compiler: intel-classic, version: '2021.9', cflags: '-Qdiag-disable:10441 -Wall -W5 -Werror-all', fflags: '/warn:all /debug:extended /Z7 /fimplicit-none /standard-semantics'} | |
- os: windows-latest | |
toolchain: {compiler: intel-classic, version: '2021.10', cflags: '-Qdiag-disable:10441 -Wall -W5 -Werror-all', fflags: '/warn:all /debug:extended /Z7 /fimplicit-none /standard-semantics'} | |
- os: windows-latest | |
toolchain: {compiler: intel-classic, version: '2021.10', cflags: '-Wall -W4 -WX', fflags: '/warn:all /debug:extended /Z7 /fimplicit-none /standard-semantics', cc: cl} | |
steps: | |
- name: Set http.postBuffer and core.compression | |
# This is a workaround for random "early EOF" of checkout. | |
# See https://github.com/actions/checkout/issues/748, https://github.com/actions/checkout/issues/1379 | |
if: startsWith(matrix.os, 'windows') | |
run: git config --global http.postBuffer 1048576000 && git config --global core.compression 0 | |
- name: Clone Repository (Latest) | |
uses: actions/checkout@v4 | |
if: github.event.inputs.git-ref == '' | |
with: | |
# ssh-key: ${{ secrets.SSH_PRIVATE_KEY_ACT }} # This forces checkout to use SSH, not HTTPS | |
# As of 231227, checkout with ssh fails frequently on Windows runners. | |
submodules: recursive | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Clone Repository (Custom Ref) | |
uses: actions/checkout@v4 | |
if: github.event.inputs.git-ref != '' | |
with: | |
ref: ${{ github.event.inputs.git-ref }} | |
# ssh-key: ${{ secrets.SSH_PRIVATE_KEY_ACT }} # This forces checkout to use SSH, not HTTPS | |
# As of 231227, checkout with ssh fails frequently on Windows runners. | |
submodules: recursive | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Miscellaneous setup | |
shell: bash | |
run: | | |
# Get the latest version of github_actions_scripts. Needed if the last step did not clone the latest version of the repository. | |
rm -rf .github/scripts && git clone https://github.com/equipez/github_actions_scripts.git .github/scripts && ls -al .github/scripts | |
bash .github/scripts/misc_setup | |
# Revise string.f90 in order to print the value of `x` in case segmentation fault happens | |
# again as https://github.com/libprima/prima/actions/runs/7599777476/job/20697191410 | |
- name: Revise string.f90 | |
if: ${{ matrix.os == 'windows-latest' }} | |
shell: bash | |
run: | | |
cd fortran/common/ || exit 42 | |
$SEDI "s|\(write (str, '(I0)') x\)|write (*, *) '---> x = ', x, '<---'\n\1|" string.f90 | |
cat string.f90 | |
- name: Set up Fortran | |
uses: fortran-lang/setup-fortran@main | |
id: setup-fortran | |
with: | |
compiler: ${{ matrix.toolchain.compiler }} | |
version: ${{ matrix.toolchain.version }} | |
- name: Override C compiler | |
if: ${{ matrix.toolchain.cc }} | |
run: echo "CC=${{ matrix.toolchain.cc }}" >> $env:GITHUB_ENV | |
- name: Build and test | |
run: | | |
cmake --version | |
VERBOSE_MAKEFILE=OFF | |
if [[ "${{ github.event.inputs.verbose-makefile }}" == "true" ]] ; then | |
VERBOSE_MAKEFILE=ON | |
fi | |
cmake -G Ninja -DCMAKE_VERBOSE_MAKEFILE:BOOL=$VERBOSE_MAKEFILE -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=. -LAH -DCMAKE_C_FLAGS="${{ matrix.toolchain.cflags }}" -DCMAKE_Fortran_FLAGS="${{ matrix.toolchain.fflags }}" . | |
cmake --build . --target install | |
cmake --build . --target tests | |
ctest --output-on-failure -V -E stress | |
env: | |
FC: ${{ steps.setup-fortran.outputs.fc }} | |
shell: bash | |
- name: Stress test | |
if: ${{ github.event_name == 'schedule' || github.event.inputs.stress-test == 'true' }} | |
run: | | |
ctest --output-on-failure -V -R stress | |
shell: bash | |
cmake-other: | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
strategy: | |
fail-fast: false | |
matrix: | |
toolchain: | |
# Classic Flang family with -Mchkptr would fail. See https://forums.developer.nvidia.com/t/bug-in-nvfortran-with-mchkptr-for-unallocated-optional-arguments/223220 | |
# As of 20240220, aflang with -Mbounds would fail due to the bug at https://github.com/flang-compiler/flang/issues/1238 | |
- {compiler: nvfortran, cflags: '-Wall -Wextra -Wpedantic -Werror', fflags: '-C -Wall -Wextra -Minform=warn -Mstandard -Mbounds -Mchkstk'} | |
- {compiler: flang, cflags: '-Wall -Wextra -Wpedantic -Werror', fflags: '-std=f2018 -pedantic -fimplicit-none -Werror'} | |
- {compiler: aflang, cflags: '-Wall -Wextra -Wpedantic -Werror', fflags: '-pedantic -Weverything -Wall -Wextra -Minform=warn -Mstandard'} | |
steps: | |
- name: Clone Repository (Latest) | |
uses: actions/checkout@v4 | |
if: github.event.inputs.git-ref == '' | |
with: | |
ssh-key: ${{ secrets.SSH_PRIVATE_KEY_ACT }} # This forces checkout to use SSH, not HTTPS | |
submodules: recursive | |
- name: Clone Repository (Custom Ref) | |
uses: actions/checkout@v4 | |
if: github.event.inputs.git-ref != '' | |
with: | |
ref: ${{ github.event.inputs.git-ref }} | |
ssh-key: ${{ secrets.SSH_PRIVATE_KEY_ACT }} # This forces checkout to use SSH, not HTTPS | |
submodules: recursive | |
- name: Miscellaneous setup | |
run: bash .github/scripts/misc_setup | |
- name: Install AOCC | |
if: ${{ matrix.toolchain.compiler == 'aflang' }} | |
run: bash .github/scripts/install_aocc | |
- name: Install nvfortran | |
if: ${{ matrix.toolchain.compiler == 'nvfortran' }} | |
run: bash .github/scripts/install_nvfortran | |
# Install Flang after AOCC, to make sure that flang is this one, while AOCC flang will be | |
# known as aflang. | |
- name: Install Flang | |
if: ${{ matrix.toolchain.compiler == 'flang' }} | |
run: bash .github/scripts/install_flang | |
- name: Build and test | |
run: | | |
$FC --version | |
#$CC --version | |
cmake --version | |
VERBOSE_MAKEFILE=OFF | |
if [[ "${{ github.event.inputs.verbose-makefile }}" == "true" ]] ; then | |
VERBOSE_MAKEFILE=ON | |
fi | |
cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=$VERBOSE_MAKEFILE -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=. -LAH -DCMAKE_C_FLAGS="${{ matrix.toolchain.cflags }}" -DCMAKE_Fortran_FLAGS="${{ matrix.toolchain.fflags }}" . | |
cmake --build . --target install | |
cmake --build . --target tests | |
# As of 20240316, CMake test fails on cobyla with the AOCC flang and nvfortran. | |
# See https://github.com/libprima/prima/issues/165 | |
ctest --output-on-failure -V -E "stress|cobyla" | |
shell: bash | |
env: | |
FC: ${{ matrix.toolchain.compiler }} | |
- name: Stress test | |
if: ${{ github.event_name == 'schedule' || github.event.inputs.stress-test == 'true' }} | |
run: | | |
ctest --output-on-failure -V -R stress -E cobyla | |
shell: bash | |
# The following job check whether the tests were successful or cancelled due to timeout. | |
# N.B.: Remember to specify `continue-on-error: true` for the job of the tests. | |
check_success_timeout: | |
runs-on: ubuntu-latest | |
if: ${{ !cancelled() }} | |
needs: [cmake-main, cmake-other] | |
steps: | |
- name: Clone the GitHub actions scripts | |
uses: actions/checkout@v4 | |
with: | |
repository: equipez/github_actions_scripts | |
ssh-key: ${{ secrets.SSH_PRIVATE_KEY_ACT }} # This forces checkout to use SSH, not HTTPS | |
path: scripts | |
- name: Check whether the tests were successful or cancelled due to timeout | |
run: bash scripts/check_success_timeout_big_test ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ github.run_id }} |