Skip to content

Commit

Permalink
bazel 6.4.0, rules_go v0.45, bazel-gazelle 0.35, more... (#355)
Browse files Browse the repository at this point in the history
* Convert to yaml config
* Vendor timestamp.proto (for ts_proto)
* Switch to proto_gazelle rule
* Fix missing NonEmptyAttrs
* Reset baseline generated rules using proto_gazelle
* Upgrade rules_go, gazelle, go_deps
* Upgrade gazelle to v0.35.0
* Migrate resolver to accomodate bazel-contrib/bazel-gazelle#1687
* checkpoint migrate to protobuf-javascript
* Use java 17, upgrade rules_scala, custom toolchain
* sync scala version
* Upgrade rules_python and add to WORKSPACE boilerplate files
* Add :protobuf_python to example deps
* ensure strings sorted for import labels
* Upgrade rules_go to v0.45.1
* exclude grpc_test.go from default go_test rule
* remove obsolete patch
* Add "make golden_test" target
* ensure reassign memory value
* Update build status badge
* preserve last-wins semantics of prior stackb/rules_proto behavior
* Update release.yaml
  • Loading branch information
pcj authored Feb 13, 2024
1 parent 2fce35e commit ee01b60
Show file tree
Hide file tree
Showing 476 changed files with 7,544 additions and 17,499 deletions.
20 changes: 13 additions & 7 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
common --enable_platform_specific_config

common --jvmopt=-Djava.security.manager=allow
build --java_language_version=17
build --java_runtime_version=remotejdk_17
build --tool_java_language_version=17
build --tool_java_runtime_version=remotejdk_17

common --enable_platform_specific_config
build:windows --cxxopt='/std:c++14'
build:windows --host_cxxopt='/std:c++14'
build:linux --cxxopt='-std=c++14'
build:linux --host_cxxopt='-std=c++14'
build:macos --cxxopt='-std=c++14'
build:macos --host_cxxopt='-std=c++14'
build:freebsd --cxxopt='-std=c++14'
build:freebsd --host_cxxopt='-std=c++14'
build:linux --cxxopt='-std=c++14'
build:linux --host_cxxopt='-std=c++14'
build:macos --cxxopt='-std=c++14'
build:macos --host_cxxopt='-std=c++14'
build:freebsd --cxxopt='-std=c++14'
build:freebsd --host_cxxopt='-std=c++14'

build:bazelci --deleted_packages=docs

Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.4.0
6.4.0
14 changes: 14 additions & 0 deletions .github/workflows/ci.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file contains Bazel settings to apply on CI only.
# It is referenced with a --bazelrc option in the call to bazel in ci.yaml
# Debug where options came from
build --announce_rc
# Don't rely on test logs being easily accessible from the test runner,
# though it makes the log noisier.
test --test_output=errors
# This directory is configured in GitHub actions to be persisted between runs.
build --disk_cache=$HOME/.cache/bazel
build --repository_cache=$HOME/.cache/bazel-repo
# Allows tests to run bazelisk-in-bazel, since this is the cache folder used
test --test_env=XDG_CACHE_HOME
# Keep until @io_bazel_rules_scala is upgraded
build --incompatible_java_common_parameters=false
54 changes: 54 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CI

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [master]
pull_request:
branches: [master]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
test:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v3

- uses: bazelbuild/setup-bazelisk@v2

- name: Mount bazel action cache
uses: actions/cache@v3
if: always()
with:
path: "~/.cache/bazel"
key: bazel

- name: Mount bazel repo cache
uses: actions/cache@v3
if: always()
with:
path: "~/.cache/bazel-repo"
key: bazel-repo

- name: bazel test
env:
# Bazelisk will download bazel to here, ensure it is cached between runs.
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: >-
bazel
--bazelrc=.github/workflows/ci.bazelrc
--bazelrc=.bazelrc
test
--deleted_packages=//plugin/grpc-ecosystem/grpc-gateway
//example/...
//pkg/...
//plugin/...
//language/...
//rules/...
//toolchain/...
44 changes: 44 additions & 0 deletions .github/workflows/format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Format

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
pull_request:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
test:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v3

- uses: bazelbuild/setup-bazelisk@v2

- name: Mount bazel action cache
uses: actions/cache@v2
with:
path: "~/.cache/bazel"
key: bazel

- name: Mount bazel repo cache
uses: actions/cache@v2
with:
path: "~/.cache/bazel-repo"
key: bazel-repo

- name: Run format
env:
# Bazelisk will download bazel to here, ensure it is cached between runs.
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: ./tools/format.sh

- name: Check no changes
run: bash -c "if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then echo >&2 'Please run \`./tools/format.sh\` - Found differences after formatting:' && git diff && exit 1; fi"
31 changes: 31 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Cut a release whenever a new tag is pushed to the repo.
name: Release

on:
push:
tags:
- "v*.*.*"

# Allows owner to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
test:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Prepare workspace snippet
run: .github/workflows/workspace_snippet.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt

- name: Release
uses: softprops/action-gh-release@v1
with:
prerelease: false
# Use GH feature to populate the changelog automatically
generate_release_notes: true
body_path: release_notes.txt
22 changes: 22 additions & 0 deletions .github/workflows/workspace_snippet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -eufo pipefail

# Set by GH actions, see
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
TAG=${GITHUB_REF_NAME}
PREFIX="rules_proto-${TAG:1}"
SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip | shasum -a 256 | awk '{print $1}')

cat << EOF
WORKSPACE snippet:
\`\`\`starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_stack_rules_proto",
sha256 = "${SHA}",
strip_prefix = "${PREFIX}",
url = "https://github.com/stackb/rules_proto/archive/refs/tags/${TAG}.tar.gz",
)
\`\`\`
EOF
10 changes: 9 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
load("@npm_ts_proto//:defs.bzl", "npm_link_all_packages")
load("@//rules:proto_gazelle.bzl", "proto_gazelle")

exports_files(["rules_proto_config.yaml"])

# ----------------------------------------------------
# Buildifier
Expand Down Expand Up @@ -28,9 +31,14 @@ gazelle_binary(
visibility = ["//visibility:public"],
)

gazelle(
proto_gazelle(
name = "gazelle",
cfgs = [":rules_proto_config.yaml"],
gazelle = ":gazelle-protobuf",
imports = [
"@googleapis//:imports.csv",
"@protoapis//:imports.csv",
],
)

gazelle(
Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BAZEL := bzl
BAZEL := bazel

.PHONY: tidy
tidy: deps
Expand All @@ -9,6 +9,10 @@ tidy: deps
$(BAZEL) run //:buildifier
$(BAZEL) run //:gazelle

.PHONY: gazelle
gazelle:
$(BAZEL) run //:gazelle

.PHONY: deps
deps:
$(BAZEL) build //deps:*
Expand All @@ -21,9 +25,13 @@ site:
$(BAZEL) build //example/golden:*
cp -f ./bazel-bin/example/golden/*.md docs/

.PHONY: golden_test
golden_test:
$(BAZEL) test //example/golden:golden_test

.PHONY: test
test:
$(BAZEL) test //example/... //pkg/... //plugin/... //language/... //rules/... //toolchain/... \
$(BAZEL) test --keep_going //example/... //pkg/... //plugin/... //language/... //rules/... //toolchain/... \
--deleted_packages=//plugin/grpc-ecosystem/grpc-gateway

.PHONY: get
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `rules_proto (v3)`

[![Build status](https://badge.buildkite.com/5980cc1d55f96e721bd9a7bd5dc1e40a096a7c30bc13117910.svg?branch=master)](https://buildkite.com/bazel/stackb-rules-proto)
![build-status](https://github.com/stackb/rules_proto/actions/workflows/ci.yaml/badge.svg)
[![Go Reference](https://pkg.go.dev/badge/github.com/stackb/rules_proto.svg)](https://pkg.go.dev/github.com/stackb/rules_proto)

Bazel starlark rules for building protocol buffers +/- gRPC :sparkles:.
Expand Down Expand Up @@ -597,7 +597,7 @@ proto_repository(
build_file_generation = "clean",
build_file_proto_mode = "file",
reresolve_known_proto_imports = True,
proto_language_config_file = "//example:config.yaml",
proto_language_config_file = "@//:rules_proto_config.yaml",
strip_prefix = "googleapis-02710fa0ea5312d79d7fb986c9c9823fb41049a9",
type = "zip",
urls = ["https://codeload.github.com/googleapis/googleapis/zip/02710fa0ea5312d79d7fb986c9c9823fb41049a9"],
Expand Down
Loading

0 comments on commit ee01b60

Please sign in to comment.