Skip to content

Commit 3003ebf

Browse files
authored
backport: part 6 (#250)
1 parent 181831b commit 3003ebf

File tree

9 files changed

+91
-134
lines changed

9 files changed

+91
-134
lines changed

.github/workflows/apisix-conformance-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ jobs:
8888
8989
- name: Loading Docker Image to Kind Cluster
9090
run: |
91+
make kind-load-adc-image
9192
make kind-load-ingress-image
9293
9394
- name: Run Conformance Test

.github/workflows/apisix-e2e-test.yml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,22 @@ jobs:
5252
with:
5353
go-version: "1.23"
5454

55-
- name: Install kind
56-
run: |
57-
go install sigs.k8s.io/[email protected]
58-
5955
- name: Login to Registry
6056
uses: docker/login-action@v3
6157
with:
6258
registry: ${{ secrets.DOCKER_REGISTRY }}
6359
username: ${{ secrets.DOCKER_USERNAME }}
6460
password: ${{ secrets.DOCKER_PASSWORD }}
6561

62+
- name: Setup Node.js
63+
uses: actions/setup-node@v3
64+
with:
65+
node-version: "*"
66+
67+
- name: Install kind
68+
run: |
69+
go install sigs.k8s.io/[email protected]
70+
6671
- name: Install ginkgo
6772
run: |
6873
make install-ginkgo
@@ -73,32 +78,32 @@ jobs:
7378
ARCH: amd64
7479
ENABLE_PROXY: "false"
7580
BASE_IMAGE_TAG: "debug"
76-
ADC_VERSION: "dev"
7781
run: |
7882
echo "building images..."
7983
make build-image
8084
81-
- name: Extract adc binary
82-
run: |
83-
echo "Extracting adc binary..."
84-
docker create --name adc-temp api7/api7-ingress-controller:dev
85-
docker cp adc-temp:/bin/adc /usr/local/bin/adc
86-
docker rm adc-temp
87-
chmod +x /usr/local/bin/adc
88-
echo "ADC binary extracted to /usr/local/bin/adc"
89-
9085
- name: Launch Kind Cluster
9186
run: |
9287
make kind-up
9388
9489
- name: Loading Docker Image to Kind Cluster
9590
run: |
91+
make kind-load-adc-image
9692
make kind-load-ingress-image
9793
9894
- name: Install Gateway API And CRDs
9995
run: |
10096
make install
10197
98+
- name: Extract adc binary
99+
if: ${{ env.ADC_VERSION == 'dev' }}
100+
run: |
101+
docker create --name adc-temp ghcr.io/api7/adc:dev
102+
docker cp adc-temp:main.js adc.js
103+
docker rm adc-temp
104+
node $(pwd)/adc.js -v
105+
echo "ADC_BIN=node $(pwd)/adc.js" >> $GITHUB_ENV
106+
102107
- name: Run E2E test suite
103108
shell: bash
104109
env:

.github/workflows/conformance-test.yml

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ concurrency:
3030
cancel-in-progress: true
3131

3232
jobs:
33-
prepare:
34-
name: Prepare
33+
conformance-test:
34+
timeout-minutes: 60
3535
runs-on: ubuntu-latest
3636
steps:
3737
- name: Checkout
3838
uses: actions/checkout@v4
39+
with:
40+
submodules: recursive
3941

4042
- name: Setup Go Env
41-
id: go
4243
uses: actions/setup-go@v4
4344
with:
4445
go-version: "1.23"
@@ -53,21 +54,6 @@ jobs:
5354
chmod 700 get_helm.sh
5455
./get_helm.sh
5556
56-
conformance-test:
57-
timeout-minutes: 60
58-
needs:
59-
- prepare
60-
runs-on: ubuntu-latest
61-
steps:
62-
- name: Checkout
63-
uses: actions/checkout@v4
64-
with:
65-
submodules: recursive
66-
67-
- name: Setup Go Env
68-
uses: actions/setup-go@v4
69-
with:
70-
go-version: "1.23"
7157
- name: Login to Registry
7258
uses: docker/login-action@v3
7359
with:

.github/workflows/e2e-test-k8s.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,6 @@ jobs:
8686
echo "building images..."
8787
make build-image
8888
89-
- name: Extract adc binary
90-
run: |
91-
echo "Extracting adc binary..."
92-
docker create --name adc-temp api7/api7-ingress-controller:dev
93-
docker cp adc-temp:/bin/adc /usr/local/bin/adc
94-
docker rm adc-temp
95-
chmod +x /usr/local/bin/adc
96-
echo "ADC binary extracted to /usr/local/bin/adc"
97-
9889
- name: Install v2 CRDs
9990
run: |
10091
make install-crds-nocel
@@ -107,6 +98,15 @@ jobs:
10798
run: |
10899
make kind-load-images
109100
101+
- name: Extract adc binary
102+
if: ${{ env.ADC_VERSION == 'dev' }}
103+
run: |
104+
docker create --name adc-temp ghcr.io/api7/adc:dev
105+
docker cp adc-temp:main.js adc.js
106+
docker rm adc-temp
107+
node $(pwd)/adc.js -v
108+
echo "ADC_BIN=node $(pwd)/adc.js" >> $GITHUB_ENV
109+
110110
- name: Run E2E test suite
111111
shell: bash
112112
env:

.github/workflows/e2e-test.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,6 @@ jobs:
8181
echo "building images..."
8282
make build-image
8383
84-
- name: Extract adc binary
85-
run: |
86-
echo "Extracting adc binary..."
87-
docker create --name adc-temp api7/api7-ingress-controller:dev
88-
docker cp adc-temp:/bin/adc /usr/local/bin/adc
89-
docker rm adc-temp
90-
chmod +x /usr/local/bin/adc
91-
echo "ADC binary extracted to /usr/local/bin/adc"
92-
9384
- name: Launch Kind Cluster
9485
run: |
9586
make kind-up
@@ -106,6 +97,15 @@ jobs:
10697
run: |
10798
make kind-load-images
10899
100+
- name: Extract adc binary
101+
if: ${{ env.ADC_VERSION == 'dev' }}
102+
run: |
103+
docker create --name adc-temp ghcr.io/api7/adc:dev
104+
docker cp adc-temp:main.js adc.js
105+
docker rm adc-temp
106+
node $(pwd)/adc.js -v
107+
echo "ADC_BIN=node $(pwd)/adc.js" >> $GITHUB_ENV
108+
109109
- name: Run E2E test suite
110110
shell: bash
111111
env:

Dockerfile

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,12 @@
1717

1818
ARG BASE_IMAGE_TAG=nonroot
1919

20-
FROM debian:bullseye-slim AS deps
21-
WORKDIR /workspace
22-
23-
ARG TARGETARCH
24-
ARG ADC_VERSION
25-
26-
RUN apt update \
27-
&& apt install -y wget \
28-
&& wget https://github.com/api7/adc/releases/download/v${ADC_VERSION}/adc_${ADC_VERSION}_linux_${TARGETARCH}.tar.gz -O adc.tar.gz \
29-
&& tar -zxvf adc.tar.gz \
30-
&& mv adc /bin/adc \
31-
&& rm -rf adc.tar.gz \
32-
&& apt autoremove -y wget
33-
3420
FROM gcr.io/distroless/cc-debian12:${BASE_IMAGE_TAG}
3521

3622
ARG TARGETARCH
3723

3824
WORKDIR /app
3925

40-
COPY --from=deps /bin/adc /bin/adc
4126
COPY ./bin/apisix-ingress-controller_${TARGETARCH} ./apisix-ingress-controller
4227
COPY ./config/samples/config.yaml ./conf/config.yaml
4328

Dockerfile.dev

Lines changed: 0 additions & 50 deletions
This file was deleted.

Makefile

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ KIND_NODE_IMAGE ?= kindest/node:v1.30.0@sha256:047357ac0cfea04663786a612ba1eaba9
3131

3232
GATEAY_API_VERSION ?= v1.2.0
3333
DASHBOARD_VERSION ?= dev
34-
ADC_VERSION ?= 0.20.0
34+
ADC_VERSION ?= 0.21.0
3535

3636
GINKGO_VERSION ?= 2.20.0
3737
TEST_TIMEOUT ?= 80m
@@ -133,7 +133,7 @@ kind-e2e-test: kind-up build-image kind-load-images e2e-test
133133

134134
# Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors.
135135
.PHONY: e2e-test
136-
e2e-test:
136+
e2e-test: adc
137137
@kind get kubeconfig --name $(KIND_NAME) > $$KUBECONFIG
138138
DASHBOARD_VERSION=$(DASHBOARD_VERSION) go test $(TEST_DIR) -test.timeout=$(TEST_TIMEOUT) -v -ginkgo.v -ginkgo.focus="$(TEST_FOCUS)" -ginkgo.label-filter="$(TEST_LABEL)"
139139

@@ -145,7 +145,7 @@ download-api7ee3-chart:
145145
@echo "Downloaded API7EE3 chart"
146146

147147
.PHONY: ginkgo-e2e-test
148-
ginkgo-e2e-test:
148+
ginkgo-e2e-test: adc
149149
@ginkgo -cover -coverprofile=coverage.txt -r --randomize-all --randomize-suites --trace --focus=$(E2E_FOCUS) --nodes=$(E2E_NODES) --label-filter="$(TEST_LABEL)" $(TEST_DIR)
150150

151151
.PHONY: install-ginkgo
@@ -184,13 +184,12 @@ kind-down:
184184
|| echo "kind cluster does not exist"
185185

186186
.PHONY: kind-load-images
187-
kind-load-images: pull-infra-images kind-load-ingress-image
187+
kind-load-images: pull-infra-images kind-load-ingress-image kind-load-adc-image
188188
@kind load docker-image hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-gateway:dev --name $(KIND_NAME)
189189
@kind load docker-image hkccr.ccs.tencentyun.com/api7-dev/api7-ee-dp-manager:$(DASHBOARD_VERSION) --name $(KIND_NAME)
190190
@kind load docker-image hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-integrated:$(DASHBOARD_VERSION) --name $(KIND_NAME)
191191
@kind load docker-image kennethreitz/httpbin:latest --name $(KIND_NAME)
192192
@kind load docker-image jmalloc/echo-server:latest --name $(KIND_NAME)
193-
@kind load docker-image ghcr.io/api7/adc:dev --name $(KIND_NAME)
194193
@kind load docker-image apache/apisix:dev --name $(KIND_NAME)
195194

196195
.PHONY: kind-load-gateway-image
@@ -202,14 +201,16 @@ kind-load-dashboard-images:
202201
@kind load docker-image hkccr.ccs.tencentyun.com/api7-dev/api7-ee-dp-manager:$(DASHBOARD_VERSION) --name $(KIND_NAME)
203202
@kind load docker-image hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-integrated:$(DASHBOARD_VERSION) --name $(KIND_NAME)
204203

205-
.PHONY: kind-load-adc-image
206-
kind-load-adc-image:
207-
@kind load docker-image ghcr.io/api7/adc:dev --name $(KIND_NAME)
208-
209204
.PHONY: kind-load-ingress-image
210205
kind-load-ingress-image:
211206
@kind load docker-image $(IMG) --name $(KIND_NAME)
212207

208+
.PHONY: kind-load-adc-image
209+
kind-load-adc-image:
210+
@docker pull ghcr.io/api7/adc:$(ADC_VERSION)
211+
@docker tag ghcr.io/api7/adc:$(ADC_VERSION) ghcr.io/api7/adc:dev
212+
@kind load docker-image ghcr.io/api7/adc:dev --name $(KIND_NAME)
213+
213214
.PHONY: pull-infra-images
214215
pull-infra-images:
215216
@docker pull hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-gateway:dev
@@ -244,11 +245,11 @@ build-multi-arch:
244245
.PHONY: build-multi-arch-image
245246
build-multi-arch-image: build-multi-arch
246247
# daemon.json: "features":{"containerd-snapshotter": true}
247-
@docker buildx build --load --platform linux/amd64,linux/arm64 --build-arg ADC_VERSION=$(ADC_VERSION) -t $(IMG) .
248+
@docker buildx build --load --platform linux/amd64,linux/arm64 -t $(IMG) .
248249

249250
.PHONY: build-push-multi-arch-image
250251
build-push-multi-arch-image: build-multi-arch
251-
@docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg ADC_VERSION=$(ADC_VERSION) -t $(IMG) .
252+
@docker buildx build --push --platform linux/amd64,linux/arm64 -t $(IMG) .
252253

253254
.PHONY: run
254255
run: manifests generate fmt vet ## Run a controller from your host.
@@ -259,12 +260,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
259260
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
260261
.PHONY: docker-build
261262
docker-build: set-e2e-goos build ## Build docker image with the manager.
262-
@echo "Building with ADC_VERSION=$(ADC_VERSION)"
263-
@if [ "$(strip $(ADC_VERSION))" = "dev" ]; then \
264-
$(CONTAINER_TOOL) build -t ${IMG} -f Dockerfile.dev . ; \
265-
else \
266-
$(CONTAINER_TOOL) build --build-arg ADC_VERSION=${ADC_VERSION} -t ${IMG} -f Dockerfile . ; \
267-
fi
263+
$(CONTAINER_TOOL) build -t ${IMG} -f Dockerfile .
268264

269265
.PHONY: docker-push
270266
docker-push: ## Push docker image with the manager.
@@ -341,13 +337,17 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize
341337
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
342338
ENVTEST ?= $(LOCALBIN)/setup-envtest
343339
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
340+
ADC_BIN ?= $(LOCALBIN)/adc
344341

345342
## Tool Versions
346343
KUSTOMIZE_VERSION ?= v5.4.2
347344
CONTROLLER_TOOLS_VERSION ?= v0.17.2
348345
ENVTEST_VERSION ?= release-0.18
349346
GOLANGCI_LINT_VERSION ?= v2.1.5
350347

348+
## export PATH so that the tools are found
349+
export PATH := $(LOCALBIN):$(PATH)
350+
351351
.PHONY: kustomize
352352
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
353353
$(KUSTOMIZE): $(LOCALBIN)
@@ -368,6 +368,16 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
368368
$(GOLANGCI_LINT): $(LOCALBIN)
369369
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(LOCALBIN) $(GOLANGCI_LINT_VERSION)
370370

371+
.PHONY: adc
372+
adc: $(ADC_BIN) ## Download adc locally if necessary.
373+
$(ADC_BIN):
374+
ifeq ($(ADC_VERSION),dev)
375+
@echo "ADC_VERSION=dev, skip download"
376+
else
377+
curl -sSfL https://github.com/api7/adc/releases/download/v${ADC_VERSION}/adc_${ADC_VERSION}_${GOOS}_${GOARCH}.tar.gz \
378+
| tar -xz -C $(LOCALBIN)
379+
endif
380+
371381
gofmt: ## Apply go fmt
372382
@gofmt -w -r 'interface{} -> any' .
373383
@gofmt -w -r 'FIt -> It' test

0 commit comments

Comments
 (0)