Skip to content

Commit 530f997

Browse files
wu-shengclaudekezhenxu94
authored
feat: migrate to testcontainers-go v0.42.0 and upgrade dependencies (#146)
* feat: migrate to testcontainers-go v0.42.0 and upgrade all major dependencies - Delete compose_provider.go (601 lines) — custom DockerContainer/DockerProvider re-implementation replaced by native testcontainers-go APIs - Delete compose_listener.go (85 lines) — Docker event listener no longer needed; containers are accessible after stack.Up() via stack.ServiceContainer() - Rewrite compose.go to use compose.NewDockerComposeWith + stack.Up/ServiceContainer - Rewrite cleanup/compose.go to use stack.Down - Upgrade testcontainers-go v0.11.1 → v0.42.0 - Upgrade docker/docker v20.10.7 → v28.5.2 - Upgrade k8s.io/* v0.22.2 → v0.35.3 - Upgrade sigs.k8s.io/kind v0.27.0 → v0.31.0 - Upgrade spf13/cobra v1.8.0 → v1.10.2 - Remove docker-compose v1 binary install from CI (v0.42.0 uses Docker Compose v2 plugin) - Update action.yaml Go version to 1.26 Closes #139 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: add multi-platform CI build matrix and CGO_ENABLED support Split Build workflow into lint-and-test + build-platform (ubuntu/windows/macos) matrix jobs. Enable CGO for native builds. Update Dockerfile with build-essential for CGO. Change `make build` to build for current OS only (CI matrix handles cross-platform). Based on #139 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: remove compose.Wait(true) to avoid requiring all containers healthy compose.Wait(true) maps to `docker compose up --wait` which requires ALL containers to remain running and healthy. This is too strict for e2e tests where some containers may not have healthchecks or may exit after init. Port readiness is already handled by WaitForService() with per-port wait strategies. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: remove containerd image store disable workaround No longer needed — testcontainers-go v0.42.0 uses Docker Compose v2 plugin which fully supports the containerd image store. Reverts the workaround added in 8c21e43 (#140). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: add manual port waiting after compose up WaitForService strategies only execute when compose.Wait(true) is passed, but compose.Wait(true) is too strict (requires all containers healthy). Instead, manually wait for each port via TCP dial after Up() returns, matching the old code's behavior of waitPortUntilReady(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: restore DOCKER_API_VERSION negotiation in action.yaml Docker SDK v28.5.2 defaults to API v1.51, but GitHub Actions runners may only support up to v1.48. Set DOCKER_API_VERSION to the daemon's supported version to ensure compatibility. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: add logging to port waiting and try immediately before polling Add INFO-level logs for port wait start/completion and DEBUG-level for retry attempts. Also try connecting immediately before the first ticker interval to avoid unnecessary 500ms delay when ports are already ready. Log when a service has no ports to wait for. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: wait for Docker healthcheck before port readiness check After stack.Up(), wait for each container's Docker healthcheck to pass (if defined) before doing TCP port checks. This matches the old behavior where docker-compose up -d would respect depends_on: condition: service_healthy. Also restored internal container port check (/proc/net/tcp + nc + /dev/tcp) from the old WaitPort implementation to align with original behavior. The wait sequence is now: 1. stack.Up(ctx) — start containers 2. waitForHealthy — poll Docker health status until healthy (if healthcheck defined) 3. waitForPort — external TCP dial + internal container check 4. Export env vars Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: only wait for healthcheck on services with ports The old code only waited for services that had ports: in docker-compose.yml. Services without ports were completely skipped. The healthcheck wait was incorrectly running on ALL services, causing timeouts on services like init containers or senders whose healthchecks depend on other services. Now: services without ports get log streaming only. Services with ports get healthcheck wait + port wait + env export (matching old behavior). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: remove healthcheck waiting, use only TCP+internal port check The old code never checked Docker healthcheck status. It only did TCP dial + internal /proc/net/tcp check. Many compose files use healthchecks with tools (nc) not available in the container image, causing Docker to mark containers as unhealthy even when the application is running fine. Remove waitForHealthy entirely to match old behavior exactly: port-level waiting only, no Docker healthcheck dependency. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: restore build target to build all platforms for release The build target must build all platforms (windows/linux/darwin) because release-bin depends on it. Each platform build uses CGO_FLAG to enable CGO only for native builds. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: build only current platform per CI matrix runner Each matrix runner (ubuntu/windows/macos) now builds only its own platform instead of all three redundantly. The `make build` target is preserved for release which needs all platforms. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ci: simplify build matrix by moving OS-to-target mapping into matrix include --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: kezhenxu94 <kezhenxu94@apache.org>
1 parent ef073ad commit 530f997

13 files changed

Lines changed: 989 additions & 2184 deletions

File tree

.github/workflows/build.yaml

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# the Apache License, Version 2.0 (the "License"); you may
66
# not use this file except in compliance with the License.
77
# You may obtain a copy of the License at
8-
#
8+
#
99
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
10+
#
1111
# Unless required by applicable law or agreed to in writing,
1212
# software distributed under the License is distributed on an
1313
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -17,16 +17,14 @@
1717
#
1818

1919
name: Build
20-
2120
on:
2221
pull_request:
2322
push:
2423
branches:
2524
- main
26-
2725
jobs:
28-
build:
29-
name: Build
26+
lint-and-test:
27+
name: Lint and Test
3028
runs-on: ubuntu-latest
3129
steps:
3230
- name: Set up Go
@@ -36,23 +34,51 @@ jobs:
3634
cache-dependency-path: |
3735
go.sum
3836
id: go
39-
4037
- name: Check out code into the Go module directory
4138
uses: actions/checkout@v4
42-
4339
- name: Check License
4440
uses: apache/skywalking-eyes@ec88b7d850018c8983f87729ea88549e100c5c82
4541
env:
4642
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47-
4843
- name: Lint Codes
4944
run: make lint
50-
5145
- name: Test
52-
run: make test
53-
46+
run: CGO_ENABLED=1 make test
47+
build-platform:
48+
name: Build (${{ matrix.os }})
49+
strategy:
50+
matrix:
51+
include:
52+
- os: ubuntu-latest
53+
target: linux
54+
- os: windows-latest
55+
target: windows
56+
- os: macos-latest
57+
target: darwin
58+
runs-on: ${{ matrix.os }}
59+
steps:
60+
- name: Set up Go
61+
uses: actions/setup-go@v5
62+
with:
63+
go-version: 1.26
64+
cache-dependency-path: |
65+
go.sum
66+
id: go
67+
- name: Check out code into the Go module directory
68+
uses: actions/checkout@v4
5469
- name: Build
55-
run: make build
56-
70+
run: make ${{ matrix.target }}
5771
- name: Build Docker Image
72+
if: matrix.os == 'ubuntu-latest'
5873
run: make docker
74+
build:
75+
name: Build
76+
runs-on: ubuntu-latest
77+
needs:
78+
- lint-and-test
79+
- build-platform
80+
steps:
81+
- name: Check out code into the Go module directory
82+
uses: actions/checkout@v4
83+
- name: Result
84+
run: echo "Lint and Test, Build (ubuntu-latest), Build (windows-latest), Build (macos-latest) completed successfully!"

.github/workflows/e2e-test.yaml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,7 @@ jobs:
4444
uses: actions/checkout@v4
4545

4646
- name: Build e2e
47-
run: make linux
48-
49-
- name: Install docker-compose
50-
shell: bash
51-
run: |
52-
if ! command docker-compose 2>&1 > /dev/null; then
53-
echo "Installing docker-compose"
54-
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
55-
sudo chmod +x /usr/local/bin/docker-compose
56-
fi
47+
run: CGO_ENABLED=1 make linux
5748

5849
- name: Run E2E Test
5950
uses: apache/skywalking-infra-e2e@main

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# the Apache License, Version 2.0 (the "License"); you may
66
# not use this file except in compliance with the License.
77
# You may obtain a copy of the License at
8-
#
8+
#
99
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
10+
#
1111
# Unless required by applicable law or agreed to in writing,
1212
# software distributed under the License is distributed on an
1313
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -22,7 +22,10 @@ WORKDIR /e2e
2222

2323
COPY . .
2424

25-
RUN make linux
25+
# Install build dependencies for CGO
26+
RUN apt-get update && apt-get install -y build-essential && rm -rf /var/lib/apt/lists/*
27+
28+
RUN CGO_ENABLED=1 make linux
2629

2730
FROM golang:1.26 AS bin
2831

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ GO := GO111MODULE=on go
2525
GO_PATH = $(shell $(GO) env GOPATH)
2626
GOARCH ?= $(shell $(GO) env GOARCH)
2727
GOOS ?= $(shell $(GO) env GOOS)
28+
HOST_GOOS = $(shell $(GO) env GOOS)
29+
HOST_GOARCH = $(shell $(GO) env GOARCH)
30+
# CGO is enabled only for native builds; cross-compilation requires target SDK
31+
CGO_FLAG = $(shell if [ "$(os)" = "$(HOST_GOOS)" ] && [ "$(GOARCH)" = "$(HOST_GOARCH)" ]; then echo 1; else echo 0; fi)
2832
GO_BUILD = $(GO) build
2933
GO_TEST = $(GO) test
3034
GO_LINT = $(GO_PATH)/bin/golangci-lint
@@ -57,7 +61,7 @@ windows: PROJECT_SUFFIX=.exe
5761
.PHONY: $(PLATFORMS)
5862
$(PLATFORMS):
5963
mkdir -p $(OUT_DIR)
60-
GOOS=$(os) GOARCH=$(GOARCH) $(GO_BUILD) $(GO_BUILD_FLAGS) -ldflags "$(GO_BUILD_LDFLAGS)" -o $(OUT_DIR)/$(os)/$(PROJECT)$(PROJECT_SUFFIX) cmd/e2e/main.go
64+
GOOS=$(os) GOARCH=$(GOARCH) CGO_ENABLED=$(CGO_FLAG) $(GO_BUILD) $(GO_BUILD_FLAGS) -ldflags "$(GO_BUILD_LDFLAGS)" -o $(OUT_DIR)/$(os)/$(PROJECT)$(PROJECT_SUFFIX) cmd/e2e/main.go
6165

6266
.PHONY: build
6367
build: windows linux darwin

action.yaml

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,14 @@ inputs:
3131
runs:
3232
using: "composite"
3333
steps:
34-
- name: Disable containerd image store
34+
- name: Set Docker API version
3535
shell: bash
3636
run: |
37-
DAEMON_JSON="/etc/docker/daemon.json"
38-
if [ -f "$DAEMON_JSON" ]; then
39-
sudo jq '. + {"features": {"containerd-snapshotter": false}}' "$DAEMON_JSON" \
40-
| sudo tee "${DAEMON_JSON}.tmp" > /dev/null
41-
sudo mv "${DAEMON_JSON}.tmp" "$DAEMON_JSON"
42-
else
43-
echo '{"features": {"containerd-snapshotter": false}}' \
44-
| sudo tee "$DAEMON_JSON" > /dev/null
45-
fi
46-
sudo systemctl restart docker
47-
docker version
48-
docker info
4937
echo "DOCKER_API_VERSION=$(docker version --format '{{.Server.APIVersion}}')" >> "$GITHUB_ENV"
50-
- name: Install docker-compose
51-
shell: bash
52-
if: runner.os != 'Windows'
53-
run: |
54-
if ! command docker-compose 2>&1 > /dev/null; then
55-
echo "Installing docker-compose"
56-
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
57-
sudo chmod +x /usr/local/bin/docker-compose
58-
fi
5938
- name: Set up Go
60-
uses: actions/setup-go@v4
39+
uses: actions/setup-go@v5
6140
with:
62-
go-version: 1.24
41+
go-version: 1.26
6342
cache-dependency-path: ${{ github.action_path }}/go.sum
6443
- shell: bash
6544
run: make -C $GITHUB_ACTION_PATH install DESTDIR=/usr/local/bin

0 commit comments

Comments
 (0)