Skip to content

Commit

Permalink
chore: release brew bottles and formula from OSS repository (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed Apr 9, 2023
1 parent 3453896 commit bf0e5c7
Show file tree
Hide file tree
Showing 37 changed files with 1,903 additions and 22 deletions.
6 changes: 5 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ build --incompatible_strict_action_env

test --keep_going
test --test_output=errors
test --@io_bazel_rules_go//go/config:race

# Don't try and auto detect the cc toolchain, as we use our own gcc toolchains.
build --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
build --incompatible_strict_action_env=true
build --incompatible_enable_cc_toolchain_resolution
8 changes: 7 additions & 1 deletion .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
# Number of commits to fetch. 0 indicates all history for all branches and tags. This is
# needed since if we don't fetch tags then the workspace status command fails to set
# STABLE_BUILD_SCM_TAG which causes the //release/brew/tests:version_file_with_stamp_test
# test to fail as it depends on that stamp value. See https://github.com/actions/checkout.
fetch-depth: 0
- name: Validate changed files
if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'allow sdk change')
run: ./.github/workflows/validate_changed_files.sh
Expand Down
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ npm_link_all_packages(name = "node_modules")
exports_files([
".bazelversion",
"LICENSE",
"README.md",
])

nogo(
Expand Down
55 changes: 53 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,61 @@ After this, you should be able to merge your changes without any conflicts in th
undesirable complication. For now with CLI major releases as `5.x.x` the corresponding go module
version should be `v1.5xx.x` with the patch version matching and the minor zero-padded to two digits.
(e.g. `5.4.3` -> `v1.504.3`, `5.56.78` -> `v1.556.78`)
When the CLI major version is bumped to 6, this mapping will need to be updated.

When the CLI major version is bumped to 6, this mapping will need to be updated.

```
git tag v1.5xx.x
git push origin $!
```

4. Update Homebrew Formula

Once the GitHub release is complete and Aspect CLI release artifacts are available for download,
follow the [instructions](https://github.com/aspect-build/homebrew-aspect#updating-formulas-to-the-latest-release)
in our [homebrew-aspect](https://github.com/aspect-build/homebrew-aspect) repository to update the
Homebrew Formulas in the `aspect-build/aspect` tap.

## Test Homebrew Formula and Bottles

### Install and Configure `nginx`

Install `nginx`. On MacOS, run `brew install nginx`.

Change the `nginx` config so that it listens on part `8090`. By default, `nginx` will listen on
`localhost:8080`.

- Find the location of your `nginx` config, run `nginx -t`.
- Update the default server stanza to listen on `8090`. It should look like the following:

```
server {
listen 8090;
server_name localhost;
```

- Restart `nginx`. Run `brew services restart nginx`.

### Build, Stage, and Install Aspect CLI with Homebrew

To verify that the built Homebrew formula and bottles build and install properly,
please run the following:

```sh
$ bazel run //release:verify_homebrew_artifacts
```

This will build the artifacts, copy the bottles to your local `nginx` webserver's
serving directory, create an `aspect-build/aspect` tap, copy the formula to the
tap, install the bottle for your system, and verify that the version from the
CLI matches the expected version.

NOTE: This is not a test target, because it will copy files to various locations on your local
machine. The default permissions for a test target do not allow this.

If you would like to perform the set up for this verification step without the assertions, you can
run the following (with or without the `--stamp` flag):

```sh
$ bazel run //release:stage_for_dev
```
99 changes: 92 additions & 7 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,56 @@ http_archive(
],
)

http_archive(
name = "aspect_gcc_toolchain",
sha256 = "3341394b1376fb96a87ac3ca01c582f7f18e7dc5e16e8cf40880a31dd7ac0e1e",
strip_prefix = "gcc-toolchain-0.4.2",
urls = ["https://github.com/aspect-build/gcc-toolchain/archive/refs/tags/0.4.2.tar.gz"],
)

http_archive(
name = "com_grail_bazel_toolchain",
patch_args = ["-p1"],
patches = ["//patches:com_grail_bazel_toolchain.patch"],
sha256 = "b54aa3b00a64a3dea06d30f0ff423e91bcea43019c5ff1c319f726f1666c3ff2",
strip_prefix = "bazel-toolchain-2f6e6adf93f4bf34d7bce7ad797f53c82d998ba8",
urls = ["https://github.com/grailbio/bazel-toolchain/archive/2f6e6adf93f4bf34d7bce7ad797f53c82d998ba8.tar.gz"],
)

_SYSROOT_BUILD_FILE = """
filegroup(
name = "sysroot",
srcs = glob(["*/**"]),
visibility = ["//visibility:public"],
)
"""

http_archive(
name = "org_chromium_sysroot_linux_arm64",
build_file_content = _SYSROOT_BUILD_FILE,
sha256 = "e39b700d8858d18868544c8c84922f6adfa8419f3f42471b92024ba38eff7aca",
urls = ["https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/2202c161310ffde63729f29d27fe7bb24a0bc540/debian_stretch_arm64_sysroot.tar.xz"],
)

http_archive(
name = "org_chromium_sysroot_linux_x86_64",
build_file_content = _SYSROOT_BUILD_FILE,
sha256 = "84656a6df544ecef62169cfe3ab6e41bb4346a62d3ba2a045dc5a0a2ecea94a3",
urls = ["https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/2202c161310ffde63729f29d27fe7bb24a0bc540/debian_stretch_amd64_sysroot.tar.xz"],
)

http_archive(
name = "io_bazel_rules_go",
patch_args = ["-p1"],
patches = ["//patches:rules_go.patch"],
sha256 = "16e9fca53ed6bd4ff4ad76facc9b7b651a89db1689a2877d6fd7b82aa824e366",
urls = ["https://github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip"],
sha256 = "19ef30b21eae581177e0028f6f4b1f54c66467017be33d211ab6fc81da01ea4d",
urls = ["https://github.com/bazelbuild/rules_go/releases/download/v0.38.0/rules_go-v0.38.0.zip"],
)

http_archive(
name = "rules_pkg",
sha256 = "8c20f74bca25d2d442b327ae26768c02cf3c99e93fad0381f32be9aab1967675",
urls = ["https://github.com/bazelbuild/rules_pkg/releases/download/0.8.1/rules_pkg-0.8.1.tar.gz"],
)

load("@io_bazel_rules_go//extras:embed_data_deps.bzl", "go_embed_data_dependencies")
Expand All @@ -52,11 +96,7 @@ go_rules_dependencies()

go_embed_data_dependencies()

go_register_toolchains(
# TODO: re-enable no-go once versions are synced with silo
# nogo = "@//:nogo",
version = "1.19.3",
)
go_register_toolchains(version = "1.20.1")

http_archive(
name = "bazel_gazelle",
Expand Down Expand Up @@ -127,3 +167,48 @@ bats_dependencies()
load("//integration_tests:bazel_binary.bzl", "bazel_binaries")

bazel_binaries()

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")

llvm_toolchain(
name = "llvm_toolchain",
llvm_version = "15.0.7",
sha256 = {
"darwin-arm64": "867c6afd41158c132ef05a8f1ddaecf476a26b91c85def8e124414f9a9ba188d",
"darwin-x86_64": "d16b6d536364c5bec6583d12dd7e6cf841b9f508c4430d9ee886726bd9983f1c",
},
strip_prefix = {
"darwin-arm64": "clang+llvm-15.0.7-arm64-apple-darwin22.0",
"darwin-x86_64": "clang+llvm-15.0.7-x86_64-apple-darwin21.0",
},
sysroot = {
"linux-aarch64": "@org_chromium_sysroot_linux_arm64//:sysroot",
"linux-x86_64": "@org_chromium_sysroot_linux_x86_64//:sysroot",
},
urls = {
"darwin-arm64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/clang+llvm-15.0.7-arm64-apple-darwin22.0.tar.xz"],
"darwin-x86_64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/clang+llvm-15.0.7-x86_64-apple-darwin21.0.tar.xz"],
},
)

register_toolchains("//platforms/toolchains:llvm")

load("@aspect_gcc_toolchain//toolchain:repositories.bzl", "gcc_toolchain_dependencies")

gcc_toolchain_dependencies()

load("@aspect_gcc_toolchain//toolchain:defs.bzl", "ARCHS", "gcc_register_toolchain")

gcc_register_toolchain(
name = "gcc_toolchain_aarch64",
target_arch = ARCHS.aarch64,
)

gcc_register_toolchain(
name = "gcc_toolchain_x86_64",
target_arch = ARCHS.x86_64,
)
2 changes: 1 addition & 1 deletion bazel/analysis/analysis_v2.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bazel/buildeventstream/build_event_stream.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bazel/command_line/command_line.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bazel/failure_details/failure_details.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bazel/flags/flags.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bazel/invocation_policy/invocation_policy.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bazel/options/option_filters.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bazel/query/build.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions patches/com_grail_bazel_toolchain.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
diff --git a/toolchain/cc_toolchain_config.bzl b/toolchain/cc_toolchain_config.bzl
index 8785a8e..5e84644 100644
--- a/toolchain/cc_toolchain_config.bzl
+++ b/toolchain/cc_toolchain_config.bzl
@@ -60,6 +60,15 @@ def cc_toolchain_config(
abi_version,
abi_libc_version,
) = {
+ "darwin-arm64": (
+ "clang-arm64-darwin",
+ "arm64-apple-macosx",
+ "darwin",
+ "macosx",
+ "clang",
+ "darwin_arm64",
+ "darwin_arm64",
+ ),
"darwin-x86_64": (
"clang-x86_64-darwin",
"x86_64-apple-macosx",
diff --git a/toolchain/internal/common.bzl b/toolchain/internal/common.bzl
index 7493c64..eefb7d3 100644
--- a/toolchain/internal/common.bzl
+++ b/toolchain/internal/common.bzl
@@ -12,7 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

-SUPPORTED_TARGETS = [("linux", "x86_64"), ("linux", "aarch64"), ("darwin", "x86_64")]
+SUPPORTED_TARGETS = [
+ ("darwin", "arm64"),
+ ("darwin", "x86_64"),
+ ("linux", "aarch64"),
+ ("linux", "x86_64"),
+]

host_tool_features = struct(
SUPPORTS_ARG_FILE = "supports_arg_file",
2 changes: 1 addition & 1 deletion pkg/plugin/sdk/v1alpha1/proto/plugin.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/plugin/sdk/v1alpha2/proto/plugin.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/plugin/sdk/v1alpha3/proto/plugin.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bf0e5c7

Please sign in to comment.