Skip to content

Commit 286bb46

Browse files
committed
wasm-cc: Fix example
Signed-off-by: Ryan Northey <ryan@synca.io>
1 parent b9635cb commit 286bb46

31 files changed

+492
-57
lines changed

.bazelignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
.github
12
node_modules
3+
wasm-cc

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ common:examples --action_env=BUILDKIT_PROGRESS
1616
common:examples --host_action_env=BUILDKIT_PROGRESS
1717
common:examples --sandbox_writable_path=/var/run/docker.sock
1818

19+
common --@rules_python//python/config_settings:bootstrap_impl=script
20+
1921
try-import %workspace%/user.bazelrc
2022
try-import %workspace%/repo.bazelrc

.github/workflows/_verify_wasm.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Verify/Wasm
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_call:
8+
9+
10+
jobs:
11+
wasm:
12+
runs-on: ubuntu-24.04
13+
steps:
14+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
15+
- run: |
16+
docker pull envoyproxy/envoy:dev
17+
DEV_CONTAINER_ID=$(docker inspect --format='{{.Id}}' envoyproxy/envoy:dev)
18+
echo "DEV_CONTAINER_ID=${DEV_CONTAINER_ID}" >> $GITHUB_ENV
19+
- run: |
20+
./verify.sh
21+
working-directory: wasm-cc

.github/workflows/docs.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ jobs:
2727
path: examples
2828
- run: |
2929
export UID
30-
docker compose run --quiet --quiet-pull --quiet-build docs
30+
echo 'load("@envoy_examples//bazel:env.bzl", "envoy_examples_env")' >> ../envoy/WORKSPACE
31+
echo 'envoy_examples_env()' >> ../envoy/WORKSPACE
32+
docker compose run docs
3133
working-directory: examples
3234
env:
3335
BAZEL_BUILD_EXTRA_OPTIONS: >-
3436
--override_repository=envoy_examples=../examples
3537
--config=ci
3638
--@rules_python//python/config_settings:bootstrap_impl=script
37-
DOCKER_BUILDKIT: 1
38-
COMPOSE_BAKE: true
3939
BUILDKIT_PROGRESS: quiet
40+
COMPOSE_BAKE: true
41+
DOCKER_BUILDKIT: 1

.github/workflows/verify.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ concurrency:
1717
jobs:
1818
examples:
1919
uses: ./.github/workflows/_verify_examples.yml
20+
wasm:
21+
uses: ./.github/workflows/_verify_wasm.yml

BUILD

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ load("//:examples.bzl", "envoy_examples")
44

55
licenses(["notice"]) # Apache 2
66

7+
# Excluding build tests - eg wasm - these should be run directly
78
EXAMPLE_TESTS = [
89
"brotli",
910
"cache",
@@ -40,7 +41,6 @@ EXAMPLE_TESTS = [
4041
"udp",
4142
"vrp-litmus",
4243
# "vrp-local",
43-
# "wasm-cc",
4444
"websocket",
4545
"zipkin",
4646
"zstd",
@@ -66,7 +66,7 @@ filegroup(
6666
"postgres/*",
6767
"kafka/*.yaml",
6868
],
69-
),
69+
) + ["@envoy-example-wasmcc//:configs"],
7070
visibility = ["//visibility:public"],
7171
)
7272

@@ -95,7 +95,7 @@ filegroup(
9595

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

101101
pkg_files(
@@ -112,16 +112,20 @@ genrule(
112112
cmd = """
113113
TEMP=$$(mktemp -d)
114114
for location in $(locations :docs_rst); do
115-
example=$$(echo $$location | sed -e 's#^external/[^/]*/##' | cut -d/ -f1)
116-
cp -a $$location "$${TEMP}/$${example}.rst"
115+
if [[ "$$location" == *"/envoy-example"* ]]; then
116+
example="$$(echo "$$location" | cut -d- -f3- | cut -d/ -f1)"
117+
else
118+
example=$$(echo $$location | sed -e 's#^external/[^/]*/##' | cut -d/ -f1)
119+
fi
120+
cp -aL $$location "$${TEMP}/$${example}.rst"
117121
echo " $${example}" >> "$${TEMP}/_toctree.rst"
118122
done
119123
echo ".. toctree::" > "$${TEMP}/toctree.rst"
120124
echo " :maxdepth: 1" >> "$${TEMP}/toctree.rst"
121125
echo "" >> "$${TEMP}/toctree.rst"
122126
cat "$${TEMP}/_toctree.rst" | sort >> "$${TEMP}/toctree.rst"
123127
rm "$${TEMP}/_toctree.rst"
124-
tar czf $@ -C $${TEMP} .
128+
tar chzf $@ -C $${TEMP} .
125129
""",
126130
)
127131

@@ -134,32 +138,32 @@ filegroup(
134138
filegroup(
135139
name = "files",
136140
srcs = glob(
137-
[
138-
"**/*",
139-
],
141+
["**/*"],
140142
exclude = [
141143
"**/*~",
142144
"**/.*",
143145
"**/#*",
144146
".*/**/*",
145147
"BUILD",
146-
".git/**/*",
148+
"README.md",
149+
"WORKSPACE",
147150
"bazel-*/**/*",
148151
"**/node_modules/**",
149152
"**/*.rst",
150153
"win32*",
151154
],
152-
) + [
153-
"//wasm-cc:files",
154-
],
155+
),
155156
)
156157

157158
pkg_tar(
158159
name = "docs",
159160
srcs = [":examples_files"],
160161
extension = "tar.gz",
161162
package_dir = "start/sandboxes",
162-
deps = [":examples_docs"],
163+
deps = [
164+
":examples_docs",
165+
"@envoy-example-wasmcc//:includes",
166+
],
163167
visibility = ["//visibility:public"],
164168
)
165169

WORKSPACE

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
workspace(name = "envoy-examples")
1+
workspace(name = "envoy_examples")
2+
3+
load("//bazel:env.bzl", "envoy_examples_env")
4+
envoy_examples_env()
25

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

912
load("//bazel:toolchains.bzl", "load_envoy_examples_toolchains")
1013
load_envoy_examples_toolchains()
14+
15+
load("//bazel:packages.bzl", "load_envoy_examples_packages")
16+
load_envoy_examples_packages()

bazel/archives.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2+
load("@envoy-example-wasmcc//bazel:archives.bzl", "load_envoy_example_wasmcc_archives")
23
load("//bazel:versions.bzl", "VERSIONS")
34

45
def load_github_archives():
@@ -36,3 +37,4 @@ def load_http_archives():
3637
def load_envoy_examples_archives():
3738
load_github_archives()
3839
load_http_archives()
40+
load_envoy_example_wasmcc_archives()

bazel/deps.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
load("@envoy-example-wasmcc//bazel:deps.bzl", "resolve_envoy_example_wasmcc_dependencies")
12
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies")
23
load("@rules_python//python:repositories.bzl", "py_repositories")
34

45
def resolve_envoy_examples_dependencies():
56
go_rules_dependencies()
67
py_repositories()
8+
resolve_envoy_example_wasmcc_dependencies()

bazel/env.bzl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
load("//bazel:nested.bzl", "load_envoy_nested_examples")
2+
3+
def _impl(ctx):
4+
need = ctx.os.environ.get("ENVOY_EXAMPLES_LLVM_ENABLED") == "1"
5+
ctx.file("llvm_flag.bzl", content = "LLVM_ENABLED = %s\n" % need)
6+
ctx.file("WORKSPACE", content = "")
7+
ctx.file("BUILD", content = "")
8+
9+
_envoy_examples_env = repository_rule(
10+
implementation = _impl,
11+
environ = ["ENVOY_EXAMPLES_LLVM_ENABLED"],
12+
)
13+
14+
def envoy_examples_env():
15+
_envoy_examples_env(name = "envoy_examples_env")
16+
load_envoy_nested_examples()

0 commit comments

Comments
 (0)