Skip to content

{WIP} build: Generate Codelabs (using Bazel) #9

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
28 changes: 28 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# https://bazel.build/run/bazelrc

# https://github.com/bazelbuild/rules_jvm_external/blob/master/docs/bzlmod.md#installation
common --enable_bzlmod

# https://bazel.build/docs/bazel-and-java#java-versions
build --java_language_version=11
build --tool_java_language_version=11

# https://bazel.build/docs/user-manual#java_runtime_version
build --java_runtime_version=remotejdk_11
build --tool_java_runtime_version=remotejdk_11

# https://github.com/bazelbuild/intellij/issues/1169
build --incompatible_strict_action_env
run --incompatible_strict_action_env

# https://bazel.build/reference/command-line-reference#flag--test_output
test --test_output=errors

# https://bazel.build/reference/command-line-reference#flag--explicit_java_test_deps
test --explicit_java_test_deps

# Quiet!
# common --noshow_progress
common --ui_event_filters=error,warning,info,-debug,stdout,stderr
# FYI -info also hides :( output from tests and tools such as core_buf_proto_lint (TODO how-to show only if failure?)
# Beware, -stdout breaks IDE integrations!
2 changes: 2 additions & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
6.4.0

Empty file added BUILD.bazel
Empty file.
6 changes: 6 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# https://github.com/bazelbuild/rules_go/blob/master/docs/go/core/bzlmod.md
bazel_dep(name = "rules_go", version = "0.42.0", repo_name = "io_bazel_rules_go")
bazel_dep(name = "gazelle", version = "0.33.0", repo_name = "bazel_gazelle")

go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.21.3")
8 changes: 8 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "googlecodelabs_tools",
sha256 = "9f2b585333fc582b0a545f6b4bee0f4466ef71c7",
strip_prefix = "",
urls = ["https://github.com/googlecodelabs/tools/archive/9f2b585333fc582b0a545f6b4bee0f4466ef71c7.zip"],
)
20 changes: 20 additions & 0 deletions b
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

# Inspired by https://github.com/enola-dev/enola/blob/main/enola

# TODO Put this into a https://github.com/www-learn-study/bazel-template

set -euo pipefail

if [ -x "$(command -v gbazelisk)" ]; then
BZL=gbazelisk
elif [ -x "$(command -v bazelisk)" ]; then
BZL=bazelisk
else
# Also in test.bash
echo "bazelisk is not installed, please run e.g. 'go install github.com/bazelbuild/bazelisk@latest' "
echo "or an equivalent from https://github.com/bazelbuild/bazelisk#installation or see docs/dev/setup.md"
exit 255
fi

"$BZL" "$@"