Skip to content

Commit

Permalink
ci: Dont stamp Envoy binary in Pull Requests (#26776)
Browse files Browse the repository at this point in the history
Fix #26632

Signed-off-by: Ryan Northey <ryan@synca.io>
  • Loading branch information
phlax authored Apr 16, 2023
1 parent 8e4835e commit ff37635
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .azure-pipelines/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 9 additions & 4 deletions bazel/get_workspace_status
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions ci/run_envoy_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit ff37635

Please sign in to comment.