Skip to content

adds github action petsc check #196

adds github action petsc check

adds github action petsc check #196

Workflow file for this run

# Github Actions workflow
#
# runs compilation tests on Linux Ubuntu and Mac platforms
name: CI
on: [push, pull_request]
jobs:
changesCheck:
name: Check file changes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for changes
id: diff
run: |
if [ $GITHUB_BASE_REF ]; then
# Pull Request
echo "Pull request:"
git fetch origin $GITHUB_BASE_REF --depth=1
export DIFF=$( git diff --name-only origin/$GITHUB_BASE_REF $GITHUB_SHA )
echo " diff between origin/$GITHUB_BASE_REF and $GITHUB_SHA"
else
# Push
echo "Push request:"
git fetch origin ${{ github.event.before }} --depth=1
export DIFF=$( git diff --name-only ${{ github.event.before }} $GITHUB_SHA )
echo " diff between ${{ github.event.before }} and $GITHUB_SHA"
fi
echo "***"; echo "$DIFF"; echo "***"
# Escape newlines (replace \n with %0A)
# deprecated:
#echo "::set-output name=diff::$( echo "$DIFF" | sed ':a;N;$!ba;s/\n/%0A/g' )"
# new:
# replace new line with %0A - will result finding only one file with a very long name...
#echo "diff=$( echo "$DIFF" | sed ':a;N;$!ba;s/\n/%0A/g' )" >> $GITHUB_OUTPUT
# doesn't work...
#echo "diff=\"$DIFF\"" >> "$GITHUB_OUTPUT"
# new multi-line format:
# (https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings)
echo "diff<<EOF" >> $GITHUB_OUTPUT
echo "$DIFF" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Output changes
run: echo "${{ steps.diff.outputs.diff }}"
- name: Check files
run: |
RUN_CHECKS=0
DIFF="${{ steps.diff.outputs.diff }}"
# Loop by lines
while read path; do
# Set $directory to substring before /
directory="$( echo $path | cut -d'/' -f1 -s )"
echo "file: $path - directory: $directory"
if [ -z "$directory" ]; then
# root directory
RUN_CHECKS=1
elif [ "$directory" == src ]; then
# src/ directory
RUN_CHECKS=1
elif [ "$directory" == setup ]; then
# setup/ directory
RUN_CHECKS=1
elif [ "$directory" == EXAMPLES ]; then
# EXAMPLES/ directory
RUN_CHECKS=1
elif [ "$directory" == tests ]; then
# tests/ directory
RUN_CHECKS=1
elif [ "$directory" == .github ]; then
# .github/ directory
RUN_CHECKS=1
fi
done <<< "$DIFF"
echo
echo "run checks: ${RUN_CHECKS}"
if [[ ${RUN_CHECKS} -eq 0 ]]; then echo "nothing to check, exiting..."; exit 1; fi
macosCheck:
name: Test on Mac
runs-on: macos-latest
needs: changesCheck
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
brew cleanup
brew reinstall gcc # need gfortran (symlink to gfortran-10)
brew install hwloc openmpi
echo ""
echo "compiler versions:"
echo "gcc --version"
gcc --version
echo "gfortran --version"
gfortran --version
echo "mpif90 --version"
mpif90 --version
echo ""
## avoids sed -i '' issue on MacOS, using gnu sed to have the same sed command lines as in linux
brew install gnu-sed
echo "PATH=/opt/homebrew/opt/gnu-sed/libexec/gnubin:$PATH" >> $GITHUB_ENV
## OpenMP
echo "OMP_NUM_THREADS=2" >> $GITHUB_ENV
## MPI
echo
echo "MPI environment:"
echo "mpif90 on path: $(which mpif90)"
echo
# add OpenMPI path to have ./configure detect mpi.h
echo "MPI_INC=/opt/homebrew/include" >> $GITHUB_ENV
## avoids MPI issue with number of slots
echo "OMPI_MCA_rmaps_base_oversubscribe=1" >> $GITHUB_ENV
echo "OMPI_MCA_rmaps_base_inherit=1" >> $GITHUB_ENV
## avoids MPI issue when running in MacOS
echo "OMPI_MCA_btl=self,tcp" >> $GITHUB_ENV
# newer OpenMPI version (5.x)
echo "PRTE_MCA_rmaps_default_mapping_policy=:oversubscribe" >> $GITHUB_ENV
# exports for xterm output (for make tests)
echo "TERM=xterm" >> $GITHUB_ENV
# warning: (arm64) could not find object file symbol for symbol ___mulsc3
echo "LDFLAGS=-lgcc" >> $GITHUB_ENV
echo ""
echo "exports:"
export
echo ""
- name: configure
run: ./configure
# skipping - compilation check done as well in make tests
#- name: make
# run: make -j2 all
- name: make tests
run: make tests
linuxCheck:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: changesCheck
strategy:
matrix:
os: [ubuntu-latest,ubuntu-20.04]
steps:
- uses: actions/checkout@v4
- name: Install packages
run: ./.github/scripts/run_install.sh
shell: bash
- name: configure
run: ./configure
- name: make
run: make -j2 all
linuxCheck-Intel:
name: Test Intel on ubuntu-20.04
runs-on: ubuntu-20.04
needs: changesCheck
steps:
- uses: actions/checkout@v4
- name: Cache Intel oneapi packages
id: cache-intel-oneapi
uses: actions/cache@v3
with:
path: /opt/intel/oneapi
key: install-${{ runner.os }}-all
- name: Install packages
if: steps.cache-intel-oneapi.outputs.cache-hit != 'true'
run: |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
echo ""
sudo echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update
echo ""
# info
#sudo -E apt-cache pkgnames intel | grep intel-oneapi
#echo ""
echo "installing packages intel oneapi:"
sudo apt-get install -y intel-oneapi-compiler-fortran-2023.2.2 intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2023.2.2 intel-oneapi-mpi intel-oneapi-mpi-devel
echo ""
- name: compiler infos
run: |
echo ""
source /opt/intel/oneapi/setvars.sh
echo ""
echo "compiler versions:"
echo "icx --version"
which icx
icx --version
echo ""
echo "icc --version"
which icc
icc --version
echo ""
echo "ifx --version"
which ifx
ifx --version
echo ""
echo "ifort --version"
which ifort
ifort --version
echo ""
echo "mpiifort --version"
which mpiifort
mpiifort --version
echo ""
echo "mpif90 --version"
which mpif90
mpif90 --version
echo ""
# infos
which ifort
which icc
which mpiifort
echo "mpirun:"
which mpirun
echo ""
# intel setup for running tests
echo ""
echo "replacing mpif90 with mpiifort link:"
sudo ln -sf $(which mpiifort) $(which mpif90)
mpif90 --version
echo ""
# debug
#export I_MPI_DEBUG=5,pid,host
#export I_MPI_LIBRARY_KIND=debug
# remove -ftrapuv which leads to issues for running tests
sed -i "s/-ftrapuv//g" flags.guess
# environment setting
export TERM=xterm
# export info
echo "exports:"
export
echo ""
echo ""
printenv >> $GITHUB_ENV
echo "CXX=icpc" >> $GITHUB_ENV
echo "CC=icc" >> $GITHUB_ENV
echo "FC=ifort" >> $GITHUB_ENV
echo ""
- name: configure debug
run: |
./configure --enable-debug FC=ifort CC=icc MPIFC=mpiifort
- name: make debug
run: |
make -j2 all
make -j2 all --always-make
make clean
- name: configure
run: |
./configure FC=ifort CC=icc MPIFC=mpiifort
- name: make
run: |
make -j2 all
make clean
# note: fails with -ftrapuv flag due to MPI issue on virtual nodes
- name: make tests
run: |
make tests
linuxTest_0:
name: Test run example 0 - make tests
runs-on: ubuntu-latest
needs: [linuxCheck]
steps:
- uses: actions/checkout@v4
- name: Install packages
run: ./.github/scripts/run_install.sh
shell: bash
- name: configure
run: ./configure
- name: make tests
run: make tests
linuxTest_1:
name: Test run example 1 - regional_Greece_small debug
runs-on: ubuntu-latest
needs: [linuxCheck]
steps:
- uses: actions/checkout@v4
- name: Install packages
run: ./.github/scripts/run_install.sh
shell: bash
- name: Run build
env:
TESTFLAGS: --enable-debug
run: ./.github/scripts/run_build.sh
shell: bash
- name: Run test
env:
TESTDIR: EXAMPLES/regional_Greece_small
DEBUG: true
run: ./.github/scripts/run_tests.sh
shell: bash
linuxTest_2:
name: Test run example 2 - regional_Greece_small
runs-on: ubuntu-latest
needs: [linuxCheck]
steps:
- uses: actions/checkout@v4
- name: Install packages
run: ./.github/scripts/run_install.sh
shell: bash
- name: Run build
env:
TESTFLAGS: --enable-vectorization
run: ./.github/scripts/run_build.sh
shell: bash
- name: Run test
env:
TESTDIR: EXAMPLES/regional_Greece_small
run: ./.github/scripts/run_tests.sh
shell: bash
linuxTest_3:
name: Test run example 3 - regional_sgloberani
runs-on: ubuntu-latest
needs: [linuxCheck]
steps:
- uses: actions/checkout@v4
- name: Install packages
run: ./.github/scripts/run_install.sh
shell: bash
- name: Run build
env:
TESTFLAGS: # no extra flags
run: ./.github/scripts/run_build.sh
shell: bash
- name: Run test
env:
TESTDIR: EXAMPLES/regional_sgloberani
run: ./.github/scripts/run_tests.sh
shell: bash
linuxTest_4:
name: Test run example 4 - point_force
runs-on: ubuntu-latest
needs: [linuxCheck]
steps:
- uses: actions/checkout@v4
- name: Install packages
run: ./.github/scripts/run_install.sh
shell: bash
- name: Run build
env:
TESTFLAGS: "FLAGS_CHECK=-O3 -mcmodel=medium -std=gnu -Wall -Wno-do-subscript -Wno-conversion -Wno-maybe-uninitialized"
run: ./.github/scripts/run_build.sh
shell: bash
- name: Run test
env:
TESTDIR: EXAMPLES/point_force
run: ./.github/scripts/run_tests.sh
shell: bash
linuxTest_5:
name: Test run example 5 - moon_global
runs-on: ubuntu-latest
needs: [linuxCheck]
steps:
- uses: actions/checkout@v4
- name: Install packages
run: ./.github/scripts/run_install.sh
shell: bash
- name: Run build
env:
TESTFLAGS: --enable-vectorization
run: ./.github/scripts/run_build.sh
shell: bash
- name: Run test
env:
TESTDIR: EXAMPLES/moon_global
run: ./.github/scripts/run_tests.sh
shell: bash
linuxTest_6:
name: Test run example 6 - mars_regional
runs-on: ubuntu-latest
needs: [linuxCheck]
steps:
- uses: actions/checkout@v4
- name: Install packages
run: ./.github/scripts/run_install.sh
shell: bash
- name: Run build
env:
TESTFLAGS: --enable-vectorization
run: ./.github/scripts/run_build.sh
shell: bash
- name: Run test
env:
TESTDIR: EXAMPLES/mars_regional
run: ./.github/scripts/run_tests.sh
shell: bash
linuxTest_7:
name: Test run example 7 - global_small
runs-on: ubuntu-latest
needs: [linuxCheck]
steps:
- uses: actions/checkout@v4
- name: Install packages
run: ./.github/scripts/run_install.sh
shell: bash
- name: Run build
env:
TESTFLAGS: --enable-vectorization
run: ./.github/scripts/run_build.sh
shell: bash
- name: Run test
env:
TESTDIR: EXAMPLES/global_small
run: ./.github/scripts/run_tests.sh
shell: bash
linuxTest_8:
name: Test run example 7 - global_small w/ FULL_GRAVITY
runs-on: ubuntu-latest
needs: [linuxCheck]
steps:
- uses: actions/checkout@v4
- name: Install packages
run: ./.github/scripts/run_install.sh
shell: bash
- name: Run build
env:
TESTFLAGS: --enable-debug
run: ./.github/scripts/run_build.sh
shell: bash
- name: Run test
env:
TESTDIR: EXAMPLES/global_small
FULL_GRAVITY: true
run: ./.github/scripts/run_tests.sh
shell: bash
linuxTest_9:
name: Test run example 7 - global_small w/ FULL_GRAVITY PETSC
runs-on: ubuntu-latest
needs: [linuxCheck]
steps:
- uses: actions/checkout@v4
- name: Install packages
env:
PETSC: true
run: ./.github/scripts/run_install.sh
shell: bash
- name: Run build
env:
TESTFLAGS: --enable-vectorization --with-petsc PETSC_INC=/usr/include/petsc
run: ./.github/scripts/run_build.sh
shell: bash
- name: Run test
env:
TESTDIR: EXAMPLES/global_small
FULL_GRAVITY: true
run: ./.github/scripts/run_tests.sh
shell: bash