mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-14 16:49:10 +00:00
strip out bazel, grpc
This commit is contained in:
parent
c8adad6c81
commit
1dd910a5f6
290 changed files with 22037 additions and 32177 deletions
|
@ -1 +0,0 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
|
@ -1 +0,0 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
|
@ -1,17 +0,0 @@
|
|||
load("@io_bazel_rules_docker//container:container.bzl", "container_push")
|
||||
|
||||
def publish(
|
||||
service,
|
||||
name = "+publish",
|
||||
image = ":image",
|
||||
prefix = "roleypoly/roleypoly/",
|
||||
registry = "docker.pkg.github.com",
|
||||
):
|
||||
container_push(
|
||||
name = name,
|
||||
format = "Docker",
|
||||
image = image,
|
||||
registry = registry,
|
||||
repository = prefix + service,
|
||||
tag = "{STABLE_URL_SAFE_TAG}",
|
||||
)
|
|
@ -1 +0,0 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
|
@ -1,61 +0,0 @@
|
|||
# Copied from https://github.com/bazelbuild/rules_nodejs/blob/stable/examples/jest/jest.bzl
|
||||
# Licensed under Apache-2.0, modifications made:
|
||||
# - improved dependency resolution
|
||||
|
||||
load("@npm//jest-cli:index.bzl", "jest", _jest_test = "jest_test")
|
||||
load("//hack/bazel:utils.bzl", "render_deps")
|
||||
|
||||
DEFAULT_DEPS = [
|
||||
"@npm//ts-jest",
|
||||
"@npm//enzyme",
|
||||
"@npm//enzyme-adapter-react-16",
|
||||
"@npm//@types/enzyme",
|
||||
"@npm//jest-environment-enzyme",
|
||||
"@npm//jsdom",
|
||||
"@npm//jest",
|
||||
"@npm//@types/jest",
|
||||
"@npm//jest-enzyme",
|
||||
"@npm//jest-styled-components",
|
||||
"@npm//enzyme-to-json",
|
||||
"@npm//react-dom",
|
||||
"@npm//@types/react-dom",
|
||||
"@npm//jest-react-hooks-shallow",
|
||||
"//:tsconfig.json",
|
||||
"//:hack/jestSetup.ts",
|
||||
]
|
||||
|
||||
def _impl_jest_test(name, srcs, deps, jest_config, **kwargs):
|
||||
"A macro around the autogenerated jest_test rule"
|
||||
templated_args = [
|
||||
"--no-cache",
|
||||
"--no-watchman",
|
||||
"--ci",
|
||||
"--no-colors",
|
||||
]
|
||||
templated_args.extend(["--config", "$(rootpath %s)" % jest_config])
|
||||
for src in srcs:
|
||||
templated_args.extend(["--runTestsByPath", "$(rootpath %s)" % src])
|
||||
|
||||
data = [jest_config] + srcs + deps + ["//:jest-reporter.js"]
|
||||
_jest_test(
|
||||
name = name,
|
||||
data = data,
|
||||
templated_args = templated_args,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
# This rule is used specifically to update snapshots via `bazel run`
|
||||
jest(
|
||||
name = "%s.update" % name,
|
||||
data = data,
|
||||
templated_args = templated_args + ["-u"],
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def jest_test(src, deps = []):
|
||||
_impl_jest_test(
|
||||
name = src[1:] + "_test",
|
||||
srcs = native.glob(["*.spec.ts", "*.spec.tsx"]),
|
||||
deps = [src] + render_deps(deps) + DEFAULT_DEPS,
|
||||
jest_config = "//:jest.config.js",
|
||||
)
|
|
@ -1,36 +0,0 @@
|
|||
load("//src/ts-protoc-gen/rules:index.bzl", "typescript_proto_library")
|
||||
load("@npm//@bazel/typescript:index.bzl", "ts_library")
|
||||
|
||||
def _generalize_pb_imports(name, srcs = [], grpc = False):
|
||||
suffix_match = "pb"
|
||||
if grpc:
|
||||
suffix_match = ""
|
||||
native.genrule(
|
||||
name = name,
|
||||
srcs = srcs,
|
||||
outs = ["index.ts"],
|
||||
cmd = """
|
||||
echo $(SRCS) | tr ' ' '\n' | grep '""" + suffix_match + """\\.js$$' | xargs -l1 -I '{}' basename {} .js | xargs -l1 -I'{}' echo 'export * from "./{}"' > $(location index.ts)
|
||||
""",
|
||||
output_to_bindir = True,
|
||||
)
|
||||
|
||||
def ts_proto(proto, name = "ts", grpc = False):
|
||||
typescript_proto_library(
|
||||
name = name + "_proto",
|
||||
proto = proto,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
_generalize_pb_imports(
|
||||
grpc = grpc,
|
||||
name = name + "_proto_generalized",
|
||||
srcs = [":" + name + "_proto"],
|
||||
)
|
||||
|
||||
ts_library(
|
||||
name = name,
|
||||
srcs = [":" + name + "_proto_generalized"],
|
||||
deps = [":" + name + "_proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
|
@ -1,27 +0,0 @@
|
|||
load("@npm//@bazel/typescript:index.bzl", "ts_library")
|
||||
load("//hack/bazel:utils.bzl", "render_deps")
|
||||
|
||||
DEFAULT_DEPS = [
|
||||
"react",
|
||||
"styled-components",
|
||||
"@types/react",
|
||||
"@types/styled-components",
|
||||
]
|
||||
|
||||
def react_library(name, deps = [], **kwargs):
|
||||
ts_library(
|
||||
name = name,
|
||||
srcs = native.glob(
|
||||
[
|
||||
"*.ts",
|
||||
"*.tsx",
|
||||
],
|
||||
exclude = native.glob([
|
||||
"*.spec.ts*",
|
||||
"*.story.tsx",
|
||||
"*.stories.tsx",
|
||||
]),
|
||||
),
|
||||
deps = render_deps(deps + DEFAULT_DEPS),
|
||||
**kwargs
|
||||
)
|
|
@ -1,30 +0,0 @@
|
|||
def _append_once(targetList, item):
|
||||
if item not in targetList:
|
||||
targetList.append(item)
|
||||
|
||||
def _extend_once(targetList, items):
|
||||
for item in items:
|
||||
_append_once(targetList, item)
|
||||
|
||||
def render_deps(deps = []):
|
||||
output_deps = []
|
||||
|
||||
has_added_grpc_deps = False
|
||||
|
||||
for dep in deps:
|
||||
if dep.startswith("//src/rpc"):
|
||||
_append_once(output_deps, dep + ":ts")
|
||||
_append_once(output_deps, dep + ":ts_proto")
|
||||
if has_added_grpc_deps == False:
|
||||
_extend_once(output_deps, [
|
||||
"@npm//google-protobuf",
|
||||
"@npm//@types/google-protobuf",
|
||||
"@npm//@improbable-eng/grpc-web",
|
||||
])
|
||||
has_added_grpc_deps = True
|
||||
elif dep.startswith("//") or dep.startswith("@npm//"):
|
||||
_append_once(output_deps, dep)
|
||||
else:
|
||||
_append_once(output_deps, "@npm//" + dep)
|
||||
|
||||
return output_deps
|
|
@ -1,44 +0,0 @@
|
|||
load("//hack/bazel/docker:publish.bzl", "publish")
|
||||
load("@io_bazel_rules_docker//docker/util:run.bzl", "container_run_and_commit_layer")
|
||||
load("@io_bazel_rules_docker//container:container.bzl", "container_image")
|
||||
|
||||
container_run_and_commit_layer(
|
||||
name = "bazel-layer",
|
||||
commands = [
|
||||
"go get -u github.com/bazelbuild/bazelisk",
|
||||
"ln /go/bin/bazelisk /usr/bin/bazel",
|
||||
"go get -u github.com/bazelbuild/buildtools/...",
|
||||
],
|
||||
image = "@devcontainergo//image",
|
||||
)
|
||||
|
||||
container_run_and_commit_layer(
|
||||
name = "node-layer",
|
||||
commands = [
|
||||
"su vscode -c 'source /usr/local/share/nvm/nvm.sh && nvm install lts/* 2>&1'",
|
||||
],
|
||||
image = "@devcontainergo//image",
|
||||
)
|
||||
|
||||
container_image(
|
||||
name = "dev-container",
|
||||
base = "@devcontainergo//image",
|
||||
layers = [
|
||||
":bazel-layer",
|
||||
":node-layer",
|
||||
],
|
||||
)
|
||||
|
||||
publish(
|
||||
name = "publish-dev-container",
|
||||
image = ":dev-container",
|
||||
service = "dev-container",
|
||||
)
|
||||
|
||||
publish(
|
||||
name = "publish-dev-container-dockerhub",
|
||||
image = ":dev-container",
|
||||
prefix = "roleypoly/",
|
||||
registry = "index.docker.io",
|
||||
service = "dev-container",
|
||||
)
|
|
@ -1,24 +0,0 @@
|
|||
# Dev Container
|
||||
|
||||
This package houses the dev-container image.
|
||||
|
||||
It includes:
|
||||
|
||||
- go (1.15.2)
|
||||
- bazel (latest via bazelisk)
|
||||
- node (latest lts via nvm)
|
||||
|
||||
As well as any other tooling within VSCode Dev Containers.
|
||||
|
||||
## Building
|
||||
|
||||
To build and use locally,
|
||||
|
||||
```sh
|
||||
bazel run //srv/dev-container && docker run -it --rm bazel/src/dev-container:dev-container
|
||||
```
|
||||
|
||||
To just use, this is published to two registries. There is no effective difference, except that GitHub's registry requires login, and Docker Hub does not.
|
||||
|
||||
- `docker pull roleypoly/dev-container:main`
|
||||
- `docker pull docker.pkg.github.com/roleypoly/roleypoly/dev-container:main`
|
|
@ -1,14 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
cd $(dirname $(realpath $0))
|
||||
cd ..
|
||||
|
||||
bazel run //:gazelle
|
||||
bazel run //:gazelle -- update-repos -from_file=./go.mod --to_macro=go_dependencies.bzl%go_repositories -prune=true
|
||||
bazel run //:gazelle
|
||||
|
||||
sleep 0.5
|
||||
echo "Fixing go_dependencies.bzl..."
|
||||
head -n2 ../go_dependencies.bzl >../go_dependencies.bzl~
|
||||
tail -n+3 ../go_dependencies.bzl | sed '/^$/d' >>../go_dependencies.bzl~
|
||||
mv ../go_dependencies.bzl~ ../go_dependencies.bzl
|
|
@ -1,7 +0,0 @@
|
|||
package hacknotused
|
||||
|
||||
//go:generate sh gazelle.sh
|
||||
|
||||
func noop() {
|
||||
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
#!/bin/bash
|
||||
echo "STABLE_GIT_COMMIT $(git rev-parse --short HEAD)"
|
||||
echo "STABLE_GIT_BRANCH $(git rev-parse --abbrev-ref HEAD)"
|
||||
echo "STABLE_URL_SAFE_TAG $(git rev-parse --abbrev-ref HEAD | tr '/' '-')"
|
||||
echo "BUILD_DATE $(date -Iseconds)"
|
Loading…
Add table
Add a link
Reference in a new issue