Skip to content

Commit edd29e1

Browse files
[Release] Synchronize for release
1 parent 885c507 commit edd29e1

File tree

1,711 files changed

+417316
-2404
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,711 files changed

+417316
-2404
lines changed

.bazelignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ submodules/
66
# Required for npm_translate_lock.verify_node_modules_ignored.
77
node_modules/
88
rbt/v1alpha1/node_modules/
9+
rbt/std/node_modules/
910
reboot/inspect/node_modules/
1011
reboot/nodejs/node_modules/
1112
reboot/react/node_modules/
13+
reboot/std/node_modules/
14+
reboot/std/react/node_modules/
15+
reboot/web/node_modules/
1216
tests/reboot/node_modules/

.clang-format

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
# Based on Google style with project-specific overrides.
3+
#
4+
# Matches the formatting style of `dev-tools`, but with an 80-character
5+
# column limit, required for sane output by clang 20.
6+
#
7+
# TODO(rjh): update the `dev-tools/.clang-format`, and go back to
8+
# sharing that.
9+
10+
Language: Cpp
11+
BasedOnStyle: Google
12+
AlignAfterOpenBracket: AlwaysBreak
13+
AlignEscapedNewlines: Right
14+
AlignOperands: DontAlign
15+
AlignTrailingComments: false
16+
AllowAllArgumentsOnNextLine: false
17+
AllowAllParametersOfDeclarationOnNextLine: false
18+
AllowShortBlocksOnASingleLine: Empty
19+
AllowShortCaseLabelsOnASingleLine: true
20+
AllowShortFunctionsOnASingleLine: Empty
21+
AllowShortIfStatementsOnASingleLine: Never
22+
AllowShortLoopsOnASingleLine: false
23+
BinPackArguments: false
24+
BinPackParameters: false
25+
BreakBeforeBinaryOperators: NonAssignment
26+
ConstructorInitializerIndentWidth: 2
27+
DerivePointerAlignment: false
28+
MaxEmptyLinesToKeep: 2
29+
SpaceAfterCStyleCast: true
30+
Standard: c++17
31+
32+
---
33+
# Proto files use default Google style.
34+
Language: Proto
35+
BasedOnStyle: Google

.devcontainer/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
This directory configures devcontainers for this repository. Devcontainers are
2+
used by GitHub Codespaces; they can also be launched locally (e.g., via VS
3+
Code).
4+
5+
Devcontainers are built for the local machine architecture (i.e., they are
6+
Linux/amd64 containers when built on amd64 hosts, and linux/arm64 when built on
7+
arm64 hosts).
8+
9+
Any changes to files within this directory will be tested via the regular
10+
`.github/workflows/*.yml` workflows; they'll be run in a devcontainer that'll
11+
have been (re-)built based on the changes in the `Dockerfile`.

.devcontainer/devcontainer.json

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/ubuntu
3+
{
4+
"name": "Codespace Workstation",
5+
"build": {
6+
"dockerfile": "../Dockerfile",
7+
"target": "codespace-workstation",
8+
// NOTE: by using 'cacheFrom' here we will be able to reuse
9+
// the Docker layers from previous devcontainer builds!
10+
"cacheFrom": "ghcr.io/reboot-dev/mono/workstation"
11+
},
12+
"customizations": {
13+
"vscode": {
14+
// Set *default* container specific settings.json values on container create.
15+
"settings": {},
16+
17+
// Add the IDs of extensions you want installed when the container is created.
18+
"extensions": [
19+
// Bazel makes VS Code aware of BUILD file syntax and tools.
20+
"BazelBuild.vscode-bazel",
21+
// Make VS Code respect .editorconfig files.
22+
"EditorConfig.EditorConfig",
23+
// Enable GitHub Copilot.
24+
"GitHub.copilot",
25+
// GitHub Pull Requests allows PR reviewers and authors to see and reply
26+
// to review comment in VS Code.
27+
"GitHub.vscode-pull-request-github",
28+
// Python support.
29+
"ms-python.python",
30+
// Python type checking.
31+
"ms-python.mypy-type-checker",
32+
// Automatically do import sorting in Python.
33+
"ms-python.isort",
34+
// C++ support.
35+
"ms-vscode.cpptools",
36+
// Additional C++ support.
37+
"ms-vscode.cpptools-extension-pack",
38+
// Use clang-format to format files.
39+
"xaver.clang-format",
40+
// Open in GitHub: provides links to open the current file + line number in GitHub.
41+
"ziyasal.vscode-open-in-github",
42+
// Protocol buffer support.
43+
"zxh404.vscode-proto3",
44+
// Spell checker.
45+
"streetsidesoftware.code-spell-checker",
46+
// Add autotmatic line/comment wrapper.
47+
"stkb.rewrap",
48+
// Prettier code formatter.
49+
"esbenp.prettier-vscode",
50+
// YAPF code formatter.
51+
"eeyore.yapf"
52+
]
53+
}
54+
},
55+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
56+
"forwardPorts": [
57+
// The HTTP port exposed by default in examples.
58+
3000,
59+
// The gRPC backend port exposed by default in examples.
60+
9991
61+
],
62+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
63+
"remoteUser": "vscode",
64+
"features": {
65+
// We need to be able to run docker-in-docker. Docker-on-docker is not enough; that would mean we
66+
// need to completely change the paths that we use for volume bindings.
67+
//
68+
// Keeping this feature here would increase the first boot time of our
69+
// Codespaces, but that's not user-visible since this happens during
70+
// Codespace Prebuilds: see
71+
// https://github.com/reboot-dev/mono/issues/107 . It would be even
72+
// better to move this installation functionality to the Dockerfile,
73+
// but that's complicated.
74+
// https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/docker-in-docker.md
75+
"ghcr.io/devcontainers/features/docker-in-docker:2": {
76+
"version": "latest"
77+
},
78+
// GitHub recently changed their default to no longer install sshd by default.
79+
// See: https://github.com/cli/cli/issues/5739. We now need to add it in
80+
// explicitly.
81+
"ghcr.io/devcontainers/features/sshd:1": {
82+
"version": "latest"
83+
}
84+
},
85+
// Specify a minimum machine size for Codespaces to work reasonably:
86+
// https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/setting-a-minimum-specification-for-codespace-machines#setting-a-minimum-machine-specification
87+
"hostRequirements": {
88+
// k3d commands easily run out of disk with only 64GB of storage:
89+
// request at least 128GB. As of Apr 2022, the only machines with this
90+
// much storage are the expensive 16-core machines, but only specify
91+
// storage because that's our only hard constraint.
92+
// TODO(alexmc): Can we reduce disk usage to reduce machine
93+
// requirements? See https://github.com/reboot-dev/mono/issues/134 .
94+
"storage": "128gb"
95+
},
96+
"containerEnv": {
97+
// Pass on variable 'RESPECT_DEVCONTAINER_YML' so that
98+
// we can skip steps that we intend only when using Codespaces.
99+
"RESPECT_DEVCONTAINER_YML": "${localEnv:RESPECT_DEVCONTAINER_YML:false}",
100+
// Pass on 'GCP_REMOTE_CACHE_CREDENTIALS_BASE64' so that we
101+
// can run any builds that might need the remote cache.
102+
"GCP_REMOTE_CACHE_CREDENTIALS_BASE64": "${localEnv:GCP_REMOTE_CACHE_CREDENTIALS_BASE64}",
103+
// Export a file path that contains credentials that can be used to
104+
// access a Google Cloud Storage bucket which we use as a remote
105+
// `bazel` cache to speed up builds.
106+
// The credentials file will be populated using a combination of secrets
107+
// and the `updateContentCommand` below.
108+
// As it turns out, we can not export this variable inside the script
109+
// or on the "command line", so we do it here.
110+
"GOOGLE_APPLICATION_CREDENTIALS": "/home/vscode/google_application_credentials.json"
111+
},
112+
// The below lifecycle hooks refer to lifecycle events documented here:
113+
// https://code.visualstudio.com/docs/remote/devcontainerjson-reference#_lifecycle-scripts
114+
// https://docs.github.com/en/codespaces/developing-in-codespaces/codespaces-lifecycle
115+
// https://docs.github.com/en/codespaces/prebuilding-your-codespaces/configuring-prebuilds#configuring-time-consuming-tasks-to-be-included-in-the-prebuild
116+
// oncreateCommand runs inside the container after the Codespace template
117+
// is created: this happens only once, well before a user is assigned.
118+
"onCreateCommand": ".devcontainer/on_create.sh",
119+
// updateContent runs inside the container after repo content is updated
120+
// with new commits. We use it to build new content so users' builds are
121+
// mostly incremental.
122+
"updateContentCommand": ".devcontainer/update_content.sh"
123+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
#
3+
# Make it possible for us to push commits to all repos that we have access to as
4+
# our GitHub user, not just to `reboot-dev/mono`. Our default GitHub
5+
# Codespaces git authentication mechanism (based on `GITHUB_TOKEN`) only has
6+
# permissions to push to the repository the codespace is created for, not the
7+
# submodules or anything else. See:
8+
# https://github.com/reboot-dev/mono/issues/100
9+
#
10+
# To authenticate our codespace to be able to push elsewhere, we...
11+
# * Set up `gh` as a credential helper once (during setup in `git_config.sh`).
12+
# * Unset `GITHUB_TOKEN`, so it uses the credential helper instead (for every
13+
# terminal start, in this script).
14+
# * Tells the user to run `gh auth login` if they haven't yet (for every
15+
# terminal start, in this script).
16+
17+
# NOTE: do NOT use `set -e` or `set -u` here, as this script is expected to be
18+
# `source`d every time a new terminal starts, and the setting will persist
19+
# for the entire lifetime of the terminal.
20+
21+
# In every terminal we DON'T want to have `GITHUB_TOKEN` set, as it will
22+
# override any authentication we may have done with `gh auth login`.
23+
unset GITHUB_TOKEN
24+
25+
# Now check that we've authenticated to GitHub.
26+
RED='\033[0;31m'
27+
NC='\033[0m' # No Color
28+
gh auth status > /dev/null 2>&1 || {
29+
echo -e "${RED}ATTENTION:${NC} you haven't authenticated to GitHub yet. Please run:"
30+
echo " gh auth login"
31+
}

.devcontainer/git_config.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
2+
#
3+
# Set common git config settings. Unfortunately, git can't be configured to use
4+
# a default config file that's checked into a repository: see
5+
# https://stackoverflow.com/a/18330114.
6+
7+
set -e # Exit if a command exits with an error.
8+
set -u # Treat expanding an unset variable as an error.
9+
10+
# When Copilot edits our repo, it checks out our code as one user, then
11+
# edits it as another. We need to tell git that this is okay.
12+
git config --global --add safe.directory $(pwd)
13+
14+
# Avoid having to type `git push --set-upstream my_branch origin/my_branch`
15+
# every time we create a new branch that we want to push to GitHub, by making
16+
# the upstream default to the same name as the local branch. That way, we
17+
# can simply type `git push -u` and it will set the upstream if needed.
18+
git config --global push.default current
19+
20+
# When doing `git pull`, default to `git pull --recurse-submodules`. We use
21+
# submodules liberally in Respect, and having to type `--recurse-submodules`
22+
# is a penguin we have to keep track of all the time. In the unlikely event
23+
# that we don't want to pull the latest submodules we can still pass
24+
# `--no-recurse-submodules` to `git pull`.
25+
git config --global submodule.recurse true
26+
27+
# Use diff3 as our conflict resolution strategy, following recommendations such as:
28+
# https://blog.nilbus.com/take-the-pain-out-of-git-conflict-resolution-use-diff3/
29+
# and
30+
# https://stackoverflow.com/questions/27417656/should-diff3-be-default-conflictstyle-on-git
31+
git config --global merge.conflictstyle diff3
32+
33+
# When force-pushing (e.g. a rebased branch), check that the upstream
34+
# branch is still exactly the way it was when it was last fetched. This
35+
# prevents force-pushes to the same branch from two different machines
36+
# (or developers) from accidentally wiping out the first pushed changes.
37+
git config --global push.forceWithLease true
38+
39+
# Do some extra work to pre-configure GitHub authentication when running
40+
# in a codespace. Skip this for a local devcontainer.
41+
if [[ "${CODESPACES:-}" == "true" ]]; then
42+
# Use HTTPS instead of SSH for git operations on this workstation: in
43+
# Codespaces we have credentials ONLY for HTTPS. See:
44+
# https://docs.github.com/en/codespaces/codespaces-reference/security-in-codespaces#authentication
45+
# https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#using-a-token-on-the-command-line
46+
git config --global url."https://github.com/".insteadOf "git@github.com:"
47+
48+
# Make it possible for us to push commits to all repos, not just to
49+
# `reboot-dev/mono`. To do so, we...
50+
# 1. Set the `gh` (GitHub CLI) tool as a `git` credential helper.
51+
gh auth setup-git
52+
53+
# 2. Set up a script that on every terminal start:
54+
# * Unsets `GITHUB_TOKEN`, so it uses the credential helper instead.
55+
# * Tells the user to run `gh auth login` if they haven't yet.
56+
grep -q "gh_auth_for_all_repos.sh" ~/.bashrc \
57+
|| { \
58+
echo "" >> ~/.bashrc \
59+
&& echo "# Installed by .devcontainer/git_config.sh" >> ~/.bashrc \
60+
&& echo "source .devcontainer/gh_auth_for_all_repos.sh" >> ~/.bashrc \
61+
;}
62+
63+
fi
64+
65+
# Install a script that on every terminal start checks if the precommit
66+
# hook is installed, and if not installs it.
67+
grep -q "install_precommit_hook.sh" ~/.bashrc \
68+
|| { \
69+
echo "" >> ~/.bashrc \
70+
&& echo "# Installed by .devcontainer/git_config.sh" >> ~/.bashrc \
71+
&& echo "source .devcontainer/install_precommit_hook.sh" >> ~/.bashrc \
72+
;}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
#
3+
function install_precommit_hook() {
4+
local repo_top_level="$(git rev-parse --show-toplevel)"
5+
# In the mono repo, submodules live under `public/`; in the standalone
6+
# public repo they live directly at the top level.
7+
local prefix=""
8+
if [[ -d "${repo_top_level}/public" ]]; then
9+
prefix="public/"
10+
fi
11+
local dev_tools_commit_hook_path="${repo_top_level}/${prefix}submodules/dev-tools/pre-commit";
12+
local local_dev_tools_commit_hook_path="${repo_top_level}/.git/hooks/dev-tools-pre-commit";
13+
local rbt_documentation_commit_hook_path="${repo_top_level}/${prefix}documentation/pre-commit";
14+
local local_rbt_documentation_commit_hook_path="${repo_top_level}/.git/hooks/rbt-documentation-pre-commit";
15+
local local_combined_commit_hook_path="${repo_top_level}/.git/hooks/pre-commit";
16+
17+
# Check that the dev-tools hook file exists.
18+
if [[ ! -f "${dev_tools_commit_hook_path}" ]]; then
19+
echo "Commit hook from dev-tools not found at '${dev_tools_commit_hook_path}' Aborting.";
20+
return 1
21+
fi
22+
23+
# Check that the rbt documentation hook file exists.
24+
if [[ ! -f "${rbt_documentation_commit_hook_path}" ]]; then
25+
echo "Commit hook from documentation not found at '${rbt_documentation_commit_hook_path}' Aborting.";
26+
return 1
27+
fi
28+
29+
# Create a local symlink for the dev-tools hook. Remove any old ones first,
30+
# in case the paths we're working with have changed.
31+
rm -f "${local_dev_tools_commit_hook_path}"
32+
ln -s -f "${dev_tools_commit_hook_path}" "${local_dev_tools_commit_hook_path}"
33+
34+
# Create a local symlink for the rbt documentation hook. Remove any old
35+
# ones first, in case the paths we're working with have changed.
36+
rm -f "${local_rbt_documentation_commit_hook_path}"
37+
ln -s -f "${rbt_documentation_commit_hook_path}" "${local_rbt_documentation_commit_hook_path}"
38+
39+
# Delete any old precommit hook. It's important to explicitly delete (rather
40+
# than just overwriting) in case the old version was a symlink pointing to a
41+
# file that we don't actually want to overwrite).
42+
rm -f "${local_combined_commit_hook_path}"
43+
44+
# Create a top-level precommit hook that calls the pulled-in files.
45+
echo "${local_dev_tools_commit_hook_path}; if [ ! \$? -eq 0 ]; then exit 1; fi; ${local_rbt_documentation_commit_hook_path}; exit \$?" > "${local_combined_commit_hook_path}"
46+
chmod +x "${local_combined_commit_hook_path}"
47+
}
48+
49+
install_precommit_hook

.devcontainer/kustomize_wrapper.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
#
3+
# When Skaffold runs:
4+
# ```
5+
# kustomize build ...
6+
# ```
7+
# We'd like it to actually invoke:
8+
# ```
9+
# kubectl kustomize ...
10+
# ```
11+
# This script is a wrapper that does that.
12+
# This extra step lets us avoid installing `kustomize` on our workstations; see
13+
# https://github.com/reboot-dev/mono/issues/1772 for background on why that's
14+
# a thing we want to avoid.
15+
16+
FIRST_ARG=$1
17+
if [ "$FIRST_ARG" != "build" ]; then
18+
echo "ERROR: kustomize_wrapper.sh only supports 'build' as the first argument"
19+
exit 1
20+
fi
21+
22+
REMAINING_ARGS=${@:2}
23+
kubectl kustomize ${REMAINING_ARGS}

.devcontainer/on_create.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
#
3+
# This script is run after a devcontainer has been created. It performs
4+
# post-creation initialization.
5+
6+
set -e # Exit if a command exits with an error.
7+
set -u # Treat expanding an unset variable as an error.
8+
set -x # Echo executed commands to help debug failures.
9+
10+
# Make sure all of the submodules are here.
11+
git submodule update --init --recursive
12+
13+
# Set up ease-of-use environmental preferences.
14+
.devcontainer/git_config.sh
15+
16+
# Ensure local git hooks match the current repository layout.
17+
.devcontainer/install_precommit_hook.sh

0 commit comments

Comments
 (0)