forked from Mellanox/rshim-user-space
-
Notifications
You must be signed in to change notification settings - Fork 0
277 lines (249 loc) · 9.71 KB
/
ci.yml
File metadata and controls
277 lines (249 loc) · 9.71 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
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
269
270
271
272
273
274
275
276
277
---
#
# Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
name: CI/CD pipeline for rshim - deb and rpm for amd64 and arm64
on:
push:
branches:
- '**'
tags:
- '*'
permissions:
contents: write
jobs:
build-and-test:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
- name: Create apt-get update retry script
run: |
cat << 'EOF' > retry_apt_update.sh
#!/bin/bash
# Retry apt-get update with exponential backoff and built-in retries
retry_apt_get_update() {
local attempt=0
local max_attempts=5
local delay=10
while (( attempt < max_attempts )); do
echo "Running apt-get update (attempt $((attempt+1))/$max_attempts)..."
if sudo apt-get update -o Acquire::Retries=3; then
return 0
fi
echo "apt-get update failed. Retrying in ${delay}s..."
sleep $delay
delay=$(( delay * 2 ))
attempt=$(( attempt + 1 ))
done
echo "apt-get update failed after $max_attempts attempts."
return 1
}
EOF
chmod +x retry_apt_update.sh
- name: Install dependencies (for .deb)
run: |
. ./retry_apt_update.sh
if sudo apt-get update || retry_apt_get_update; then
systemd_dep="systemd"
if apt-cache show systemd-dev >/dev/null 2>&1; then
systemd_dep="systemd-dev"
fi
sudo apt-get install -y \
build-essential debhelper devscripts fakeroot git \
libpci-dev libusb-1.0-0-dev libfuse-dev pkg-config \
"$systemd_dep"
else
echo "Unable to refresh apt cache"
exit 1
fi
- name: Prepare release body
id: changelog
run: |
body=$(./scripts/get-changelog debian/changelog)
echo "body<<EOF" >> $GITHUB_OUTPUT
echo "${body}" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create source tarball
run: |
[ -d dist ] || mkdir -p dist
version="$(./scripts/get-ver)"
tarball="rshim-src-${version}.tar.gz"
git archive --format=tar.gz -o "$tarball" HEAD
mv -v "$tarball" dist/
ls -lh dist
- name: Build & Test x86_64 .deb package
run: |
version="$(./scripts/get-ver)"
sed -i "1s/(\(.*\))/($version)/" debian/changelog
DEB_BUILD_OPTIONS="nocheck nostrip nolto" \
CFLAGS="-fno-lto" LDFLAGS="-fno-lto" \
dpkg-buildpackage -us -uc -a amd64
mkdir -p dist
mv -v ../*.deb dist/
ls -lh dist
sudo dpkg -i dist/*.deb || sudo apt-get -f install -y
echo "Running rshim --version:"
rshim --version
- name: Capture UID/GID for Docker
id: uidgid
run: |
echo "HOST_UID=$(id -u)" >> $GITHUB_ENV
echo "HOST_GID=$(id -g)" >> $GITHUB_ENV
- name: Build & Test ARM64 .deb package in Docker
run: |
set -euo pipefail
docker run --rm --privileged multiarch/qemu-user-static \
--reset -p yes
# Retry function for Docker build
retry_count=0
max_retries=3
delay=20
while true; do
echo "Docker build attempt $((retry_count + 1))/$max_retries"
if docker run --rm --platform linux/arm64 \
-e HOST_UID="${{ env.HOST_UID }}" \
-e HOST_GID="${{ env.HOST_GID }}" \
-v "${{ github.workspace }}:/workspace" \
-w /workspace \
arm64v8/ubuntu:22.04 \
/bin/bash -c "
set -euo pipefail
. /workspace/retry_apt_update.sh
apt-get update || retry_apt_get_update
systemd_dep="systemd"
if apt-cache show systemd-dev >/dev/null 2>&1; then
systemd_dep="systemd-dev"
fi
apt-get install -y \
autoconf automake libtool build-essential debhelper \
devscripts fakeroot gcc git libpci-dev libusb-1.0-0-dev \
libfuse-dev libsystemd-dev libpci3 libusb-1.0-0 fuse \
pkg-config "\$systemd_dep"
git config --global --add safe.directory /workspace && \
version=\$(/workspace/scripts/get-ver)
sed -i \"1s/(\(.*\))/(\$version)/\" /workspace/debian/changelog
mkdir -p /workspace/build
DEB_BUILD_OPTIONS='nocheck nostrip nolto' \
CFLAGS="-fno-lto" LDFLAGS="-fno-lto" \
dpkg-buildpackage -us -uc -a arm64 || {
echo '--- pkg-config failure diagnostics ---'
pkg-config --modversion libpci || true
pkg-config --modversion libusb-1.0 || true
pkg-config --modversion fuse || true
pkg-config --variable=systemdsystemunitdir systemd || true
echo '--- config.log tails ---'
find . -name config.log -exec sh -c \
'echo ==== {}; tail -n 200 {}' \;
exit 1
}
mv -v ../*.deb /workspace/build/ && \
dpkg -i /workspace/build/*.deb || apt-get -f install -y
echo 'Running rshim --version:'
rshim --version
chown -R \$HOST_UID:\$HOST_GID /workspace
"; then
echo "Docker build succeeded on attempt $((retry_count + 1))"
break
else
retry_count=$((retry_count + 1))
if [ $retry_count -lt $max_retries ]; then
echo "Docker build failed, waiting ${delay}s before retry..."
sleep $delay
else
echo "Docker build failed after $max_retries attempts"
exit 1
fi
fi
done
mkdir -p dist
mv -v build/*.deb dist/
ls -lh dist
- name: Build & Test x86_64 RPM using Rocky Linux
run: |
docker run --rm \
-e HOST_UID="${{ env.HOST_UID }}" \
-e HOST_GID="${{ env.HOST_GID }}" \
-v "${{ github.workspace }}:/workspace" \
-w /workspace \
quay.io/rockylinux/rockylinux:8 \
/bin/bash -c "
set -euo pipefail
yum -y install gcc make rpm-build git autoconf automake \
libtool pkgconfig pciutils-devel libusb1-devel fuse-devel && \
git config --global --add safe.directory /workspace && \
ARCH=x86_64 CFLAGS="-fno-lto" LDFLAGS="-fno-lto" \
./scripts/build-rpm && \
yum localinstall -y /workspace/rpmbuild/RPMS/x86_64/*.rpm && \
echo 'Running rshim --version:' && \
rshim --version && \
chown -R \$HOST_UID:\$HOST_GID /workspace
"
mkdir -p dist
mv -v $(find rpmbuild/RPMS -name '*.rpm') dist/
ls -lh dist
- name: Build & Test arm64 RPM using Rocky Linux
run: |
set -euo pipefail
# Prepare QEMU for ARM64 emulation
docker run --rm --privileged multiarch/qemu-user-static \
--reset -p yes
# Retry function for Docker build
retry_count=0
max_retries=3
delay=20
while true; do
echo "Docker build attempt $((retry_count + 1))/$max_retries"
if docker run --rm --platform linux/arm64 \
-e HOST_UID="${{ env.HOST_UID }}" \
-e HOST_GID="${{ env.HOST_GID }}" \
-v "${{ github.workspace }}:/workspace" \
-w /workspace \
quay.io/rockylinux/rockylinux:8 \
/bin/bash -c "
set -euo pipefail
yum -y install gcc make rpm-build git autoconf automake \
libtool pkgconfig pciutils-devel libusb1-devel fuse-devel && \
git config --global --add safe.directory /workspace && \
ARCH=aarch64 CFLAGS=\"-fno-lto\" LDFLAGS=\"-fno-lto\" \
./scripts/build-rpm && \
yum localinstall -y /workspace/rpmbuild/RPMS/aarch64/*.rpm && \
echo 'Running rshim --version:' && \
rshim --version && \
chown -R \$HOST_UID:\$HOST_GID /workspace
"; then
echo "Docker build succeeded on attempt $((retry_count + 1))"
break
else
retry_count=$((retry_count + 1))
if [ $retry_count -lt $max_retries ]; then
echo "Docker build failed, waiting ${delay}s before retry..."
sleep $delay
else
echo "Docker build failed after $max_retries attempts"
exit 1
fi
fi
done
mkdir -p dist
mv -v $(find rpmbuild/RPMS -name '*.rpm') dist/
ls -lh dist
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: rshim-packages
path: dist/*
- name: Create GitHub Release
if: startsWith(github.ref_name, 'rshim-')
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.body }}
draft: false
prerelease: false
files: dist/*