From 12eea11f9300264f3728bfe8ef4a98493441df7b Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 25 Jun 2021 05:18:15 +0000 Subject: [PATCH] Add entrypoint to run CI locally (backport #18131) (#18216) * ci: use versioned cargo wrapper for crate ordering (cherry picked from commit 554002b73cc16130a723ed9bc39494b772e1fea5) * ci: nvidia persistence mode isn't a hard requirement (cherry picked from commit f213e48067a38e1c93d45e4de190201060990777) * sdk: ensure `ld` can find criterion when running BPF tests (cherry picked from commit 7ee39fcb0f9e77cf3e0a6d7ba50f6b39de799475) * ci: give localnet nodes a more time to startup (cherry picked from commit 278a241db33491241d74ff63c2f1773f5a6c7a6b) * ci: add downstream build wrapper (cherry picked from commit 761e3249821d3fbb1e58151fc6c4093e8d0e6fa5) * ci: add wrapper script for running ci locally Linux only for now (cherry picked from commit 0bc38153ca0e5160915c59f1148fb8efffbbd856) Co-authored-by: Trent Nelson --- ci/env.sh | 5 ++- ci/localnet-sanity.sh | 2 +- ci/order-crates-for-publishing.py | 8 +++-- ci/run-local.sh | 54 +++++++++++++++++++++++++++++++ ci/test-downstream-builds.sh | 9 ++++++ ci/test-stable.sh | 2 +- sdk/bpf/c/bpf.mk | 1 + 7 files changed, 76 insertions(+), 5 deletions(-) create mode 100755 ci/run-local.sh create mode 100755 ci/test-downstream-builds.sh diff --git a/ci/env.sh b/ci/env.sh index d075b25999..df7ed1ce6a 100644 --- a/ci/env.sh +++ b/ci/env.sh @@ -74,10 +74,13 @@ else export CI_BUILD_ID= export CI_COMMIT= export CI_JOB_ID= - export CI_OS_NAME= export CI_PULL_REQUEST= export CI_REPO_SLUG= export CI_TAG= + # Don't override ci/run-local.sh + if [[ -z $CL_LOCAL_RUN ]]; then + export CI_OS_NAME= + fi fi cat <&2 + exit 1 + ;; +esac + +steps=() +steps+=(test-sanity) +steps+=(shellcheck) +steps+=(test-checks) +steps+=(test-coverage) +steps+=(test-stable) +steps+=(test-stable-perf) +steps+=(test-downstream-builds) +steps+=(test-bench) +steps+=(test-local-cluster) + +step_index=0 +if [[ -n "$1" ]]; then + start_step="$1" + while [[ $step_index -lt ${#steps[@]} ]]; do + step="${steps[$step_index]}" + if [[ "$step" = "$start_step" ]]; then + break + fi + step_index=$((step_index + 1)) + done + if [[ $step_index -eq ${#steps[@]} ]]; then + echo "unexpected start step: \"$start_step\"" 1>&2 + exit 1 + else + echo "** starting at step: \"$start_step\" **" + echo + fi +fi + +while [[ $step_index -lt ${#steps[@]} ]]; do + step="${steps[$step_index]}" + cmd="ci/${step}.sh" + $cmd + step_index=$((step_index + 1)) +done diff --git a/ci/test-downstream-builds.sh b/ci/test-downstream-builds.sh new file mode 100755 index 0000000000..0a45db80d2 --- /dev/null +++ b/ci/test-downstream-builds.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +cd "$(dirname "$0")/.." + +export CI_LOCAL_RUN=true + +set -ex + +scripts/build-downstream-projects.sh diff --git a/ci/test-stable.sh b/ci/test-stable.sh index 1d7cbc1bce..46032eb238 100755 --- a/ci/test-stable.sh +++ b/ci/test-stable.sh @@ -57,7 +57,7 @@ test-stable-perf) # Enable persistence mode to keep the CUDA kernel driver loaded, avoiding a # lengthy and unexpected delay the first time CUDA is involved when the driver # is not yet loaded. - sudo --non-interactive ./net/scripts/enable-nvidia-persistence-mode.sh + sudo --non-interactive ./net/scripts/enable-nvidia-persistence-mode.sh || true rm -rf target/perf-libs ./fetch-perf-libs.sh diff --git a/sdk/bpf/c/bpf.mk b/sdk/bpf/c/bpf.mk index 3f850d988e..83b722fdd1 100644 --- a/sdk/bpf/c/bpf.mk +++ b/sdk/bpf/c/bpf.mk @@ -191,6 +191,7 @@ endef define TEST_EXEC_RULE $1: $2 + LD_LIBRARY_PATH=$(TESTFRAMEWORK_RPATH) \ $2$(\n) endef