Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): always build with -c opt #555

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ build --embed_label=v1.2.3
# Mock versioning command to test the --stamp behavior
build --workspace_status_command="echo BUILD_SCM_VERSION 1.2.3"

# For releasing, use --workspace_status_command and stamp
# before adding more flags to the release config make sure it does not
# affect the hashes of /tools. See tools/release.bzl for opt transition
# add appropriate commandline transition there to match the configuration.
common:release --workspace_status_command "${PWD}/workspace_status.sh"
common:release -c opt
common:release --stamp
common --compilation_mode opt

# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`.
# This file should appear in `.gitignore` so that settings are not shared with team members. This
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@ jobs:
env:
# Bazelisk will download bazel to here
XDG_CACHE_HOME: ~/.cache/bazel-repo
# Warning: DO NOT drop --config=release as it ensures that tools/integrity.bzl is up-to-date with release config.
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //... --config=release
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //...
- name: Build release artifacts
run: |
if [ -n "$(git status --porcelain)" ]; then
>&2 echo "ERROR: the git state is not clean, aborting build..."
exit 1
fi
rm -rf /tmp/aspect/release
bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc run --config=release //tools:release -- /tmp/aspect/release
bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc run //tools:release -- /tmp/aspect/release
if /tmp/aspect/release/copy_to_directory-linux_amd64 version | grep '(with local changes)'; then
>&2 echo "ERROR: the release contained changes in the git state and the release will not be produced"
exit 1
Expand Down
35 changes: 2 additions & 33 deletions tools/release.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,6 @@ PLATFORMS = [
struct(os = "windows", arch = "amd64", ext = ".exe", gc_linkopts = []),
]

def _compilation_mode_transition_impl(settings, attr):
# buildifier: disable=unused-variable
_ignore = (settings, attr)
return {"//command_line_option:compilation_mode": "opt"}

compilation_mode_transition = transition(
implementation = _compilation_mode_transition_impl,
inputs = [],
outputs = ["//command_line_option:compilation_mode"],
)

def _compilation_mode_transition_rule_impl(ctx):
runfiles = ctx.runfiles().merge_all([target[DefaultInfo].default_runfiles for target in ctx.attr.targets])

return DefaultInfo(
files = depset(ctx.files.targets),
runfiles = runfiles,
)

compilation_mode_transition_rule = rule(
implementation = _compilation_mode_transition_rule_impl,
attrs = {
"targets": attr.label_list(),
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
cfg = compilation_mode_transition,
)

def multi_platform_go_binaries(name, embed, prefix = "", **kwargs):
"""The multi_platform_go_binaries macro creates a go_binary for each platform.

Expand Down Expand Up @@ -79,10 +49,9 @@ def multi_platform_go_binaries(name, embed, prefix = "", **kwargs):
)
targets.extend([target_label, hashes_label])

# binaries should always be compiled in opt mode as it affects the hashes.
compilation_mode_transition_rule(
native.filegroup(
name = name,
targets = targets,
srcs = targets,
**kwargs
)

Expand Down
27 changes: 0 additions & 27 deletions workspace_status.sh

This file was deleted.

Loading