Skip to content
Merged
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
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
18 changes: 17 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
pkg-config \
zip unzip \
python \
git
git \
libnss3-dev

# Install Bazel
ARG BAZELISK_VERSION=v1.10.1
Expand All @@ -18,6 +19,21 @@ RUN curl -fSsL -o /usr/local/bin/bazelisk https://github.com/bazelbuild/bazelisk
&& chmod 0755 /usr/local/bin/bazelisk \
&& ln -sf /usr/local/bin/bazelisk /usr/local/bin/bazel

# Install Homebrew. See:
# https://docs.brew.sh/Installation#skip-tap-cloning-beta
# https://docs.brew.sh/Installation#unattended-installation
ENV HOMEBREW_INSTALL_FROM_API=1
ENV NONINTERACTIVE=1
RUN /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" \
&& echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /etc/profile.d/99-homebrew.sh \
&& chmod 0755 /etc/profile.d/99-homebrew.sh \
&& eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" \
&& brew --version

# Install pnpm package manager
RUN eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" \
&& brew install pnpm

# Clean extraneous packages and files
RUN apt-get autoremove -y \
&& apt-get clean -y \
Expand Down
37 changes: 37 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base",
":rebaseStalePrs",
":automergeMinor",
"schedule:weekends"
],
"golang": {
"description": "TODO(ralimi) Enable when gazelle supported: https://github.com/renovatebot/renovate/issues/3347",
"enabled": false
},
"packageRules": [
{
"description": "rules_proto has versions like '4.0.0-3.19.2-2'. Override the versioning scheme to better handle these.",
"matchManagers": ["bazel"],
"matchPackageNames": ["rules_proto"],
"versioning": "regex:(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)-(?<build>.+)$"
},
{
"description": "package.json specifies dependencies like ^1.0.0; bump them even when new version matches",
"matchManagers": ["npm"],
"rangeStrategy": "bump"
}
],
"regexManagers": [
{
"description": "Custom match modeled after https://docs.renovatebot.com/modules/manager/regex/#advanced-capture. Match things like: <something>1.2.3<something else> # renovate: datasource=foo depName=bar versioning=baz",
"fileMatch": [
"^WORKSPACE$"
],
"matchStrings": [
".*?(?<currentValue>[\\d\\.]+)[^\\n]*?renovate:\\s+datasource=(?<datasource>\\S+)\\s+depName=(?<depName>\\S+)\\s+(versioning=(?<versioning>\\S+))?"
]
}
]
}
3 changes: 3 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@io_bazel_rules_go//go:def.bzl", "TOOLS_NOGO", "nogo")
load("@rules_pkg//:pkg.bzl", "pkg_zip")

Expand Down Expand Up @@ -51,6 +52,8 @@ exports_files([
"package-lock.json",
])

npm_link_all_packages(name = "node_modules")

pkg_zip(
name = "chrome-ssh-agent",
srcs = [
Expand Down
68 changes: 53 additions & 15 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,24 @@ http_archive(
)

http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "ee3280a7f58aa5c1caa45cb9e08cbb8f4d74300848c508374daf37314d5390d6",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.5.1/rules_nodejs-5.5.1.tar.gz"],
name = "aspect_rules_js",
sha256 = "9fadde0ae6e0101755b8aedabf7d80b166491a8de297c60f6a5179cd0d0fea58",
strip_prefix = "rules_js-1.20.0",
url = "https://github.com/aspect-build/rules_js/releases/download/v1.20.0/rules_js-v1.20.0.tar.gz",
)

http_archive(
name = "aspect_rules_ts",
sha256 = "db77d904284d21121ae63dbaaadfd8c75ff6d21ad229f92038b415c1ad5019cc",
strip_prefix = "rules_ts-1.3.0",
url = "https://github.com/aspect-build/rules_ts/releases/download/v1.3.0/rules_ts-v1.3.0.tar.gz",
)

http_archive(
name = "aspect_rules_esbuild",
sha256 = "3e074ee7be579ceb4f0a664f6ae88fa68926e8eec65ffa067624c5d98c9552f6",
strip_prefix = "rules_esbuild-0.13.5",
url = "https://github.com/aspect-build/rules_esbuild/archive/refs/tags/v0.13.5.tar.gz",
)

http_archive(
Expand Down Expand Up @@ -109,7 +124,8 @@ go_rules_dependencies()

go_register_toolchains(
nogo = "@//:chrome_ssh_agent_nogo",
version = "1.19",
# Use semver-coerced to handle versions where patches are left off (e.g., 1.19).
version = "1.19", # renovate: datasource=golang-version depName=golang versioning=semver-coerced
)

# Gazelle dependency management support
Expand All @@ -123,25 +139,47 @@ go_dependencies()

gazelle_dependencies()

# NodeJS support. Required for testing and publishing.
load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")
# Javascript support.
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

build_bazel_rules_nodejs_dependencies()
rules_js_dependencies()

load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "npm_install")
load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "node_repositories", "nodejs_register_toolchains")

nodejs_register_toolchains(
name = "nodejs",
node_version = DEFAULT_NODE_VERSION,
)

node_repositories()
load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")

npm_install(
npm_translate_lock(
name = "npm",
package_json = "//:package.json",
package_lock_json = "//:package-lock.json",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)

# Enable esbuild for merging Javascript/Typescript.
load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories")
load("@npm//:repositories.bzl", "npm_repositories")

esbuild_repositories(npm_repository = "npm")
npm_repositories()

# Typescript support.
load("@aspect_rules_ts//ts:repositories.bzl", "LATEST_VERSION", "rules_ts_dependencies")

rules_ts_dependencies(ts_version = LATEST_VERSION)

# esbuild support.

load("@aspect_rules_esbuild//esbuild:dependencies.bzl", "rules_esbuild_dependencies")

rules_esbuild_dependencies()

load("@aspect_rules_esbuild//esbuild:repositories.bzl", "LATEST_VERSION", "esbuild_register_toolchains")

esbuild_register_toolchains(
name = "esbuild",
esbuild_version = LATEST_VERSION,
)

# Skylib for helpful utilities in custom rules.

Expand Down
8 changes: 5 additions & 3 deletions build_defs/wasm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ load("@io_bazel_rules_go//go/private:providers.bzl", "GoLibrary", "GoPath", "GoA
load("@io_bazel_rules_go//go:def.bzl", "go_test", "go_library", "go_binary")
load("@bazel_skylib//lib:paths.bzl", "paths")


def _go_wasm_test_impl(ctx):
node_info = ctx.toolchains["@rules_nodejs//nodejs:toolchain_type"].nodeinfo
node_path = node_info.target_tool_path
Expand All @@ -16,8 +17,7 @@ def _go_wasm_test_impl(ctx):
'#!/bin/bash -eu',
# Ensure 'node' binary is on the PATH.
'export PATH="${{PWD}}/{0}:${{PATH}}"'.format(paths.dirname(node_path)),
# TODO: Replace with proper way to discover directory
'export NODE_PATH="${PWD}/external/npm/node_modules"',
'export NODE_PATH="${PWD}/node_modules"',
# Wrapping executes a subprocess and uses pipe() for communication;
# pipe() is unsupported under node.js and WASM.
'export GO_TEST_WRAP=0',
Expand All @@ -31,8 +31,10 @@ def _go_wasm_test_impl(ctx):

runfiles = ctx.runfiles(files=(
[runner, test_executable, ctx.executable.run_wasm]
+ node_inputs + ctx.files.node_deps
+ node_inputs
))
for nd in ctx.attr.node_deps:
runfiles = runfiles.merge(nd[DefaultInfo].default_runfiles)
runfiles = runfiles.merge(test_runfiles)

return [DefaultInfo(
Expand Down
4 changes: 2 additions & 2 deletions go/dom/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ go_wasm_test(
],
embed = [":dom"],
node_deps = [
"@npm//jsdom",
"@npm//@ungap/url-search-params",
"//:node_modules/jsdom",
"//:node_modules/@ungap/url-search-params",
],
deps = [
"//go/dom/testing",
Expand Down
4 changes: 2 additions & 2 deletions go/keys/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ go_wasm_test(
],
embed = [":keys"],
node_deps = [
"@npm//web-locks",
"@npm//mem-storage-area",
"//:node_modules/web-locks",
"//:node_modules/mem-storage-area",
],
deps = [
"//go/jsutil/testing",
Expand Down
2 changes: 1 addition & 1 deletion go/lock/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ go_wasm_test(
srcs = ["lock_test.go"],
embed = [":lock"],
node_deps = [
"@npm//web-locks",
"//:node_modules/web-locks",
],
deps = [
"//go/dom/testing",
Expand Down
6 changes: 3 additions & 3 deletions go/optionsui/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ go_wasm_test(
],
embed = [":optionsui"],
node_deps = [
"@npm//web-locks",
"@npm//mem-storage-area",
"@npm//jsdom",
"//:node_modules/web-locks",
"//:node_modules/mem-storage-area",
"//:node_modules/jsdom",
],
deps = [
"//go/dom",
Expand Down
4 changes: 2 additions & 2 deletions go/storage/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ go_wasm_test(
],
embed = [":storage"],
node_deps = [
"@npm//web-locks",
"@npm//mem-storage-area",
"//:node_modules/web-locks",
"//:node_modules/mem-storage-area",
],
deps = [
"//go/jsutil/testing",
Expand Down
21 changes: 15 additions & 6 deletions html/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@npm//@bazel/esbuild:index.bzl", "esbuild")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files")

# Typescript compiler inputs must be within our package. Copy it over.
Expand All @@ -20,39 +20,48 @@ js_library(
],
)

ts_config(
name = "tsconfig",
src = "tsconfig.json",
)

ts_project(
name = "app",
srcs = ["app.ts"],
tsconfig = ":tsconfig",
declaration = True,
deps = [
":wasm_exec",
"@npm//@types/chrome",
"//:node_modules/@types/chrome",
],
)

ts_project(
name = "background",
srcs = ["background.ts"],
tsconfig = ":tsconfig",
declaration = True,
deps = [
":app",
"@npm//@types/chrome",
"//:node_modules/@types/chrome",
],
)

esbuild(
name = "background-bundle",
data = [":tsconfig"],
entry_point = "background.ts",
deps = [":background"],
)

ts_project(
name = "options",
srcs = ["options.ts"],
tsconfig = ":tsconfig",
declaration = True,
deps = [
":app",
"@npm//@types/chrome",
"//:node_modules/@types/chrome",
],
)

Expand Down
Loading