Update rshim.spec.in to include additional build requirements libusb,… #96
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| # | |
| # 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 | |
| sudo apt-get update || retry_apt_get_update && \ | |
| sudo apt-get install -y \ | |
| build-essential debhelper devscripts fakeroot git \ | |
| libpci-dev libusb-1.0-0-dev libfuse-dev pkg-config | |
| - 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 | |
| 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 | |
| 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/* |