Skip to content

Commit 9e8ba7d

Browse files
committed
Add workflow for Github CI, adjust Makefile to use Docker
1 parent 73aa001 commit 9e8ba7d

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
branches:
99
- master
1010
schedule:
11-
- cron: '* 4 * * *'
11+
- cron: '* 5 * * *'
1212

1313
env:
1414
DOCKER_BUILDKIT: 1
@@ -34,10 +34,6 @@ jobs:
3434
run: |
3535
echo "${CRT}" | base64 --decode > docker/nginx-repo.crt
3636
echo "${KEY}" | base64 --decode > docker/nginx-repo.key
37-
- name: Setup Go Environment
38-
uses: actions/setup-go@v2
39-
with:
40-
go-version: '^${{ env.GOLANG_VERSION }}'
4137
- name: Build & Test Client
4238
if: (github.event_name != 'schedule')
4339
run: make test

Makefile

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,56 @@
11
NGINX_PLUS_VERSION=19-1
22
NGINX_IMAGE=nginxplus:$(NGINX_PLUS_VERSION)
33
DOCKER_NETWORK?=test
4+
DOCKER_NETWORK_ALIAS=nginx-plus-test
45
DOCKER_NGINX_PLUS?=nginx-plus
56
DOCKER_NGINX_PLUS_HELPER?=nginx-plus-helper
67

7-
export TEST_API_ENDPOINT=http://127.0.0.1:8080/api
8-
export TEST_API_ENDPOINT_OF_HELPER=http://127.0.0.1:8090/api
9-
export TEST_UNAVAILABLE_STREAM_ADDRESS=127.0.0.1:8081
8+
GOLANG_CONTAINER=golang:1.14
9+
GOLANGCI_CONTAINER=golangci/golangci-lint:v1.27-alpine
10+
11+
export TEST_API_ENDPOINT=http://$(DOCKER_NGINX_PLUS):8080/api
12+
export TEST_API_ENDPOINT_OF_HELPER=http://$(DOCKER_NGINX_PLUS_HELPER):8080/api
13+
export TEST_UNAVAILABLE_STREAM_ADDRESS=$(DOCKER_NGINX_PLUS):8081
1014

1115
test: docker-build run-nginx-plus test-run configure-no-stream-block test-run-no-stream-block clean
1216

1317
lint:
14-
golangci-lint run
18+
docker run --rm \
19+
-v $(shell pwd):/go/src/github.com/nginxinc/nginx-plus-go-client \
20+
-w /go/src/github.com/nginxinc/nginx-plus-go-client \
21+
$(GOLANGCI_CONTAINER) golangci-lint run
1522

1623
docker-build:
1724
docker build --build-arg NGINX_PLUS_VERSION=$(NGINX_PLUS_VERSION)~stretch -t $(NGINX_IMAGE) docker
1825

1926
run-nginx-plus:
2027
docker network create --driver bridge $(DOCKER_NETWORK)
21-
docker run --network=$(DOCKER_NETWORK) -d --name $(DOCKER_NGINX_PLUS) --network-alias=nginx-plus-test --rm -p 8080:8080 -p 8081:8081 $(NGINX_IMAGE)
22-
docker run --network=$(DOCKER_NETWORK) -d --name $(DOCKER_NGINX_PLUS_HELPER) --network-alias=nginx-plus-test --rm -p 8090:8080 -p 8091:8081 $(NGINX_IMAGE)
28+
docker run --network=$(DOCKER_NETWORK) -d --name $(DOCKER_NGINX_PLUS) --network-alias=$(DOCKER_NETWORK_ALIAS) --rm -p 8080:8080 -p 8081:8081 $(NGINX_IMAGE)
29+
docker run --network=$(DOCKER_NETWORK) -d --name $(DOCKER_NGINX_PLUS_HELPER) --network-alias=$(DOCKER_NETWORK_ALIAS) --rm -p 8090:8080 -p 8091:8081 $(NGINX_IMAGE)
2330

2431
test-run:
25-
go test client/*
26-
go clean -testcache
27-
go test tests/client_test.go
32+
docker run --rm \
33+
--network=$(DOCKER_NETWORK) \
34+
-e TEST_API_ENDPOINT \
35+
-e TEST_API_ENDPOINT_OF_HELPER \
36+
-e TEST_UNAVAILABLE_STREAM_ADDRESS \
37+
-v $(shell pwd):/go/src/github.com/nginxinc/nginx-plus-go-client \
38+
-w /go/src/github.com/nginxinc/nginx-plus-go-client \
39+
$(GOLANG_CONTAINER) /bin/sh -c "go test client/*; go clean -testcache; go test tests/client_test.go"
2840

2941
configure-no-stream-block:
3042
docker cp docker/nginx_no_stream.conf $(DOCKER_NGINX_PLUS):/etc/nginx/nginx.conf
3143
docker exec $(DOCKER_NGINX_PLUS) nginx -s reload
3244

33-
test-run-no-stream-block:
34-
go clean -testcache
35-
go test tests/client_no_stream_test.go
45+
test-run-no-stream-block: configure-no-stream-block
46+
docker run --rm \
47+
--network=$(DOCKER_NETWORK) \
48+
-e TEST_API_ENDPOINT \
49+
-e TEST_API_ENDPOINT_OF_HELPER \
50+
-e TEST_UNAVAILABLE_STREAM_ADDRESS \
51+
-v $(shell pwd):/go/src/github.com/nginxinc/nginx-plus-go-client \
52+
-w /go/src/github.com/nginxinc/nginx-plus-go-client \
53+
$(GOLANG_CONTAINER) /bin/sh -c "go clean -testcache; go test tests/client_no_stream_test.go"
3654

3755
clean:
3856
-docker kill $(DOCKER_NGINX_PLUS)

0 commit comments

Comments
 (0)