Skip to content

Commit db78e3f

Browse files
authored
1.37 (#53)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
1 parent 2d4b47f commit db78e3f

22 files changed

Lines changed: 609 additions & 349 deletions

.github/workflows/commit.yaml

Lines changed: 22 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ on:
77
branches: [ main ]
88

99
jobs:
10-
rust:
11-
name: Rust Build and Test (${{ matrix.platform.arch }}, ${{ matrix.platform.os }})
10+
build_and_test:
11+
name: Build and Test (${{ matrix.platform.arch }}, ${{ matrix.platform.os }})
1212
runs-on: ${{ matrix.platform.os }}
13-
defaults:
14-
run:
15-
working-directory: ./rust
1613
strategy:
1714
fail-fast: false
1815
matrix:
@@ -28,6 +25,19 @@ jobs:
2825
- name: Checkout repository
2926
uses: actions/checkout@v4
3027

28+
- uses: actions/setup-go@v5
29+
with:
30+
cache: false
31+
go-version-file: go/go.mod
32+
33+
- uses: actions/cache@v4
34+
with:
35+
path: |
36+
~/.cache/go-build
37+
~/go/pkg/mod
38+
~/go/bin
39+
key: go-test-${{ hashFiles('**/go.mod', '**/go.sum') }}
40+
3141
- name: Cache Cargo registry
3242
uses: actions/cache@v4
3343
with:
@@ -51,58 +61,13 @@ jobs:
5161
override: true
5262
components: clippy, rustfmt
5363

54-
- name: Check formatting
55-
run: cargo fmt -- --check
56-
57-
- name: Run Clippy linter
58-
run: cargo clippy -- -D warnings
59-
60-
- name: Build project
61-
run: cargo build --verbose
62-
63-
- name: Run tests
64-
run: cargo test --verbose
65-
66-
go:
67-
name: Go Build and Test (${{ matrix.platform.arch }}, ${{ matrix.platform.os }})
68-
runs-on: ${{ matrix.platform.os }}
69-
defaults:
70-
run:
71-
working-directory: ./go
72-
strategy:
73-
fail-fast: false
74-
matrix:
75-
platform:
76-
- os: ubuntu-22.04
77-
arch: amd64
78-
- os: ubuntu-22.04-arm
79-
arch: arm64
80-
- os: macos-latest
81-
arch: arm64
82-
83-
steps:
84-
- name: Checkout repository
85-
uses: actions/checkout@v4
86-
87-
- uses: actions/setup-go@v5
88-
with:
89-
cache: false
90-
go-version-file: go/go.mod
91-
92-
- uses: actions/cache@v4
93-
with:
94-
path: |
95-
~/.cache/go-build
96-
~/go/pkg/mod
97-
~/go/bin
98-
key: go-test-${{ hashFiles('**/go.mod', '**/go.sum') }}
99-
100-
- run: CGO_ENABLED=0 go test ./... -v
101-
- run: go build -buildmode=c-shared -o main.so
102-
- run: go tool golangci-lint run
64+
- run: make check
65+
- run: make test
66+
- run: make build
67+
- run: make integration-test
10368

10469
docker_build_and_integration_test:
105-
name: Build and Run Integration Tests
70+
name: Integration Test with Docker Image
10671
runs-on: ubuntu-latest
10772
steps:
10873
- name: Checkout
@@ -162,9 +127,9 @@ jobs:
162127
cache-from: type=gha
163128
cache-to: type=gha,mode=max
164129

165-
integration_test_on_main:
130+
docker_build_and_integration_test_on_main:
166131
needs: [docker_build_and_integration_test]
167-
name: Integration Test (${{ matrix.platform.arch }})
132+
name: Integration Test with Docker Image (${{ matrix.platform.arch }})
168133
# This will only run on push events to the main branch.
169134
# Mainly to check the multi-arch image by running the
170135
# integration tests on both architectures.

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ RUN cp /build/target/x86_64-unknown-linux-gnu/debug/librust_module.so /build/amd
3232
##### Build the Go library #####
3333

3434
# We use zig to cross-compile the Go library for both x86_64 and aarch64 architectures.
35-
FROM --platform=$BUILDPLATFORM golang:1.24.2 AS go_builder
35+
FROM --platform=$BUILDPLATFORM golang:1.25.6 AS go_builder
3636
# Install zig.
3737
ARG ZIG_VERSION=0.14.0
3838
RUN apt update && apt install -y curl xz-utils
@@ -46,7 +46,7 @@ RUN CC="zig cc -target aarch64-linux-gnu" CXX="zig c++ -target aarch64-linux-gnu
4646
RUN CC="zig cc -target x86_64-linux-gnu" CXX="zig c++ -target x86_64-linux-gnu" CGO_ENABLED=1 GOARCH=amd64 go build -buildmode=c-shared -o /build/amd64_libgo_module.so .
4747

4848
##### Build the final image #####
49-
FROM envoyproxy/envoy:v1.36.2 AS envoy
49+
FROM envoyproxy/envoy:v1.37.0 AS envoy
5050
ARG TARGETARCH
5151
ENV ENVOY_DYNAMIC_MODULES_SEARCH_PATH=/usr/local/lib
5252
COPY --from=rust_builder /build/${TARGETARCH}_librust_module.so /usr/local/lib/librust_module.so

ENVOY_VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

Makefile

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
CYAN := \033[36m
2+
GREEN := \033[32m
3+
YELLOW := \033[33m
4+
RESET := \033[0m
5+
BOLD := \033[1m
6+
7+
define print_task
8+
printf "$(BOLD)$(CYAN)[TASK]$(RESET) $(BOLD)%s$(RESET)\n" "$(1)"
9+
endef
10+
define print_subtask
11+
printf " $(YELLOW)$(RESET) %s\n" "$(1)"
12+
endef
13+
define print_success
14+
printf " $(GREEN)$(RESET) %s\n" "$(1)"
15+
endef
16+
17+
## help: Show this help info.
18+
.PHONY: help
19+
help:
20+
@echo "Envoy Dynamic Modules.\n"
21+
@echo "Usage:\n make \033[36m<Target>\033[0m \n\nTargets:"
22+
@awk 'BEGIN {FS = ":.*##"; printf ""} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
23+
24+
# This runs all necessary steps to prepare for a commit.
25+
.PHONY: precommit
26+
precommit: ## Run all necessary steps to prepare for a commit.
27+
precommit: precommit-go precommit-rust
28+
29+
.PHONY: precommit-go
30+
precommit-go: ## This runs the linter, formatter, and tidy on the Go codebase.
31+
@$(call print_task,Tidying Go modules)
32+
@find . -name "go.mod" \
33+
| grep go.mod \
34+
| xargs -I {} bash -c 'dirname {}' \
35+
| xargs -I {} bash -c 'cd {} && $(call print_subtask,Tidying {}) && go mod tidy -v;'
36+
@$(call print_success,Tidying completed)
37+
@$(call print_task,Running linter)
38+
@$(call print_subtask,Checking ./...)
39+
@cd go && go tool golangci-lint run --build-tags==cgo ./...
40+
@$(call print_success,Linting completed)
41+
@$(call print_task,Formatting code)
42+
@$(call print_subtask,Running gofmt)
43+
@cd go && find . -type f -name '*.go' | xargs gofmt -s -w
44+
@$(call print_subtask,Running gofumpt)
45+
@cd go && find . -type f -name '*.go' | xargs go tool gofumpt -l -w
46+
@$(call print_subtask,Running gci)
47+
@cd go && go tool gci write -s standard -s default -s "prefix(github.com/envoyproxy/dynamic-modules-examples)" `find . -name '*.go'`
48+
@$(call print_success,Formatting completed)
49+
50+
.PHONY: precommt-rust
51+
precommit-rust: ## This runs the linter, formatter, and tidy on the Rust codebase.
52+
@$(call print_task,Running Rust precommit steps)
53+
@$(call print_subtask,Running cargo fmt)
54+
@cd rust && cargo fmt --all -- --check
55+
@$(call print_subtask,Running cargo clippy)
56+
@cd rust && cargo clippy -- -D warnings
57+
@$(call print_success,Rust precommit steps completed)
58+
59+
# This runs precommit and checks for any differences in the codebase, failing if there are any.
60+
.PHONY: check
61+
check: precommit ## Run all necessary steps to prepare for a commit and check for any differences in the codebase.
62+
@$(call print_task,Checking for uncommitted changes)
63+
@if [ ! -z "`git status -s`" ]; then \
64+
echo "$(BOLD)$(YELLOW)The following differences will fail CI until committed:$(RESET)"; \
65+
git diff --exit-code; \
66+
echo "$(BOLD)$(YELLOW)Please ensure you have run 'make precommit' and committed the changes.$(RESET)"; \
67+
exit 1; \
68+
fi
69+
@$(call print_success,No uncommitted changes found)
70+
71+
.PHONY: test
72+
test: test-rust test-rust ## Run all tests for the codebase.
73+
.PHONY: test-go
74+
test-go:## Run the unit tests for the Go codebase. This doesn't run the integration tests like test-* targets.
75+
@$(call print_task,Running Go tests)
76+
@cd go && go test -v ./...
77+
@$(call print_success,Go unit tests completed)
78+
.PHONY: test-rust
79+
test-rust: ## Run the unit tests for the Rust codebase.
80+
@$(call print_task,Running Rust tests)
81+
@cd rust && cargo test
82+
@$(call print_success,Rust unit tests completed)
83+
84+
.PHONY: build
85+
build: build-go build-rust ## Build all dynamic modules.
86+
87+
.PHONY: build-go
88+
build-go: ## Build the Go dynamic module.
89+
@$(call print_task,Building Go dynamic module)
90+
@cd go && go build -buildmode=c-shared -o libgo_module.so .
91+
@$(call print_success,Go dynamic module built at go/libgo_module.so)
92+
@$(call print_task,Copying Go dynamic module for easier use with Envoy)
93+
@cp go/libgo_module.so integration/libgo_module.so
94+
95+
.PHONY: build-rust
96+
build-rust: ## Build the Rust dynamic module.
97+
@$(call print_task,Building Rust dynamic module)
98+
@cd rust && cargo build
99+
@$(call print_success,Rust dynamic module built at rust/target/debug/librust_module.so)
100+
@$(call print_task,Copying Rust dynamic module for easier use with Envoy)
101+
@cp rust/target/debug/librust_module.dylib integration/librust_module.so || true
102+
@cp rust/target/debug/librust_module.so integration/librust_module.so || true
103+
104+
.PHONY: integration-test
105+
integration-test: build-go build-rust ## Run the integration tests.
106+
@$(call print_task,Running integration tests)
107+
@cd integration && go test -v ./...
108+
@$(call print_success,Integration tests completed)

README.md

Lines changed: 7 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Dynamic Modules Examples
22

3-
> Envoy Version: [dc2d3098ae5641555f15c71d5bb5ce0060a8015c] v1.36.2
3+
> Envoy Version: v1.37.0
44
>
55
> Since dynamic modules are tied with a specific Envoy version, this repository is based on the specific commit of Envoy.
66
> For examples for a specific Envoy version, please check out `release/v<version>` branches:
@@ -29,67 +29,14 @@ The tracking issue for dynamic modules in general is [here](https://github.com/e
2929

3030
## Development
3131

32-
### Rust Dynamic Module
33-
34-
To build and test the modules locally without Envoy, you can use `cargo` to build them just like any other Rust project:
35-
36-
```
37-
cd rust
38-
cargo build
39-
cargo test
40-
cargo clippy -- -D warnings
41-
cargo fmt --all -- --check
42-
```
43-
44-
### Go Dynamic Module
45-
To build and test the modules locally without Envoy, you can use `go` to build them just like any other Go project:
46-
47-
```
48-
cd go
49-
go test ./... -v
50-
go build -buildmode=c-shared -o libgo_module.so .
51-
go tool golangci-lint run
52-
find . -type f -name '*.go' | xargs go tool gofumpt -l -w
53-
```
54-
55-
### Build Envoy + Example Dynamic Module Docker Image
56-
57-
To build the example modules and bundle them with Envoy, simply run
58-
59-
```
60-
docker buildx build . -t envoy-with-dynamic-modules:latest [--platform linux/amd64,linux/arm64]
61-
```
62-
63-
where `--platform` is optional and can be used to build for multiple platforms.
64-
65-
### Run Envoy + Example Dynamic Module Docker Image
66-
67-
The example Envoy configuration yaml is in [`integration/envoy.yaml`](integration/envoy.yaml) which is also used
68-
to run the integration tests. Assuming you built the Docker image with the tag `envoy-with-dynamic-modules:latest`, you can run Envoy with the following command:
69-
70-
```
71-
docker run --network host -v $(pwd):/examples -w /examples/integration envoy-with-dynamic-modules:latest --config-path ./envoy.yaml
72-
```
73-
74-
Then execute, for example, the following command to test the passthrough and access log filters:
75-
76-
```
77-
curl localhost:1062/uuid
78-
```
79-
80-
### Run integration tests with the built example Envoy + Dynamic Module Docker Image.
81-
82-
The integration tests are in the `integration` directory. Assuming you built the Docker image with the tag `envoy-with-dynamic-modules:latest`, you can run the integration tests with the following command:
83-
```
84-
cd integration
85-
go test . -v -count=1
86-
```
87-
88-
If you want to explicitly specify the docker image, use `ENVOY_IMAGE` environment variable:
8932
```
90-
ENVOY_IMAGE=foo-bar-image:latest go test . -v -count=1
33+
# Run all unit tests
34+
make test
35+
# Build all dynamic modules
36+
make build
37+
# Run integration tests with Envoy via func-e (no local installation required)
38+
make integration-test
9139
```
9240

93-
[dc2d3098ae5641555f15c71d5bb5ce0060a8015c]: https://github.com/envoyproxy/envoy/tree/dc2d3098ae5641555f15c71d5bb5ce0060a8015c
9441
[Envoy]: https://github.com/envoyproxy/envoy
9542
[High Level Doc]: https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/advanced/dynamic_modules

0 commit comments

Comments
 (0)