Skip to content

Commit 86a730b

Browse files
authored
Merge branch 'gonzojive:es6' into es6
2 parents 70c3f63 + 56d0a9f commit 86a730b

File tree

9 files changed

+269
-75
lines changed

9 files changed

+269
-75
lines changed

.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
common --enable_bzlmod

.github/workflows/ci.bazelrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This file contains Bazel settings to apply on CI only.
2+
# It is referenced with a --bazelrc option in the call to bazel in ci.yaml
3+
4+
# Debug where options came from
5+
build --announce_rc
6+
# This directory is configured in GitHub actions to be persisted between runs.
7+
build --disk_cache=~/.cache/bazel
8+
build --repository_cache=~/.cache/bazel-repo
9+
# Don't rely on test logs being easily accessible from the test runner,
10+
# though it makes the log noisier.
11+
test --test_output=errors
12+
# Allows tests to run bazelisk-in-bazel, since this is the cache folder used
13+
test --test_env=XDG_CACHE_HOME

.github/workflows/ci.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: CI
2+
3+
# Controls when the action will run.
4+
on:
5+
# Triggers the workflow on push or pull request events but only for the main branch
6+
push:
7+
branches: [main, es6]
8+
pull_request:
9+
branches: [main, es6]
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
concurrency:
15+
# Cancel previous actions from the same PR: https://stackoverflow.com/a/72408109
16+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
# matrix-prep-* steps generate JSON used to create a dynamic actions matrix.
21+
# Insanely complex for how simple this requirement is inspired from
22+
# https://stackoverflow.com/questions/65384420/how-to-make-a-github-action-matrix-element-conditional
23+
24+
matrix-prep-bazelversion:
25+
# Prepares the 'bazelversion' axis of the test matrix
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v3
29+
- id: bazel_from_bazelversion
30+
run: echo "bazelversion=$(head -n 1 .bazelversion)" >> $GITHUB_OUTPUT
31+
# bazel 5 testing disabled for now due to
32+
# https://github.com/aspect-build/bazel-lib/issues/392
33+
# - id: bazel_5
34+
# run: echo "bazelversion=5.3.2" >> $GITHUB_OUTPUT
35+
outputs:
36+
# Will look like ["<version from .bazelversion>"]
37+
bazelversions: ${{ toJSON(steps.*.outputs.bazelversion) }}
38+
39+
bazel-build:
40+
# The type of runner that the job will run on
41+
runs-on: ubuntu-latest
42+
43+
needs:
44+
- matrix-prep-bazelversion
45+
46+
# Run bazel test in each workspace with each version of Bazel supported
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions) }}
51+
folder:
52+
- "."
53+
54+
# Steps represent a sequence of tasks that will be executed as part of the job
55+
steps:
56+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
57+
- uses: actions/checkout@v3
58+
59+
# Cache build and external artifacts so that the next ci build is incremental.
60+
# Because github action caches cannot be updated after a build, we need to
61+
# store the contents of each build in a unique cache key, then fall back to loading
62+
# it on the next ci run. We use hashFiles(...) in the key and restore-keys- with
63+
# the prefix to load the most recent cache for the branch on a cache miss. You
64+
# should customize the contents of hashFiles to capture any bazel input sources,
65+
# although this doesn't need to be perfect. If none of the input sources change
66+
# then a cache hit will load an existing cache and bazel won't have to do any work.
67+
# In the case of a cache miss, you want the fallback cache to contain most of the
68+
# previously built artifacts to minimize build time. The more precise you are with
69+
# hashFiles sources the less work bazel will have to do.
70+
- name: Mount bazel caches
71+
uses: actions/cache@v3
72+
with:
73+
path: |
74+
~/.cache/bazel
75+
~/.cache/bazel-repo
76+
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE') }}
77+
restore-keys: bazel-cache-
78+
79+
- name: Configure Bazel version
80+
working-directory: ${{ matrix.folder }}
81+
run: echo "${{ matrix.bazelversion }}" > .bazelversion
82+
83+
- name: bazel build //generator/...
84+
env:
85+
# Bazelisk will download bazel to here, ensure it is cached between runs.
86+
XDG_CACHE_HOME: ~/.cache/bazel-repo
87+
working-directory: ${{ matrix.folder }}
88+
run: bazel --bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc --bazelrc=.github/workflows/ci.bazelrc build //generator/...

BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pkg_files(
2121
name = "dist_files",
2222
srcs = glob([
2323
"google/protobuf/*.js",
24-
"google/protobuf/compiler/*.js"
24+
"google/protobuf/compiler/*.js",
2525
]) + [
2626
"google-protobuf.js",
2727
"package.json",
@@ -58,5 +58,5 @@ filegroup(
5858
srcs = [
5959
":dist_tar",
6060
":dist_zip",
61-
]
61+
],
6262
)

MODULE.bazel

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module(
2+
name = "protobuf_javascript_gonzojive",
3+
version = "3.21.5",
4+
)
5+
6+
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
7+
bazel_dep(name = "abseil-cpp", version = "20211102.0")
8+
bazel_dep(name = "rules_pkg", version = "0.7.0")
9+
10+
# For VS Code autocompletion:
11+
# https://github.com/hedronvision/bazel-compile-commands-extractor#usage
12+
#
13+
# Run bazel run @hedron_compile_commands//:refresh_all to get autocomplete
14+
# working in VS Code and other editors.
15+
# Not currently working due to https://github.com/hedronvision/bazel-compile-commands-extractor/issues/199
16+
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
17+
git_override(
18+
module_name = "hedron_compile_commands",
19+
commit = "0e990032f3c5a866e72615cf67e5ce22186dcb97",
20+
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
21+
# Replace the commit hash (above) with the latest (https://github.com/hedronvision/bazel-compile-commands-extractor/commits/main).
22+
# Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README).
23+
)

MODULE.bazel.lock

Lines changed: 110 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WORKSPACE

Lines changed: 0 additions & 33 deletions
This file was deleted.

generator/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ cc_binary(
99
],
1010
visibility = ["//visibility:public"],
1111
deps = [
12+
"@abseil-cpp//absl/strings:str_format",
1213
"@com_google_protobuf//:protobuf",
1314
"@com_google_protobuf//:protoc_lib",
1415
],
1516
)
16-

0 commit comments

Comments
 (0)