From ff37635ed09e1d9b198687172752a1aba7459c1e Mon Sep 17 00:00:00 2001 From: phlax Date: Sun, 16 Apr 2023 22:58:57 +0100 Subject: [PATCH] ci: Dont stamp Envoy binary in Pull Requests (#26776) Fix #26632 Signed-off-by: Ryan Northey --- .azure-pipelines/bazel.yml | 3 +++ .bazelrc | 4 ++++ bazel/get_workspace_status | 13 +++++++++---- ci/run_envoy_docker.sh | 1 + 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.azure-pipelines/bazel.yml b/.azure-pipelines/bazel.yml index 0963e825e8d8..fd3af0d60c55 100644 --- a/.azure-pipelines/bazel.yml +++ b/.azure-pipelines/bazel.yml @@ -98,6 +98,9 @@ steps: AZP_TARGET_BRANCH: "origin/$(System.PullRequest.TargetBranch)" ${{ if ne(variables['Build.Reason'], 'PullRequest') }}: AZP_TARGET_BRANCH: "origin/$(Build.SourceBranchName)" + ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: + # sha1sum of `ENVOY_PULL_REQUEST` + BAZEL_FAKE_SCM_REVISION: e3b4a6e9570da15ac1caffdded17a8bebdc7dfc9 ${{ if parameters.rbe }}: GCP_SERVICE_ACCOUNT_KEY: $(GcpServiceAccountKey) ENVOY_RBE: "1" diff --git a/.bazelrc b/.bazelrc index 44716f4baa91..695c1bd2eb00 100644 --- a/.bazelrc +++ b/.bazelrc @@ -33,6 +33,10 @@ build --action_env=PATH --host_action_env=PATH # Requires setting `BAZEL_VOLATILE_DIRTY` in the env. build --action_env=BAZEL_VOLATILE_DIRTY --host_action_env=BAZEL_VOLATILE_DIRTY +# Prevent stamped caches from busting (eg in PRs) +# Requires setting `BAZEL_FAKE_SCM_REVISION` in the env. +build --action_env=BAZEL_FAKE_SCM_REVISION --host_action_env=BAZEL_FAKE_SCM_REVISION + build --enable_platform_specific_config build --test_summary=terse diff --git a/bazel/get_workspace_status b/bazel/get_workspace_status index 203f23fde0c4..ca5159e6dea9 100755 --- a/bazel/get_workspace_status +++ b/bazel/get_workspace_status @@ -28,10 +28,15 @@ then exit 0 fi -# The code below presents an implementation that works for git repository -git_rev=$(git rev-parse HEAD) || exit 1 -echo "BUILD_SCM_REVISION ${git_rev}" -echo "STABLE_BUILD_SCM_REVISION ${git_rev}" +if [[ -n "$BAZEL_FAKE_SCM_REVISION" ]]; then + echo "BUILD_SCM_REVISION $BAZEL_FAKE_SCM_REVISION" + echo "STABLE_BUILD_SCM_REVISION $BAZEL_FAKE_SCM_REVISION" +else + # The code below presents an implementation that works for git repository + git_rev=$(git rev-parse HEAD) || exit 1 + echo "BUILD_SCM_REVISION ${git_rev}" + echo "STABLE_BUILD_SCM_REVISION ${git_rev}" +fi # If BAZEL_VOLATILE_DIRTY is set then stamped builds will rebuild uncached when # either a tracked file changes or an untracked file is added or removed. diff --git a/ci/run_envoy_docker.sh b/ci/run_envoy_docker.sh index 3be3ec31c7bc..f4c93673f161 100755 --- a/ci/run_envoy_docker.sh +++ b/ci/run_envoy_docker.sh @@ -103,6 +103,7 @@ docker run --rm \ -e BAZEL_STARTUP_OPTIONS \ -e BAZEL_BUILD_EXTRA_OPTIONS \ -e BAZEL_EXTRA_TEST_OPTIONS \ + -e BAZEL_FAKE_SCM_REVISION \ -e BAZEL_REMOTE_CACHE \ -e ENVOY_STDLIB \ -e BUILD_REASON \