testing scenarios #792
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: testing scenarios | |
# Controls when the action will run. | |
on: | |
# run on push | |
push: | |
# schedule test for nightly build | |
schedule: | |
- cron: "22 0 * * *" | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Note: the defaults are repeated within the env section | |
# of some of the jobs so any change to the default | |
# need to be done twice! | |
inputs: | |
logLevel: | |
description: 'Log level' | |
required: true | |
default: 'Warning' | |
branch: | |
# note: this should be either 'master' or a tag of the form | |
# vN where 'N' is a legal python package version | |
# e.g. N=2.9.0rc1 | |
# otherwise the distributions will not be generated | |
# and the build will fail | |
description: 'core modules tag e.g. (master | v2.9.0) [master]' | |
required: true | |
default: 'master' | |
fembranch: | |
# note: this should be either 'master' or a tag of the form | |
# vN where 'N' is a legal python package version | |
# e.g. N=2.9.0rc1 | |
# otherwise the distributions will not be generated | |
# and the build will fail | |
description: 'dune-fem modules tag e.g. (master | v2.9.0.1) [master]' | |
required: true | |
default: 'master' | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# generate test file matrix | |
getTests: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.setmatrix.outputs.matrix }} | |
steps: | |
- name: printParameters | |
run: | | |
echo "Workflow parameters" | |
echo "Using github branch : ${GITHUB_REF#refs/heads/}" | |
echo "Using log level : ${{ github.event.inputs.logLevel }}" | |
echo "Using dune-core branch: ${{ github.event.inputs.branch }}" | |
echo "Using dune-fem branch: ${{ github.event.inputs.fembranch }}" | |
- name: checkout source code | |
uses: actions/checkout@v1 | |
- id: setmatrix | |
run: | | |
matrixArray=$(find ./testing -name '*.sh') # Creates array of all files .sh withing testing | |
# Start Generate Json String | |
echo "$matrixArray" | \ | |
jq --slurp --raw-input 'split("\n")[:-1]' | \ | |
jq "{\"filepath\": .[], \"os\":\"ubuntu-latest\" }, {\"filepath\": .[], \"os\": \"macOS-latest\" }" | \ | |
jq -sc "{ \"include\": . }" > tmp | |
cat ./tmp | |
# End Generate Json String | |
matrixStringifiedObject=$(cat ./tmp) # Use this as jq @sh not working right | |
# echo "::set-output name=matrix::$matrixStringifiedObject" | |
# this is the new version to fix deprecated set-output | |
echo "matrix=$matrixStringifiedObject" >> $GITHUB_OUTPUT | |
# build packages | |
build: | |
name: build | |
runs-on: [ubuntu-latest] | |
env: | |
BRANCH: master | |
FEMBRANCH: master | |
steps: | |
- name: environmentCore | |
if: github.event.inputs.branch != '' | |
run: echo "BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV | |
- name: environmentFem | |
if: github.event.inputs.fembranch != '' | |
run: echo "FEMBRANCH=${{ github.event.inputs.fembranch }}" >> $GITHUB_ENV | |
- name: starting | |
uses: actions/checkout@v3 | |
- name: clone dune branch ${{ env.BRANCH }} and build python packages | |
run: | | |
pip install scikit-build | |
./clone-modules $BRANCH $FEMBRANCH "none" | |
- name: upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: packages | |
path: dist/ | |
# test packages | |
test: | |
name: testing tutorial | |
needs: [ build, getTests ] | |
env: | |
LOGLEVEL: Warning | |
BRANCH: master | |
FEMBRANCH: master | |
strategy: | |
fail-fast: false | |
# Note: | |
# 1) macOS does not install petsc4py | |
matrix: ${{fromJson(needs.getTests.outputs.matrix)}} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: starting | |
uses: actions/checkout@v3 | |
- name: environment | |
if: github.event.inputs.logLevel != '' | |
run: echo "LOGLEVEL=${{ github.event.inputs.logLevel }}" >> $GITHUB_ENV | |
- name: environmentCore | |
if: github.event.inputs.branch != '' | |
run: echo "BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV | |
- name: environmentFem | |
if: github.event.inputs.fembranch != '' | |
run: echo "FEMBRANCH=${{ github.event.inputs.fembranch }}" >> $GITHUB_ENV | |
- name: Install dependencies | |
run: | | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
# note: using 'apt-get -o Acquire::Retries=3' to dance around connectivity issues to Azure, | |
# use apt-spy2 to select closest apt mirror, | |
# which helps avoid connectivity issues in Azure; | |
# see https://github.com/actions/virtual-environments/issues/675 | |
# APT-SPY2 fails also | |
# sudo gem install apt-spy2 | |
# sudo apt-spy2 check | |
# sudo apt-spy2 fix --commit | |
# after selecting a specific mirror, we need to run 'apt-get update' | |
sudo apt-get update -o Acquire::Retries=3 | |
sudo apt-get install libopenmpi-dev openmpi-bin libsuperlu-dev libsuitesparse-dev petsc-dev paraview python3-paraview gmsh libboost-all-dev python3-numpy python3-matplotlib python3-scipy python3-mpi4py python3-ufl | |
elif [ "$RUNNER_OS" == "macOS" ]; then | |
# fixes an issue with homebrew can probably be remove once the issue is resolved | |
# https://github.com/orgs/Homebrew/discussions/4612#discussioncomment-6356325 | |
export HOMEBREW_NO_INSTALL_FROM_API= | |
brew config | |
brew untap homebrew/core homebrew/cask | |
brew config | |
# normal service resumes... | |
brew update | |
brew install [email protected] || true | |
brew install [email protected] || true | |
brew install openmpi superlu suite-sparse gmsh boost pkg-config || true | |
fi | |
shell: bash | |
- name: download artifacts | |
uses: actions/download-artifact@v3 | |
# if all packages exist on pypi then no artifacts are uploaded so don't fail | |
continue-on-error: true | |
with: | |
name: packages | |
path: dist | |
- name: Run test | |
run: | | |
export DUNEPY_DISABLE_PLOTTING=1 | |
export DUNE_LOG_LEVEL=$LOGLEVEL | |
echo "Running: ${{ matrix.filepath }}" | |
ls -R | |
tar xzf dist/repos.tar.gz | |
mkdir test | |
cd test | |
bash -e ../${{ matrix.filepath }} $BRANCH $FEMBRANCH $RUNNER_OS | |
shell: bash |