-
Notifications
You must be signed in to change notification settings - Fork 8
189 lines (177 loc) · 7.19 KB
/
tests-ubuntu.yaml
File metadata and controls
189 lines (177 loc) · 7.19 KB
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
# Copyright (C) The DDC development team, see COPYRIGHT.md file
#
# SPDX-License-Identifier: MIT
---
name: Tests on Ubuntu
# yamllint disable-line rule:truthy
on:
pull_request:
paths:
- '.github/workflows/tests-ubuntu.yaml'
- '**.cpp'
- '**.hpp'
- '**.hpp.in'
- 'CMakeLists.txt'
- '**/CMakeLists.txt'
- '**.cmake'
- '**.cmake.in'
- 'docker/**'
- 'vendor/**'
push:
branches:
- main
paths:
- '.github/workflows/tests-ubuntu.yaml'
- '**.cpp'
- '**.hpp'
- '**.hpp.in'
- 'CMakeLists.txt'
- '**/CMakeLists.txt'
- '**.cmake'
- '**.cmake.in'
- 'docker/**'
- 'vendor/**'
concurrency:
group: ${{github.workflow}}-${{github.ref == github.ref_protected && github.run_id || github.event.pull_request.number || github.ref}}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: jidicula/clang-format-action@4726374d1aa3c6aecf132e5197e498979588ebc8 # v4.15.0
with:
clang-format-version: '20'
- name: Prefer 'if defined'/'if !defined' over 'ifdef'/'ifndef'
run: if grep -RE "(ifdef|ifndef)" $(git ls-files '*.[ch]pp' ':!*/kokkos-kernels-ext/*'); then exit 1; fi
- name: Do not include <iostream> in the headers of the library
run: if grep -R "#include <iostream>" $(git ls-files 'include/*.[ch]pp'); then exit 1; fi
- name: Find modifications of Kokkos reserved macros
run: if grep -RE "(define|undef) KOKKOS_" $(git ls-files '*.[ch]pp'); then exit 1; fi
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']
needs: id_repo
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with: {tool-cache: true, large-packages: false}
- name: Checkout built branch
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Login to GitHub Container Registry
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Build
run: |
DOCKER_BUILDKIT=1 docker build \
--build-arg BACKEND=${{matrix.backend}} \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--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@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{matrix.image}}_${{matrix.backend}}-artifact
path: ${{matrix.image}}_${{matrix.backend}}.tar
retention-days: 1
coverage-test:
if: github.ref_name != 'main'
strategy:
fail-fast: false
matrix:
image: ['latest']
backend:
- name: 'cpu'
c_compiler: 'gcc'
cxx_compiler: 'g++'
cxx_version: ['17']
cmake_build_type: ['Debug']
runs-on: ubuntu-latest
needs: [docker-build, id_repo]
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with: {tool-cache: true, large-packages: false}
- name: Checkout built branch
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with: {submodules: true}
- name: Collect image artifact
if: needs.id_repo.outputs.in_base_repo == 'false'
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: |
${{matrix.image}}_${{matrix.backend.name}}-artifact
- name: Load image artifact into docker
if: needs.id_repo.outputs.in_base_repo == 'false'
run: |
docker load < ${{matrix.image}}_${{matrix.backend.name}}.tar
rm ${{matrix.image}}_${{matrix.backend.name}}.tar
- name: Install gcovr
run: |
pipx install gcovr
- name: clang-tidy
run: |
cat<<-'EOF' > run.sh
set -xe
git config --global --add safe.directory '*'
export CMAKE_BUILD_PARALLEL_LEVEL=4
export CMAKE_BUILD_TYPE=${{matrix.cmake_build_type}}
export CC=${{matrix.backend.c_compiler}}
export CXX=${{matrix.backend.cxx_compiler}}
cmake \
-DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \
-DCMAKE_CXX_FLAGS="--coverage -fprofile-update=atomic" \
-DDDC_BUILD_BENCHMARKS=OFF \
-DKokkos_ENABLE_DEPRECATED_CODE_4=OFF \
-DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF \
-B build \
-S /src
ctest --test-dir build
gcovr --filter include/ddc --lcov coverage.lcov --merge-mode-functions=merge-use-line-0 build
cat coverage.lcov
EOF
docker run \
--cidfile='docker.cid' \
-v ${PWD}:/src:ro \
ghcr.io/cexa-project/ddc/${{matrix.image}}_${{matrix.backend.name}}:${GITHUB_SHA:0:7} \
bash /src/run.sh
if docker cp "$(cat docker.cid)":/data/coverage.lcov ${{github.workspace}}/coverage.lcov
then echo "with_report=true" >> "$GITHUB_OUTPUT"
else echo "with_report=false" >> "$GITHUB_OUTPUT"
fi
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d #v5.4.2
with:
files: coverage.lcov
token: ${{secrets.CODECOV_TOKEN}}
verbose: true