Skip to content

Commit b55a37c

Browse files
Use release archive for examples (#2614)
This gives us quicker feedback on if the release archive works. It also removes the need for a separate CI job. --------- Signed-off-by: Brentley Jones <github@brentleyjones.com>
1 parent 4fc5c56 commit b55a37c

File tree

11 files changed

+119
-85
lines changed

11 files changed

+119
-85
lines changed

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/.bcr/ @MobileNativeFoundation/rules_xcodeproj-maintainers-release
77
/distribution/ @MobileNativeFoundation/rules_xcodeproj-maintainers-release
88
/MODULE.bazel @MobileNativeFoundation/rules_xcodeproj-maintainers-release
9-
/tools/bazel @MobileNativeFoundation/rules_xcodeproj-maintainers-release
9+
tools/bazel @MobileNativeFoundation/rules_xcodeproj-maintainers-release
1010
/xcodeproj/repositories.bzl @MobileNativeFoundation/rules_xcodeproj-maintainers-release
1111

1212
# Admin

buildbuddy.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ x_templates:
4646
- examples/sanitizers/setup-bazel-output-base
4747

4848
commands:
49-
- &set_release_archive_override "--output_base=setup-bazel-output-base run --config=workflows @rules_xcodeproj//tools:set_release_archive_override"
5049
- &validate_integration "--output_base=bazel-output-base run --config=workflows //test/fixtures:validate"
5150
- &build_all "--output_base=bazel-output-base build --config=workflows //..."
5251
- &test_all "--output_base=bazel-output-base test --config=workflows //test/..."
@@ -149,13 +148,3 @@ actions:
149148
# bazel_commands:
150149
# - *validate_integration
151150
# - *build_all
152-
153-
- name: Validate release.tar.gz
154-
<<: *bazel_in_repo_version
155-
<<: *arm64
156-
<<: *normal_resources
157-
<<: *action_base
158-
<<: *examples_integration_workspace
159-
bazel_commands:
160-
- *set_release_archive_override
161-
- run --config=workflows //:xcodeproj-bazel-sim_arm64

distribution/BUILD

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,23 @@ pkg_tar(
5454
strip_prefix = "/",
5555
tags = ["manual"],
5656
)
57+
58+
genrule(
59+
name = "expanded_release_pkg",
60+
srcs = [":release_pkg"],
61+
outs = ["expanded_release"],
62+
cmd = """\
63+
set -euo pipefail
64+
65+
mkdir "$@"
66+
tar -xf $< -C "$@"
67+
touch "$@/WORKSPACE"
68+
""",
69+
tags = ["manual"],
70+
)
71+
72+
opt_wrapper(
73+
name = "opt_expanded_release_pkg",
74+
dep = ":expanded_release_pkg",
75+
tags = ["manual"],
76+
)

examples/integration/MODULE.bazel

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
bazel_dep(
22
name = "rules_xcodeproj",
3+
# Set to the real version with `--override_module`
34
version = "0.0.0",
45
)
56
bazel_dep(
@@ -33,11 +34,6 @@ bazel_dep(
3334

3435
bazel_dep(name = "bazel_features", version = "1.0.0", dev_dependency = True)
3536

36-
local_path_override(
37-
module_name = "rules_xcodeproj",
38-
path = "../..",
39-
)
40-
4137
local_path_override(
4238
module_name = "examples_cc_external",
4339
path = "cc/external",

examples/integration/tools/bazel

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/integration/tools/bazel

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
readonly tool_location="${BASH_SOURCE[0]}"
6+
readonly workspace_dir="${tool_location%/*/*}"
7+
readonly root_dir="${workspace_dir%/*/*}"
8+
readonly archive_output_base="$workspace_dir/bazel-output-base/release_archive"
9+
readonly override_bazelrc="$archive_output_base/override.bazelrc"
10+
11+
# Don't update the release archive if doing a build inside of Xcode, or if we
12+
# are in the inner-bazel invocation
13+
if [[ -z "${BUILD_WORKSPACE_DIRECTORY:-}" ]]; then
14+
# Update release archive
15+
16+
echo "Building expanded release.tar.gz" >&2
17+
pushd "$root_dir" > /dev/null
18+
19+
# Ensure that we use bazelisk with `.bazelversion`, not whatever is being used
20+
# in the currenct command
21+
ppid=$(ps -o ppid= $$)
22+
bazelisk=$(ps -ewwo comm= "${ppid// /}")
23+
global_bazel=$(env PATH=/opt/homebrew/bin:/usr/local/bin /usr/bin/which "$bazelisk")
24+
readonly root_bazel=(
25+
env
26+
BAZEL_REAL=
27+
BAZELISK_SKIP_WRAPPER=
28+
USE_BAZEL_VERSION=
29+
PATH=/bin:/usr/bin
30+
"$global_bazel"
31+
)
32+
33+
"${root_bazel[@]}" \
34+
"--output_base=$archive_output_base" \
35+
build \
36+
//distribution:opt_expanded_release_pkg
37+
38+
if [[ $(uname -m) == "arm64" ]]; then
39+
repository_override="$archive_output_base/execroot/_main/bazel-out/darwin_arm64-opt/bin/distribution/expanded_release"
40+
else
41+
repository_override="$archive_output_base/execroot/_main/bazel-out/darwin-opt/bin/distribution/expanded_release"
42+
fi
43+
cat > "$override_bazelrc" <<EOF
44+
common --override_repository=rules_xcodeproj=$repository_override
45+
common --override_module=rules_xcodeproj=$repository_override
46+
EOF
47+
48+
popd > /dev/null
49+
50+
# Execute command
51+
52+
echo
53+
echo "Executing bazel command" >&2
54+
fi
55+
56+
57+
bazel_version=$("$BAZEL_REAL" info release | /usr/bin/cut -d ' ' -f 2 | /usr/bin/cut -d '.' -f 1)
58+
if [[ "$bazel_version" == "version" ]]; then
59+
bazel_version=7
60+
fi
61+
62+
flags=("--noworkspace_rc")
63+
64+
readonly root_version_bazelrc="$root_dir/bazel_$bazel_version.bazelrc"
65+
if [[ -s "$root_version_bazelrc" ]]; then
66+
flags+=("--bazelrc=$root_version_bazelrc")
67+
fi
68+
69+
readonly workspace_version_bazelrc="$workspace_dir/bazel_$bazel_version.bazelrc"
70+
if [[ -s "$workspace_version_bazelrc" ]]; then
71+
flags+=("--bazelrc=$workspace_version_bazelrc")
72+
fi
73+
74+
readonly workspace_bazelrc="$workspace_dir/.bazelrc"
75+
if [[ -s "$workspace_bazelrc" ]]; then
76+
flags+=("--bazelrc=$workspace_bazelrc")
77+
fi
78+
79+
flags+=("--bazelrc=$override_bazelrc")
80+
81+
exec "$BAZEL_REAL" "${flags[@]}" "$@"

examples/rules_ios/tools/bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../tools/bazel
1+
../../integration/tools/bazel

examples/sanitizers/tools/bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../tools/bazel
1+
../../integration/tools/bazel

shared.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Opt into future migrations
22
build --experimental_strict_conflict_checks
33
build --incompatible_disallow_empty_glob
4+
5+
# Don't create convenience symlinks
46
build --experimental_convenience_symlinks=ignore
57

68
# Use Bzlmod

tools/BUILD

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,6 @@ xcodeproj(
285285

286286
# Release
287287

288-
sh_binary(
289-
name = "set_release_archive_override",
290-
srcs = ["set_release_archive_override.sh"],
291-
tags = ["manual"],
292-
)
293-
294288
filegroup(
295289
name = "release_files",
296290
srcs = [

0 commit comments

Comments
 (0)