diff --git a/projects/rdc/.github/workflows/main.yml b/projects/rdc/.github/workflows/main.yml new file mode 100644 index 0000000000..d719d2feeb --- /dev/null +++ b/projects/rdc/.github/workflows/main.yml @@ -0,0 +1,180 @@ +name: Build RDC + +on: + pull_request: + branches: [ 'dgalants/ci', 'amd-staging', 'amd-mainline' ] + workflow_dispatch: + +env: + DEBIAN_FRONTEND: noninteractive + DEBCONF_NONINTERACTIVE_SEEN: true + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: RelWithDebInfo + ROCM_DIR: /opt/rocm + # Use secrets for internal URLs + JOB_NAME: ${{ secrets.JOB_NAME }} + AMDGPU_REPO_DEB: ${{ secrets.AMDGPU_REPO_DEB }} + AMDGPU_REPO_URL: ${{ secrets.AMDGPU_REPO_URL }} + ROCM_CI_URL: ${{ secrets.ROCM_CI_URL }} + # Set env vars to values of config vars + env_var: ${{ vars.ENV_CONTEXT_VAR }} + +jobs: + build: + runs-on: lstt + container: rocm/rocm-build-ubuntu-22.04:6.2 + outputs: + BUILD_NUM: ${{ steps.build_number.outputs.BUILD_NUM }} + TODAY: ${{ steps.build_number.outputs.TODAY }} + + steps: + - uses: actions/checkout@v3 + + - name: Set up apt repos + run: | + cat /etc/os-release + apt update -y + # provides add-apt-repository and support for caching actions + apt install -y software-properties-common jq nodejs + add-apt-repository -y ppa:apt-fast/stable + apt update -y + apt install -y apt-fast + # provides amdgpu-repo + wget "$AMDGPU_REPO_URL/$AMDGPU_REPO_DEB" + apt-fast install -y "./$AMDGPU_REPO_DEB" + + - name: Get latest build number + id: build_number + run: | + curl -Ls "${ROCM_CI_URL}/${JOB_NAME}/lastStableBuild/api/json?depth=1" -o /tmp/build_info.json + cat /tmp/build_info.json | jq '.actions[] | .buildsByBranchName."refs/remotes/origin/amd-master".buildNumber | select(. != null)' > /tmp/build_num.txt + BUILD_NUM="$(cat /tmp/build_num.txt)" + echo "BUILD_NUM=$BUILD_NUM" >> "$GITHUB_ENV" + echo "BUILD_NUM=$BUILD_NUM" >> "$GITHUB_OUTPUT" + amdgpu-repo --rocm-build="$JOB_NAME"/"$BUILD_NUM" + apt-fast update -y + # useful for date-based caches + TODAY="$(date +%Y_%m_%d)" + echo "TODAY=$TODAY" >> "$GITHUB_ENV" + echo "TODAY=$TODAY" >> "$GITHUB_OUTPUT" + + + - name: Get apt packages + run: | + apt install -y \ + rocm-core \ + amd-smi-lib \ + rocblas \ + rocblas-dev \ + rocm-developer-tools \ + rocm-device-libs \ + rocm-smi-lib \ + rocm-validation-suite \ + rocprofiler-dev \ + build-essential \ + ccache \ + cmake \ + curl \ + git \ + gzip \ + jq \ + libcap-dev \ + tar \ + unzip \ + wget \ + zip \ + zstd + + - name: Cache .ccache + uses: actions/cache@v4 + with: + path: ~/.cache/ccache + # only create one cache per day to save time during upload + key: ${{ runner.os }}-ccache-${{ github.ref_name }}-${{ env.TODAY }} + restore-keys: | + ${{ runner.os }}-ccache-${{ github.ref_name }}- + ${{ runner.os }}-ccache- + + - name: Build RDC + run: | + pwd + cmake \ + -B build \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -DGRPC_ROOT=/usr/grpc \ + -DBUILD_RUNTIME=ON \ + -DBUILD_PROFILER=ON \ + -DBUILD_RVS=OFF \ + -DBUILD_TESTS=ON \ + -DCPACK_GENERATOR="DEB" \ + -DCMAKE_INSTALL_PREFIX=${ROCM_DIR} + make -C build -j $(nproc) + make -C build -j $(nproc) package + + - name: Install RDC + run: | + echo "pre: " + ls -lah /opt + make -C build -j $(nproc) install + echo "post: " + ls -lah /opt + + # important to use v3 because v4 doesn't work with act: + # https://github.com/nektos/act/issues/329 + - name: Package RDC + uses: actions/upload-artifact@v3 + with: + name: rdc + path: build/rdc*.deb + if-no-files-found: error + retention-days: 5 + + test: + needs: build + runs-on: lstt + container: rocm/rocm-build-ubuntu-22.04:6.2 + + steps: + - name: Set up apt repos + run: | + cat /etc/os-release + apt update -y + # provides add-apt-repository and support for caching actions + apt install -y software-properties-common jq nodejs + + - name: Package RDC + uses: actions/download-artifact@v3 + with: + name: rdc + path: /opt/ + + - name: Test RDC installation + shell: bash + run: | + COUNT=$(find /opt/ -iname 'rdc*.deb' | wc -l) + test "$COUNT" -eq '2' + dpkg --force-all -i /opt/rdc*.deb + # confirm binaries are installed + find $ROCM_DIR/bin -maxdepth 1 -iname rdcd + find $ROCM_DIR/bin -maxdepth 1 -iname rdci + find $ROCM_DIR/share/rdc -iname rdctst + # confirm that libraries are installed + MISSING_LIBS=() + for lib in librdc.so librdc_bootstrap.so librdc_client.so; do + test -e "$ROCM_DIR/lib/$lib" || MISSING_LIBS+=("$lib") + done + for lib in librdc_rocr.so librdc_rocp.so; do + test -e "$ROCM_DIR/lib/rdc/$lib" || MISSING_LIBS+=("$lib") + done + + if test "${#MISSING_LIBS[@]}" != "0"; then + echo "Missing libs found!" + for lib in "${MISSING_LIBS[@]}"; do + echo "- $lib" + done + exit 1 + else + echo "No missing libs found!" + fi diff --git a/projects/rdc/.gitignore b/projects/rdc/.gitignore index c3b5513cff..d8d9aff444 100644 --- a/projects/rdc/.gitignore +++ b/projects/rdc/.gitignore @@ -25,3 +25,7 @@ docs/_doxygen/ # misc __pycache__/ authentication/CA/ + +# act +act.variables +act.secrets diff --git a/projects/rdc/run_github_actions_locally.sh b/projects/rdc/run_github_actions_locally.sh new file mode 100755 index 0000000000..396d29f891 --- /dev/null +++ b/projects/rdc/run_github_actions_locally.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +# This program runs github actions locally using 'act' +# All arguments given to this script are passed to act itself + +set -eu +set -o pipefail + +REMOTE_NAME="${REMOTE_NAME:-origin}" +CONTAINER="${CONTAINER:-ubuntu}" + +# act will use this file if it exists for secrets +SECRETS_FILE="${SECRETS_FILE:-act.secrets}" + +if ! git remote | grep -q "$REMOTE_NAME"; then + echo "ERROR: Remote '$REMOTE_NAME' does not exist!" + echo "Set remote like so: + REMOTE_NAME=myremote $0" + exit 1 +fi + +if ! command -v act > /dev/null; then + echo "ERROR: 'act' not found!" + echo "Please install act from the link below:" + echo "https://github.com/nektos/act" + exit 1 +fi + +# build arguments array for act +args=( + --rm + --remote-name "$REMOTE_NAME" + --artifact-server-path /tmp/artifacts + -P "self-hosted=$CONTAINER" +) + +if test -e "${SECRETS_FILE}"; then + args+=(--secret-file "${SECRETS_FILE}") +fi + +# trace +set -x + +mkdir -p /tmp/artifacts +act "${args[@]}" "$@"