From 68581c67c9b72ee74b7a7f6015fe65c3d6f41fab Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 7 Aug 2024 16:27:51 +0200 Subject: [PATCH 1/6] bump p4est for cmake CI --- p4est | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/p4est b/p4est index 7896878956..8206f0e56d 160000 --- a/p4est +++ b/p4est @@ -1 +1 @@ -Subproject commit 78968789560133460f0eee74897a44b3444790e5 +Subproject commit 8206f0e56d536d6d7f2e1d106c491b8c9386e28f From 1b49f3be9c8cb6724ea5c6ec3f59c46552f93608 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 7 Aug 2024 16:28:44 +0200 Subject: [PATCH 2/6] add preparation step for cmake CI --- .github/workflows/tests_cmake_preparation.yml | 192 ++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 .github/workflows/tests_cmake_preparation.yml diff --git a/.github/workflows/tests_cmake_preparation.yml b/.github/workflows/tests_cmake_preparation.yml new file mode 100644 index 0000000000..705143dd29 --- /dev/null +++ b/.github/workflows/tests_cmake_preparation.yml @@ -0,0 +1,192 @@ +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 + IGNORE_CACHE: + required: false + type: boolean + default: false + CACHE_COUNTER: + required: true + type: number + MPI: + required: true + type: string + 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 From d19852c8be030042361ce67ef1f176483719c85c Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 7 Aug 2024 16:29:11 +0200 Subject: [PATCH 3/6] add sc and p4est cmake tests --- .github/workflows/tests_cmake_sc_p4est.yml | 119 +++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 .github/workflows/tests_cmake_sc_p4est.yml diff --git a/.github/workflows/tests_cmake_sc_p4est.yml b/.github/workflows/tests_cmake_sc_p4est.yml new file mode 100644 index 0000000000..d06d16334e --- /dev/null +++ b/.github/workflows/tests_cmake_sc_p4est.yml @@ -0,0 +1,119 @@ +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 + MPI: + required: true + type: string + +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 From 94f8fda30c681f1e79b7fbf6d90faa636a306eab Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 7 Aug 2024 16:29:38 +0200 Subject: [PATCH 4/6] add control file for cmake CI --- .github/workflows/tests_cmake_testsuite.yml | 78 +++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/tests_cmake_testsuite.yml diff --git a/.github/workflows/tests_cmake_testsuite.yml b/.github/workflows/tests_cmake_testsuite.yml new file mode 100644 index 0000000000..19cedc5dd4 --- /dev/null +++ b/.github/workflows/tests_cmake_testsuite.yml @@ -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 }} From ff9055f7a778701d080c97e5be1a53be23b98922 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 20 Aug 2024 11:41:20 +0200 Subject: [PATCH 5/6] add input description for cmake ci preparation --- .github/workflows/tests_cmake_preparation.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/tests_cmake_preparation.yml b/.github/workflows/tests_cmake_preparation.yml index 705143dd29..4325e59f35 100644 --- a/.github/workflows/tests_cmake_preparation.yml +++ b/.github/workflows/tests_cmake_preparation.yml @@ -27,16 +27,20 @@ on: 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" From 65dd30145b845816d7ede57bb85000a7f9d96127 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 20 Aug 2024 11:42:08 +0200 Subject: [PATCH 6/6] add input description for cmake ci sc p4est --- .github/workflows/tests_cmake_sc_p4est.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests_cmake_sc_p4est.yml b/.github/workflows/tests_cmake_sc_p4est.yml index d06d16334e..fe3ab95796 100644 --- a/.github/workflows/tests_cmake_sc_p4est.yml +++ b/.github/workflows/tests_cmake_sc_p4est.yml @@ -36,9 +36,11 @@ on: 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: