-
Notifications
You must be signed in to change notification settings - Fork 40
268 lines (257 loc) · 9.32 KB
/
build-multi.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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
permissions: read-all
defaults:
run:
shell: bash
env:
TEST_GROUPS_ARRAY: '["perf", "conformance", "negative", "layer", "stress"]'
jobs:
config:
runs-on: ubuntu-latest
outputs:
short-sha: ${{ steps.const.outputs.short-sha }}
ref-slug: ${{ steps.const.outputs.ref-slug }}
build-matrix: ${{ steps.build-matrix.outputs.matrix }}
image-matrix: ${{ steps.image-matrix.outputs.matrix }}
groups: ${{ steps.const.outputs.groups }}
steps:
- uses: actions/checkout@v4
with:
clean: true
ref: ${{ github.event.pull_request.head.sha }}
- name: Set constants
id: const
run: |
cat >> ${GITHUB_OUTPUT} <<EOF
short-sha=$(git rev-parse --short=7 ${GITHUB_SHA})
ref-slug=$(echo ${{ github.ref_name }} | tr '/_' '-')
groups=${{ env.TEST_GROUPS_ARRAY }}
EOF
- name: Generate build matrix
id: build-matrix
run: '
echo ''matrix={
"os":[
{"name":"ubuntu", "vmaj":"20", "vmin":"04"},
{"name":"ubuntu", "vmaj":"22", "vmin":"04"},
{"name":"sles", "vmaj":"15", "vmin":"2"},
{"name":"sles", "vmaj":"15", "vmin":"3"},
{"name":"sles", "vmaj":"15", "vmin":"4"},
{"name":"rhel", "vmaj":"8", "vmin":"6"},
{"name":"windows"}
],
"arch":[""],
"include":[
{"os":{"name":"ubuntu", "vmaj":"20", "vmin":"04"}, "arch":"arm64"}
]
}'' | tee -a ${GITHUB_OUTPUT} | sed "s/matrix\=\(.*\)/\1/" | jq .'
- name: Generate image build matrix
id: image-matrix
run: |
echo 'matrix={"os":'$(echo '${{ steps.build-matrix.outputs.matrix }}' | jq -c .os)'}' |
tee -a ${GITHUB_OUTPUT} | sed "s/matrix\=\(.*\)/\1/" | jq .
image:
runs-on: ${{ matrix.os.name == 'windows' && 'windows-latest' || 'ubuntu-latest' }}
needs: [config]
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.config.outputs.image-matrix) }}
env:
OS_STRING: >-
${{ matrix.os.name == 'windows' && 'windows' ||
format('{0}-{1}.{2}',
matrix.os.name,
matrix.os.vmaj,
matrix.os.vmin
)
}}
DOCKER_BUILDKIT: ${{ matrix.os.name == 'windows' && '0' || '1' }}
steps:
- name: Compute image name
run: echo "DOCKER_IMAGE=localhost/${{ github.repository }}/${OS_STRING}" >> ${GITHUB_ENV}
- uses: actions/checkout@v4
with:
clean: true
submodules: true
- name: "Registry login: ghcr.io"
run: |
echo ${{ secrets.GITHUB_TOKEN }} |
docker login -u sys-lzdev --password-stdin ghcr.io
- name: Setup buildkit builder
if: env.DOCKER_BUILDKIT == '1'
id: buildx-builder
uses: docker/setup-buildx-action@v3
- name: Build image
run: |
docker info
docker \
${{ env.DOCKER_BUILDKIT == '0' && 'build' || 'buildx build --load' }} \
${{ runner.os == 'Windows' && ' \
--memory 16G ' || ' '
}}\
${{ matrix.os.vmaj != '' && format(' \
--build-arg VMAJ={0} \
--build-arg VMIN={1} ', matrix.os.vmaj, matrix.os.vmin) || ' '
}}\
--pull \
--tag ${DOCKER_IMAGE}:${{ needs.config.outputs.ref-slug }} \
- < .github/docker/${{ matrix.os.name }}.Dockerfile
- name: Save image
run: docker save ${DOCKER_IMAGE}:${{ needs.config.outputs.ref-slug }} -o ./${{ env.OS_STRING }}.tar
- name: Save image ID
run: echo "$(docker images --format '{{.ID}}' ${DOCKER_IMAGE}:${{ needs.config.outputs.ref-slug }})" > ./${{ env.OS_STRING }}.id
- name: Upload image
uses: actions/upload-artifact@v4
with:
name: ${{ env.OS_STRING }}
path: ./${{ env.OS_STRING }}.*
build:
# Notes on formatting:
#
# GitHub Actions expressions ${{ ... }} are used wherever possible so the
# evaluation results are plainly visible in the web console.
#
# Note the mixed spaces and tabs in the heredocs, see the bash man page
# entry for <<- in the Here Documents section. This allows generated code to
# be indented for readability in the workflow output.
needs: [config, image]
runs-on: ${{ matrix.os.name == 'windows' && 'windows-latest' || 'ubuntu-latest' }}
# Always run build even if the image step failed, except if the job was cancelled
if: >-
always() &&
! cancelled() &&
needs.config.result == 'success'
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.config.outputs.build-matrix) }}
env:
TEST_GROUPS: ${{ join(fromJSON(needs.config.outputs.groups), ' ') }}
MSYS_NO_PATHCONV: 1
MOUNT_TARGET: ${{ matrix.os.name == 'windows' && 'C:/project' || '/project' }}
# -j breaks the Visual Studio configuration selection
PARALLEL: ${{ ! (matrix.os.name == 'windows') && '-j' || '' }}
ARCH_SUFFIX: ${{ matrix.arch != '' && format('_{0}', matrix.arch) || '' }}
steps:
- name: Set constants
id: const
env:
OS_STRING: >-
${{ matrix.os.name == 'windows' && 'windows' ||
format('{0}-{1}.{2}',
matrix.os.name,
matrix.os.vmaj,
matrix.os.vmin
)
}}
CCACHE_DIR: ${{ github.workspace }}/ccache
run: |
cat >> ${GITHUB_OUTPUT} <<EOF
os-string=${OS_STRING}
image-name=ghcr.io/${{ github.repository }}/${OS_STRING}
ccache-dir=${CCACHE_DIR}
EOF
- uses: actions/checkout@v4
with:
clean: true
fetch-depth: 0
- name: Checkout loader
uses: actions/checkout@v4
with:
repository: oneapi-src/level-zero
clean: true
path: ./level-zero
- name: Create Ccache directory
run: mkdir -p '${{ steps.const.outputs.ccache-dir }}'
- name: Ccache
uses: actions/cache@v4
with:
path: ${{ steps.const.outputs.ccache-dir }}
key: ccache-${{ github.job }}-${{ steps.const.outputs.os-string }}${{ env.ARCH_SUFFIX }}-${{ github.sha }}
restore-keys: ccache-${{ github.job }}-${{ steps.const.outputs.os-string }}${{ env.ARCH_SUFFIX }}-
- name: Download image
uses: actions/download-artifact@v4
with:
name: ${{ steps.const.outputs.os-string }}
- name: Load image
run: docker load -i ./${{ steps.const.outputs.os-string }}.tar
- name: Get image ID
id: image-id
run: echo "id=$(cat ./${{ steps.const.outputs.os-string }}.id)" >> ${GITHUB_OUTPUT}
- name: Build loader
run: |
mkdir level-zero/build
docker run \
--rm \
--interactive \
-v '${{ github.workspace }}':${MOUNT_TARGET} \
-w ${MOUNT_TARGET}/level-zero/build \
-e CCACHE_BASEDIR=${MOUNT_TARGET} \
-e CCACHE_DIR=${MOUNT_TARGET}/ccache \
-v '${{ steps.const.outputs.ccache-dir }}':${MOUNT_TARGET}/ccache \
${{ steps.image-id.outputs.id }} \
bash -e -x <<-EOF
ccache --zero-stats
cmake \
-G Ninja \
${{ matrix.arch == 'arm64' && ' \
-D CMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
-D CMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
-D CMAKE_SYSTEM_PROCESSOR=aarch64' || ' '
}}\
-D CMAKE_C_COMPILER_LAUNCHER=ccache \
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
${{ runner.os == 'Windows' && ' \
-D USE_Z7=TRUE'
}} \
-D CMAKE_INSTALL_PREFIX=${MOUNT_TARGET}/level-zero/install \
..
ninja -j $(nproc) install
ccache --show-stats
EOF
- name: Build
id: build
run: |
mkdir build
${{ matrix.coverity-build && 'mkdir cov' || '' }}
docker run \
--rm \
--interactive \
-v '${{ github.workspace }}':${MOUNT_TARGET} \
-w ${MOUNT_TARGET}/build \
-e CCACHE_BASEDIR=${MOUNT_TARGET} \
-e CCACHE_DIR=${MOUNT_TARGET}/ccache \
-e MSYS_NO_PATHCONV=1 \
-v '${{ steps.const.outputs.ccache-dir }}':${MOUNT_TARGET}/ccache \
${{ matrix.coverity-build && format(' \
-v {0}:{0} ', steps.coverity.outputs.install) || ' '
}}\
${{ steps.image-id.outputs.id }} \
bash -e -x <<-EOF
ccache --zero-stats
for group in ${TEST_GROUPS}; do
cmake \
-G Ninja \
${{ matrix.arch == 'arm64' && ' \
-D CMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
-D CMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
-D CMAKE_SYSTEM_PROCESSOR=aarch64 ' || ' '
}}\
-D CMAKE_C_COMPILER_LAUNCHER=ccache \
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
${{ runner.os == 'Windows' && ' \
-D USE_Z7=TRUE' || ' '
}}\
-D GROUP="/\${group}_tests" \
-D CMAKE_PREFIX_PATH=${MOUNT_TARGET}/level-zero/install \
-D REQUIRE_OPENCL_BENCHMARKS=yes \
-D CMAKE_INSTALL_PREFIX=${MOUNT_TARGET}/level-zero-tests-\${group} \
..
cmake --build . -j --target install
done
ccache --show-stats
EOF