Skip to content

Commit

Permalink
Merge pull request #1195 from DLR-AMR/feature-CMake_CI_1
Browse files Browse the repository at this point in the history
CMake CI [1/2]
  • Loading branch information
Davknapp authored Aug 20, 2024
2 parents d230465 + 265ebd4 commit 67e4cb9
Show file tree
Hide file tree
Showing 4 changed files with 396 additions and 1 deletion.
196 changes: 196 additions & 0 deletions .github/workflows/tests_cmake_preparation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
name: CMake tests preparation


# This file is part of t8code.
# t8code is a C library to manage a collection (a forest) of multiple
# connected adaptive space-trees of general element types in parallel.
#
# Copyright (C) 2024 the developers
#
# t8code is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# t8code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with t8code; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

on:
workflow_call:
inputs:
MAKEFLAGS:
required: true
type: string
description: 'Make flags to use for compilation (like -j4)'
IGNORE_CACHE:
required: false
type: boolean
default: false
description: 'Ignore cache and force recompilation'
CACHE_COUNTER:
required: true
type: number
description: 'Counter to force updating the cache'
MPI:
required: true
type: string
description: 'Use MPI for compilation (ON/OFF)'
outputs:
USED_CACHE:
description: "Whether the cache was used"
value: ${{ jobs.cmake_preparation.outputs.USED_CACHE }}

env:
USED_CACHE: ${{ !inputs.IGNORE_CACHE }}

jobs:
cmake_preparation:
runs-on: ubuntu-latest
container: dlramr/t8code-ubuntu:t8-dependencies
timeout-minutes: 10
outputs:
USED_CACHE: ${{ steps.used_cache.outputs.USED_CACHE }}
steps:
#
# Setup
#
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update packages
run: apt-get update && apt-get upgrade -y
# This seems to be necessary because of the docker container
- name: disable ownership checks
run: git config --global --add safe.directory '*'
- name: init submodules
run: git submodule init
- name: update submodules
run: git submodule update
- name: Get input vars
run: export MAKEFLAGS="${{ inputs.MAKEFLAGS }}"
&& export IGNORE_CACHE="${{ inputs.IGNORE_CACHE }}"
&& export CACHE_COUNTER="${{ inputs.CACHE_COUNTER }}"
&& export MPI="${{ inputs.MPI }}"
&& echo MAKEFLAGS="$MAKEFLAGS" >> $GITHUB_ENV
&& echo IGNORE_CACHE="$IGNORE_CACHE" >> $GITHUB_ENV
&& echo CACHE_COUNTER="$CACHE_COUNTER" >> $GITHUB_ENV
&& echo MPI="$MPI" >> $GITHUB_ENV
#
# SC installation
#
- name: store sc folders in var
run: echo SC_BUILD=$PWD/sc/build >> $GITHUB_ENV
&& echo SC_DEBUG=$PWD/sc/build/Debug >> $GITHUB_ENV
&& echo SC_RELEASE=$PWD/sc/build/Release >> $GITHUB_ENV
- name: Get sc commit hash
run: hash=`git rev-parse HEAD:sc` && echo sc_commit=$hash >> $GITHUB_ENV
- name: Check cache for previous sc installation
id: sc_cmake_cache
uses: actions/cache@v4
with:
path: |
${{ env.SC_DEBUG }}
${{ env.SC_RELEASE }}
# You can increase the counter at the end to force a new key and hence recomputing the cache
key: sc-cmake-MPI-${{ inputs.MPI }}-${{ env.sc_commit }}-${{ inputs.CACHE_COUNTER }}
- name: Log that no cache was found
run: echo USED_CACHE=0 >> $GITHUB_ENV
if: ${{ steps.sc_cmake_cache.outputs.cache-hit != 'true' }}
- name: Cache info
if: ${{ steps.sc_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }}
run: echo No cache found or cache will be ignored. IGNORE_CACHE=$IGNORE_CACHE
- name: if ignore cache, delete folders
if: ${{ inputs.IGNORE_CACHE == 1 }}
# The true at the end is to ignore errors that i.e. occur when the folders do not exist
run: rm -r $SC_BUILD || true
- name: make folders
run: mkdir -p $SC_DEBUG $SC_RELEASE
if: ${{ steps.sc_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }}
- name: install sc
run: echo "Install sc"
if: ${{ steps.sc_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }}
## sc debug
- name: sc cmake debug
run: cd $SC_DEBUG && cmake ../../ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$SC_DEBUG/install -Dmpi=$MPI -GNinja
if: ${{ steps.sc_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }}
- name: sc build debug
run: cd $SC_DEBUG && ninja $MAKEFLAGS && ninja $MAKEFLAGS install
if: ${{ steps.sc_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }}
## sc release
- name: sc cmake release
run: cd $SC_RELEASE && cmake ../../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$SC_RELEASE/install -Dmpi=$MPI -GNinja
if: ${{ steps.sc_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }}
- name: sc build release
run: cd $SC_RELEASE && ninja $MAKEFLAGS && ninja $MAKEFLAGS install
if: ${{ steps.sc_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }}
#
# P4EST
#
- name: store p4est folders in var
run: echo P4EST_BUILD=$PWD/p4est/build >> $GITHUB_ENV
&& echo P4EST_DEBUG=$PWD/p4est/build/Debug >> $GITHUB_ENV
&& echo P4EST_RELEASE=$PWD/p4est/build/Release >> $GITHUB_ENV
- name: Get p4est commit hash
run: hash=`git rev-parse HEAD:p4est` && echo p4est_commit=$hash >> $GITHUB_ENV
- name: Check cache for previous p4est installation
id: p4est_cmake_cache
uses: actions/cache@v4
with:
path: |
${{ env.P4EST_DEBUG }}
${{ env.P4EST_RELEASE }}
# You can increase the counter at the end to force a new key and hence recomputing the cache
key: p4est-cmake-MPI-${{ inputs.MPI }}-${{ env.p4est_commit }}-${{ env.sc_commit }}-${{ inputs.CACHE_COUNTER }}
- name: Log that no cache was found
run: echo USED_CACHE=0 >> $GITHUB_ENV
if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' }}
- name: Cache info
if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }}
run: echo No cache found or cache will be ignored. IGNORE_CACHE=$IGNORE_CACHE
- name: install p4est
run: echo "Install p4est"
if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }}
- name: if ignore cache, delete folders
if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }}
# The true at the end is to ignore errors that i.e. occur when the folders do not exist
run: rm -r $P4EST_BUILD || true
- name: make folders
if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }}
run: mkdir -p $P4EST_DEBUG $P4EST_RELEASE
## p4est debug
- name: p4est cmake debug
run: cd $P4EST_DEBUG && cmake ../../ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$P4EST_DEBUG/install -DP4EST_USE_SYSTEM_SC=ON -DSC_DIR=$SC_DEBUG/install/cmake -DP4EST_ENABLE_MPI=$MPI -GNinja
if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }}
- name: p4est build debug
run: cd $P4EST_DEBUG && ninja $MAKEFLAGS && ninja $MAKEFLAGS install
if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }}
## p4est release
- name: p4est cmake release
run: cd $P4EST_RELEASE && cmake ../../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$P4EST_RELEASE/install -DP4EST_USE_SYSTEM_SC=ON -DSC_DIR=$SC_DEBUG/install/cmake -DP4EST_ENABLE_MPI=$MPI -GNinja
if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }}
- name: p4est build release
run: cd $P4EST_RELEASE && ninja $MAKEFLAGS && ninja $MAKEFLAGS install
if: ${{ steps.p4est_cmake_cache.outputs.cache-hit != 'true' || inputs.IGNORE_CACHE == 1 }}

## output cache info
- name: output cache info
id: used_cache
run: echo "USED_CACHE=$USED_CACHE" >> $GITHUB_OUTPUT

## tar artifact to keep permissions: https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss
- name: Tar files
run: tar -cvf artifact.tar .

## upload artifacts
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: SC_P4EST_MPI_${{ inputs.MPI }}
path: ./artifact.tar
retention-days: 1
121 changes: 121 additions & 0 deletions .github/workflows/tests_cmake_sc_p4est.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: CMake tests sc and p4est


# This file is part of t8code.
# t8code is a C library to manage a collection (a forest) of multiple
# connected adaptive space-trees of general element types in parallel.
#
# Copyright (C) 2024 the developers
#
# t8code is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# t8code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with t8code; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

#
# This github CI script installs t8code and runs its tests for various configurations.
# We compile sc and p4est as thirdparty libraries and use caching to only trigger a
# new installation of them when their versions have changed in t8code.
#
# Note: To manually enforce sc and p4est installation, either increase the counter
# in the "key:" entries of the sc and p4est steps or set the variables
# SC_IGNORE_CACHE and P4EST_IGNORE_CACHE to 1 in the respective steps.

on:
workflow_call:
inputs:
MAKEFLAGS:
required: true
type: string
description: 'Make flags to use for compilation (like -j4)'
MPI:
required: true
type: string
description: 'Use MPI for compilation (ON/OFF)'

jobs:
sc_p4est_cmake_tests:
runs-on: ubuntu-latest
container: dlramr/t8code-ubuntu:t8-dependencies
timeout-minutes: 30
steps:
#
# Setup
#
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: SC_P4EST_MPI_${{ inputs.MPI }}
- name: untar artifact
run: tar -xf artifact.tar && rm artifact.tar
- name: Update packages
run: apt-get update && apt-get upgrade -y
# This seems to be necessary because of the docker container
- name: disable ownership checks
run: git config --global --add safe.directory '*'
- name: Get input vars
run: export MAKEFLAGS="${{ inputs.MAKEFLAGS }}"
&& export MPI="${{ inputs.MPI }}"
&& echo MPI="$MPI" >> $GITHUB_ENV
&& echo MAKEFLAGS="$MAKEFLAGS" >> $GITHUB_ENV
#
# SC tests
#
## save variables
- name: Save variables
run: export SC_DEBUG=$PWD/sc/build/Debug
&& export SC_RELEASE=$PWD/sc/build/Release
&& export P4EST_DEBUG=$PWD/p4est/build/Debug
&& export P4EST_RELEASE=$PWD/p4est/build/Release
&& echo SC_DEBUG="$SC_DEBUG" >> $GITHUB_ENV
&& echo SC_RELEASE="$SC_RELEASE" >> $GITHUB_ENV
&& echo P4EST_DEBUG="$P4EST_DEBUG" >> $GITHUB_ENV
&& echo P4EST_RELEASE="$P4EST_RELEASE" >> $GITHUB_ENV
## sc debug
- name: sc debug check
run: cd $SC_DEBUG && ninja test $MAKEFLAGS
- name: OnFailUploadLog
if: failure()
uses: actions/upload-artifact@v4
with:
name: sc_debug_MPI_${{ inputs.MPI }}.log
path: $SC_DEBUG/Testing/Temporary/LastTest.log
## sc release
- name: sc release check
run: cd $SC_RELEASE && ninja test $MAKEFLAGS
- name: OnFailUploadLog
if: failure()
uses: actions/upload-artifact@v4
with:
name: sc_release_MPI_${{ inputs.MPI }}.log
path: $SC_RELEASE/Testing/Temporary/LastTest.log
#
# P4EST tests
#
## p4est debug
- name: p4est debug check
run: cd $P4EST_DEBUG && ninja test $MAKEFLAGS
- name: OnFailUploadLog
if: failure()
uses: actions/upload-artifact@v4
with:
name: sp4est_debug_MPI_${{ inputs.MPI }}.log
path: $P4EST_DEBUG/Testing/Temporary/LastTest.log
## p4est release
- name: p4est release check
run: cd $P4EST_RELEASE && ninja test $MAKEFLAGS
- name: OnFailUploadLog
if: failure()
uses: actions/upload-artifact@v4
with:
name: sp4est_release_MPI_${{ inputs.MPI }}.log
path: $P4EST_RELEASE/Testing/Temporary/LastTest.log
78 changes: 78 additions & 0 deletions .github/workflows/tests_cmake_testsuite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: t8code CMake testsuite


# This file is part of t8code.
# t8code is a C library to manage a collection (a forest) of multiple
# connected adaptive space-trees of general element types in parallel.
#
# Copyright (C) 2024 the developers
#
# t8code is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# t8code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with t8code; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

#
# This github CI script installs t8code and runs its tests for various configurations.
# We compile sc and p4est as thirdparty libraries and use caching to only trigger a
# new installation of them when their versions have changed in t8code.
#
# Note: To manually enforce sc and p4est installation, either increase the counter
# in the "CACHE_COUNTER:" entries of the sc and p4est steps or set the variables
# IGNORE_CACHE to true in the respective steps.

on:
push:
branches:
- main
- develop
- feature-*CI* # for testing this script, all feature branches with "CI" in their name
pull_request:
branches:
- main
- develop
workflow_dispatch: # Be able to trigger this manually on github.com
# Run every night at 1:10
schedule:
- cron: '10 1 * * *'

jobs:
# Preparation step for tests. Repo is cloned and sc + p4est are compiled with and without MPI.
preparation:
if: (github.event_name == 'schedule' && github.repository == 'DLR-AMR/t8code') || (github.event_name != 'schedule')
uses: ./.github/workflows/tests_cmake_preparation.yml
strategy:
fail-fast: false
matrix:
MPI: [OFF, ON]
include:
- MAKEFLAGS: -j4
with:
MAKEFLAGS: ${{ matrix.MAKEFLAGS }}
IGNORE_CACHE: false # Use this to force a new installation of sc and p4est for this specific workflow run
CACHE_COUNTER: 0 # Increase this number to force a new installation of sc and p4est and to update the cache once
MPI: ${{ matrix.MPI }}

# Run parallel tests for sc and p4est with and without MPI
sc_p4est_tests:
if: ((github.event_name == 'schedule' && github.repository == 'DLR-AMR/t8code') || (github.event_name != 'schedule'))
needs: preparation
uses: ./.github/workflows/tests_cmake_sc_p4est.yml
strategy:
fail-fast: false
matrix:
MPI: [OFF, ON]
include:
- MAKEFLAGS: -j4
with:
MAKEFLAGS: ${{ matrix.MAKEFLAGS }}
MPI: ${{ matrix.MPI }}
Loading

0 comments on commit 67e4cb9

Please sign in to comment.