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
2 changes: 2 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.github
node_modules
wasm-cc
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ common:examples --action_env=BUILDKIT_PROGRESS
common:examples --host_action_env=BUILDKIT_PROGRESS
common:examples --sandbox_writable_path=/var/run/docker.sock

common --@rules_python//python/config_settings:bootstrap_impl=script

try-import %workspace%/user.bazelrc
try-import %workspace%/repo.bazelrc
21 changes: 21 additions & 0 deletions .github/workflows/_verify_wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Verify/Wasm

permissions:
contents: read

on:
workflow_call:


jobs:
wasm:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- run: |
docker pull envoyproxy/envoy:dev
DEV_CONTAINER_ID=$(docker inspect --format='{{.Id}}' envoyproxy/envoy:dev)
echo "DEV_CONTAINER_ID=${DEV_CONTAINER_ID}" >> $GITHUB_ENV
- run: |
./verify.sh
working-directory: wasm-cc
8 changes: 5 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ jobs:
path: examples
- run: |
export UID
docker compose run --quiet --quiet-pull --quiet-build docs
echo 'load("@envoy_examples//bazel:env.bzl", "envoy_examples_env")' >> ../envoy/WORKSPACE
echo 'envoy_examples_env()' >> ../envoy/WORKSPACE
docker compose run docs
working-directory: examples
env:
BAZEL_BUILD_EXTRA_OPTIONS: >-
--override_repository=envoy_examples=../examples
--config=ci
--@rules_python//python/config_settings:bootstrap_impl=script
DOCKER_BUILDKIT: 1
COMPOSE_BAKE: true
BUILDKIT_PROGRESS: quiet
COMPOSE_BAKE: true
DOCKER_BUILDKIT: 1
2 changes: 2 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ concurrency:
jobs:
examples:
uses: ./.github/workflows/_verify_examples.yml
wasm:
uses: ./.github/workflows/_verify_wasm.yml
32 changes: 18 additions & 14 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("//:examples.bzl", "envoy_examples")

licenses(["notice"]) # Apache 2

# Excluding build tests - eg wasm - these should be run directly
EXAMPLE_TESTS = [
"brotli",
"cache",
Expand Down Expand Up @@ -40,7 +41,6 @@ EXAMPLE_TESTS = [
"udp",
"vrp-litmus",
# "vrp-local",
# "wasm-cc",
"websocket",
"zipkin",
"zstd",
Expand All @@ -66,7 +66,7 @@ filegroup(
"postgres/*",
"kafka/*.yaml",
],
),
) + ["@envoy-example-wasmcc//:configs"],
visibility = ["//visibility:public"],
)

Expand Down Expand Up @@ -95,7 +95,7 @@ filegroup(

filegroup(
name = "docs_rst",
srcs = glob(["**/example.rst"]) + ["//wasm-cc:example.rst"],
srcs = glob(["**/example.rst"]) + ["@envoy-example-wasmcc//:example.rst"],
)

pkg_files(
Expand All @@ -112,16 +112,20 @@ genrule(
cmd = """
TEMP=$$(mktemp -d)
for location in $(locations :docs_rst); do
example=$$(echo $$location | sed -e 's#^external/[^/]*/##' | cut -d/ -f1)
cp -a $$location "$${TEMP}/$${example}.rst"
if [[ "$$location" == *"/envoy-example"* ]]; then
example="$$(echo "$$location" | cut -d- -f3- | cut -d/ -f1)"
else
example=$$(echo $$location | sed -e 's#^external/[^/]*/##' | cut -d/ -f1)
fi
cp -aL $$location "$${TEMP}/$${example}.rst"
echo " $${example}" >> "$${TEMP}/_toctree.rst"
done
echo ".. toctree::" > "$${TEMP}/toctree.rst"
echo " :maxdepth: 1" >> "$${TEMP}/toctree.rst"
echo "" >> "$${TEMP}/toctree.rst"
cat "$${TEMP}/_toctree.rst" | sort >> "$${TEMP}/toctree.rst"
rm "$${TEMP}/_toctree.rst"
tar czf $@ -C $${TEMP} .
tar chzf $@ -C $${TEMP} .
""",
)

Expand All @@ -134,32 +138,32 @@ filegroup(
filegroup(
name = "files",
srcs = glob(
[
"**/*",
],
["**/*"],
exclude = [
"**/*~",
"**/.*",
"**/#*",
".*/**/*",
"BUILD",
".git/**/*",
"README.md",
"WORKSPACE",
"bazel-*/**/*",
"**/node_modules/**",
"**/*.rst",
"win32*",
],
) + [
"//wasm-cc:files",
],
),
)

pkg_tar(
name = "docs",
srcs = [":examples_files"],
extension = "tar.gz",
package_dir = "start/sandboxes",
deps = [":examples_docs"],
deps = [
":examples_docs",
"@envoy-example-wasmcc//:includes",
],
visibility = ["//visibility:public"],
)

Expand Down
8 changes: 7 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
workspace(name = "envoy-examples")
workspace(name = "envoy_examples")

load("//bazel:env.bzl", "envoy_examples_env")
envoy_examples_env()

load("//bazel:archives.bzl", "load_envoy_examples_archives")
load_envoy_examples_archives()
Expand All @@ -8,3 +11,6 @@ resolve_envoy_examples_dependencies()

load("//bazel:toolchains.bzl", "load_envoy_examples_toolchains")
load_envoy_examples_toolchains()

load("//bazel:packages.bzl", "load_envoy_examples_packages")
load_envoy_examples_packages()
2 changes: 2 additions & 0 deletions bazel/archives.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@envoy-example-wasmcc//bazel:archives.bzl", "load_envoy_example_wasmcc_archives")
load("//bazel:versions.bzl", "VERSIONS")

def load_github_archives():
Expand Down Expand Up @@ -36,3 +37,4 @@ def load_http_archives():
def load_envoy_examples_archives():
load_github_archives()
load_http_archives()
load_envoy_example_wasmcc_archives()
2 changes: 2 additions & 0 deletions bazel/deps.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
load("@envoy-example-wasmcc//bazel:deps.bzl", "resolve_envoy_example_wasmcc_dependencies")
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies")
load("@rules_python//python:repositories.bzl", "py_repositories")

def resolve_envoy_examples_dependencies():
go_rules_dependencies()
py_repositories()
resolve_envoy_example_wasmcc_dependencies()
16 changes: 16 additions & 0 deletions bazel/env.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("//bazel:nested.bzl", "load_envoy_nested_examples")

def _impl(ctx):
need = ctx.os.environ.get("ENVOY_EXAMPLES_LLVM_ENABLED") == "1"
ctx.file("llvm_flag.bzl", content = "LLVM_ENABLED = %s\n" % need)
ctx.file("WORKSPACE", content = "")
ctx.file("BUILD", content = "")

_envoy_examples_env = repository_rule(
implementation = _impl,
environ = ["ENVOY_EXAMPLES_LLVM_ENABLED"],
)

def envoy_examples_env():
_envoy_examples_env(name = "envoy_examples_env")
load_envoy_nested_examples()
28 changes: 28 additions & 0 deletions bazel/nested.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

def _example_repo_impl(ctx):
example_resources = [
"WORKSPACE",
"BUILD",
"bazel",
"envoy.yaml",
"example.rst",
"envoy_filter_http_wasm_updated_example.cc",
"envoy_filter_http_wasm_example.cc",
"Dockerfile-proxy",
]
for d in example_resources:
ctx.symlink(ctx.path(ctx.attr.examples_root).dirname.get_child(ctx.attr.path).get_child(d), d)

example_repository = repository_rule(
implementation = _example_repo_impl,
attrs = {
"examples_root": attr.label(default = "@envoy_examples//:BUILD"),
"path": attr.string(mandatory=True),
},
)

def load_envoy_nested_examples():
example_repository(
name = "envoy-example-wasmcc",
path = "wasm-cc",
)
8 changes: 8 additions & 0 deletions bazel/packages.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@envoy_examples_env//:llvm_flag.bzl", "LLVM_ENABLED")
load("@envoy-example-wasmcc//bazel:packages.bzl", "load_envoy_example_wasmcc_packages")
load("@envoy-example-wasmcc//bazel:toolchains_extra.bzl", "load_envoy_example_wasmcc_toolchains_extra")

def load_envoy_examples_packages():
load_envoy_example_wasmcc_packages()
if LLVM_ENABLED:
load_envoy_example_wasmcc_toolchains_extra()
2 changes: 2 additions & 0 deletions bazel/toolchains.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@envoy-example-wasmcc//bazel:toolchains.bzl", "load_envoy_example_wasmcc_toolchains")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains")
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
load("//bazel:versions.bzl", "VERSIONS")
Expand All @@ -8,3 +9,4 @@ def load_envoy_examples_toolchains():
name = "python%s" % VERSIONS["python"].replace(".", "_"),
python_version = VERSIONS["python"].replace("-", "_"),
)
load_envoy_example_wasmcc_toolchains(go=False)
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
- |
./ci/do_ci.sh docs
environment:
DOCS_BUILD_RST: "${DOCS_BUILD_RST:-}"
BAZEL_BUILD_EXTRA_OPTIONS: >-
${BAZEL_BUILD_EXTRA_OPTIONS:-
--override_repository=envoy_examples=../examples
Expand Down
7 changes: 3 additions & 4 deletions shared/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM envoyproxy/envoy-build-ubuntu:f94a38f62220a2b017878b790b6ea98a0f6c5f9c@sha256:2dd96b6f43c08ccabd5f4747fce5854f5f96af509b32e5cf6493f136e9833649
FROM envoyproxy/envoy-build:ci-cdfbb76bc18c115270127132c6f7c67000cd2e74@sha256:48a8b1bc24ed771560126642dcbba33c50c6b837722ba9c75270b858ef7ab3a6
ENV DEBIAN_FRONTEND=noninteractive
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
apt-get -qq install --no-install-recommends -y gosu \
&& groupadd -f envoygroup \
&& useradd -g envoygroup -m -d /home/envoybuild envoybuild
apt-get -qq update \
&& apt-get -qq install --no-install-recommends -y gosu
2 changes: 1 addition & 1 deletion shared/build/build-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ set -e
if [[ $(id -u envoybuild) != "${BUILD_UID}" ]]; then
usermod -u "${BUILD_UID}" envoybuild
chown envoybuild /home/envoybuild
chown envoybuild /home/envoybuild/.cache
fi

chown envoybuild /output
chmod 1777 /tmp

exec gosu envoybuild "$@"
2 changes: 2 additions & 0 deletions wasm-cc/.bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# only directories can be ignored, and no globbing
.github
7 changes: 7 additions & 0 deletions wasm-cc/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
common --enable_bzlmod=0
common --color=yes
common:ci --noshow_progress
common:ci --noshow_loading_progress
common:ci --test_output=errors

common --@rules_python//python/config_settings:bootstrap_impl=script
1 change: 1 addition & 0 deletions wasm-cc/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.6.0
41 changes: 29 additions & 12 deletions wasm-cc/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@bazel_skylib//lib:selects.bzl", "selects")
# load("@envoy//bazel/wasm:wasm.bzl", "envoy_wasm_cc_binary")
load("@envoy//bazel/wasm:wasm.bzl", "envoy_wasm_cc_binary")
load("@rules_pkg//pkg:pkg.bzl", "pkg_tar")

licenses(["notice"]) # Apache 2

Expand All @@ -8,8 +9,8 @@ exports_files(["example.rst"])
selects.config_setting_group(
name = "include_wasm_config",
match_all = [
"//bazel:x86",
"//bazel:wasm_v8",
"@envoy//bazel:x86",
"@envoy//bazel:wasm_v8",
],
)

Expand All @@ -31,18 +32,34 @@ filegroup(
visibility = ["//visibility:public"],
)

# envoy_wasm_cc_binary(
# name = "envoy_filter_http_wasm_example.wasm",
# srcs = ["envoy_filter_http_wasm_example.cc"],
# )
envoy_wasm_cc_binary(
name = "envoy_filter_http_wasm_example.wasm",
srcs = ["envoy_filter_http_wasm_example.cc"],
)

# envoy_wasm_cc_binary(
# name = "envoy_filter_http_wasm_updated_example.wasm",
# srcs = ["envoy_filter_http_wasm_updated_example.cc"],
# )
envoy_wasm_cc_binary(
name = "envoy_filter_http_wasm_updated_example.wasm",
srcs = ["envoy_filter_http_wasm_updated_example.cc"],
)

filegroup(
name = "files",
srcs = glob(["**/*"], exclude = ["example.rst", "BUILD"]),
srcs = glob(
["**/*"],
exclude = [
"**/*~",
"**/.*",
".*/**/*",
"example.rst",
"BUILD",
"README.md",
"WORKSPACE",
]),
)

pkg_tar(
name = "includes",
srcs = [":files"],
package_dir = "_include/wasm-cc",
visibility = ["//visibility:public"],
)
16 changes: 16 additions & 0 deletions wasm-cc/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
workspace(name = "envoy-example-wasmcc")

load("//bazel:archives.bzl", "load_envoy_example_wasmcc_archives")
load_envoy_example_wasmcc_archives()

load("//bazel:deps.bzl", "resolve_envoy_example_wasmcc_dependencies")
resolve_envoy_example_wasmcc_dependencies()

load("//bazel:toolchains.bzl", "load_envoy_example_wasmcc_toolchains")
load_envoy_example_wasmcc_toolchains()

load("//bazel:packages.bzl", "load_envoy_example_wasmcc_packages")
load_envoy_example_wasmcc_packages()

load("//bazel:toolchains_extra.bzl", "load_envoy_example_wasmcc_toolchains_extra")
load_envoy_example_wasmcc_toolchains_extra()
Empty file added wasm-cc/bazel/BUILD
Empty file.
Loading