-
Notifications
You must be signed in to change notification settings - Fork 55
196 lines (188 loc) · 8.54 KB
/
tests_cmake_preparation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
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