-
Notifications
You must be signed in to change notification settings - Fork 5
225 lines (221 loc) · 8.62 KB
/
tests.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: test
on:
push: { branches: [ main ] }
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: DoozyX/[email protected]
with:
source: 'include/ddc/ tests/ examples/'
exclude: ''
extensions: 'hpp,cpp'
clangFormatVersion: 12
id_repo:
runs-on: ubuntu-latest
steps:
- name: Identify repository
id: identify_repo
run: |
echo "in_base_repo=${{ (github.event_name == 'push' && github.repository == 'CExA-project/ddc') || github.event.pull_request.head.repo.full_name == 'CExA-project/ddc' }}" >> "$GITHUB_OUTPUT"
outputs: { in_base_repo: '${{ steps.identify_repo.outputs.in_base_repo }}' }
docker-build:
strategy:
fail-fast: false
matrix:
image: ['oldest', 'latest']
backend: ['cpu', 'cuda', 'hip']
exclude:
- image: 'oldest'
backend: 'cuda'
needs: id_repo
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/[email protected]
with: { tool-cache: true, large-packages: false }
- name: Checkout built branch
uses: actions/checkout@v3
- name: Build
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin || true
docker pull ghcr.io/cexa-project/ddc/${{matrix.image}}_${{matrix.backend}} || true
docker build \
--build-arg BACKEND=${{matrix.backend}} \
--cache-from ghcr.io/cexa-project/ddc/${{matrix.image}}_${{matrix.backend}} \
-t ghcr.io/cexa-project/ddc/${{matrix.image}}_${{matrix.backend}} \
-t ghcr.io/cexa-project/ddc/${{matrix.image}}_${{matrix.backend}}:${GITHUB_SHA:0:7} \
docker/${{matrix.image}}
- name: Publish image for current SHA
if: needs.id_repo.outputs.in_base_repo == 'true'
run: |
docker push ghcr.io/cexa-project/ddc/${{matrix.image}}_${{matrix.backend}}:${GITHUB_SHA:0:7}
- name: Publish latest (default) image
if: github.event_name == 'push' && github.ref_name == 'main' && needs.id_repo.outputs.in_base_repo == 'true'
run: |
docker push ghcr.io/cexa-project/ddc/${{matrix.image}}_${{matrix.backend}}
- name: Create image tarball
if: needs.id_repo.outputs.in_base_repo == 'false'
run: |
docker save ghcr.io/cexa-project/ddc/${{matrix.image}}_${{matrix.backend}}:${GITHUB_SHA:0:7} > ${{matrix.image}}_${{matrix.backend}}.tar
- name: Generate docker artifact from image
if: needs.id_repo.outputs.in_base_repo == 'false'
uses: actions/upload-artifact@v3
with:
name: ${{matrix.image}}_${{matrix.backend}}-artifact
path: ${{matrix.image}}_${{matrix.backend}}.tar
retention-days: 1
test:
strategy:
fail-fast: false
matrix:
image: ['oldest', 'latest']
backend: ['cpu-gcc', 'cpu-clang', 'cuda', 'hip']
cxx_version: ['17', '20', '23']
cmake_build_type: ['Debug', 'Release']
exclude:
- image: 'oldest' # image not available
backend: 'cuda'
- image: 'oldest' # no compiler supports C++-23 in oldest
cxx_version: '23'
- image: 'oldest' # clang does not support C++-20 in oldest
backend: 'cpu-clang'
cxx_version: '20'
- image: 'latest' # nvcc only supports C++-17
backend: 'cuda'
cxx_version: '20'
- image: 'latest' # nvcc only supports C++-17
backend: 'cuda'
cxx_version: '23'
runs-on: ubuntu-latest
needs: [docker-build, id_repo]
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/[email protected]
with: { tool-cache: true, large-packages: false }
- name: Checkout built branch
uses: actions/checkout@v3
with: { submodules: recursive }
- name: Collect image artifact
if: needs.id_repo.outputs.in_base_repo == 'false'
uses: actions/download-artifact@v3
with:
name: |
${{matrix.image}}_${{fromJSON('{"cpu-gcc":"cpu","cpu-clang":"cpu"}')[matrix.backend] || matrix.backend}}-artifact
- name: Load image artifact into docker
if: needs.id_repo.outputs.in_base_repo == 'false'
run: |
docker load < ${{matrix.image}}_${{fromJSON('{"gcc":"cpu","clang":"cpu"}')[matrix.backend] || matrix.backend}}.tar
rm ${{matrix.image}}_${{fromJSON('{"cpu-gcc":"cpu","cpu-clang":"cpu"}')[matrix.backend] || matrix.backend}}.tar
- name: Test
id: test
run: |
cat<<-'EOF' > run.sh
set -xe
git config --global --add safe.directory '*'
case "${{matrix.backend}}" in
'cuda')
export CC=${CUDA_GCC}
export CXX=${CUDA_GXX}
EXTRA_CMAKE_FLAGS="-DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_AMPERE80=ON -DKokkos_ENABLE_LIBDL=OFF"
;;
'hip')
export CC=hipcc
export CXX=hipcc
EXTRA_CMAKE_FLAGS="-DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_VEGA90A=ON -DCMAKE_PREFIX_PATH=/opt/rocm"
CMAKE_CXX_FLAGS="-Wno-gnu-zero-variadic-macro-arguments"
;;
'cpu-clang')
export CC=clang
export CXX=clang++
CMAKE_CXX_FLAGS="-Wno-gnu-zero-variadic-macro-arguments"
;;
'cpu-gcc')
export CC=gcc
export CXX=g++
if [ 'xDebug' = 'x${{matrix.cmake_build_type}}' ]
then
CMAKE_CXX_FLAGS="-fno-omit-frame-pointer -fsanitize=address"
fi
;;
esac
cmake \
-DBUILD_BENCHMARKS=ON \
-DCMAKE_BUILD_TYPE=${{matrix.cmake_build_type}} \
-DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \
-DMDSPAN_CXX_STANDARD=${{matrix.cxx_version}} \
-DKokkos_ENABLE_DEPRECATED_CODE_3=OFF \
-DKokkos_ENABLE_DEPRECATED_CODE_4=OFF \
-DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF \
-DCMAKE_CXX_FLAGS="\
-Wall -Wextra -Wpedantic \
-Werror=vla \
-Werror=implicit-fallthrough \
${CMAKE_CXX_FLAGS}" \
${EXTRA_CMAKE_FLAGS} \
/src
make -j 2
case "${{matrix.backend}}" in
'cpu-'*)
ctest -j 2 --output-on-failure --timeout 5 --output-junit tests.xml
;;
esac
EOF
docker run \
--cidfile='docker.cid' \
-v ${PWD}:/src:ro \
ghcr.io/cexa-project/ddc/${{matrix.image}}_${{fromJSON('{"cpu-gcc":"cpu","cpu-clang":"cpu"}')[matrix.backend] || matrix.backend}}:${GITHUB_SHA:0:7} \
bash /src/run.sh
if docker cp "$(cat docker.cid)":/data/tests.xml /home/runner/work/ddc/ddc/tests.xml
then echo "with_report=true" >> "$GITHUB_OUTPUT"
else echo "with_report=false" >> "$GITHUB_OUTPUT"
fi
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: ( success() || failure() ) && steps.test.outputs.with_report == 'true' # always run even if the previous step fails
with:
report_paths: '/home/runner/work/ddc/ddc/tests.xml'
clang-tidy-test:
runs-on: ubuntu-latest
needs: [docker-build, id_repo]
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/[email protected]
with: { tool-cache: true, large-packages: false }
- name: Checkout built branch
uses: actions/checkout@v3
with: { submodules: recursive }
- name: Collect image artifact
if: needs.id_repo.outputs.in_base_repo == 'false'
uses: actions/download-artifact@v3
with: { name: 'latest_cpu-artifact' }
- name: Load image artifact into docker
if: needs.id_repo.outputs.in_base_repo == 'false'
run: |
docker load < latest_cpu-artifact.tar
rm latest_cpu-artifact.tar
- name: clang-tidy
run: |
cat<<-'EOF' > run.sh
set -xe
git config --global --add safe.directory '*'
cmake \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DBUILD_BENCHMARKS=ON \
-DBUILD_TESTING=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=17 \
-DMDSPAN_CXX_STANDARD=17 \
-DKokkos_ENABLE_DEPRECATED_CODE_3=OFF \
-DKokkos_ENABLE_DEPRECATED_CODE_4=OFF \
-DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF \
-S /src \
-B build
find /src/benchmarks /src/examples /src/tests -name '*.cpp' -exec clang-tidy-14 -p build -header-filter="(/src/include/ddc/.*|/src/tests/.*)" '{}' '+'
EOF
docker run \
-v ${PWD}:/src:ro ghcr.io/cexa-project/ddc/latest_cpu:${GITHUB_SHA:0:7} \
bash /src/run.sh