Skip to content

Commit 5ef0c08

Browse files
Migrate continuous integration to Github workflows (#43)
* Add workflow for Github Actions * Remove old pipeline files
1 parent e11aefd commit 5ef0c08

File tree

3 files changed

+80
-19
lines changed

3 files changed

+80
-19
lines changed

.github/workflows/ci.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
branches:
9+
- master
10+
schedule:
11+
- cron: '* 5 * * *'
12+
13+
env:
14+
DOCKER_BUILDKIT: 1
15+
DOCKER_NETWORK: ${{ github.run_id }}
16+
DOCKER_NETWORK_ALIAS: nginx-plus-test
17+
DOCKER_NGINX_PLUS: nginx-plus-${{ github.run_id }}
18+
DOCKER_NGINX_PLUS_HELPER: nginx-plus-helper-${{ github.run_id }}
19+
20+
jobs:
21+
22+
build:
23+
name: Build Go Client
24+
runs-on: ubuntu-18.04
25+
if: (github.repository == 'nginxinc/nginx-plus-go-client')
26+
steps:
27+
- name: Checkout Repository
28+
uses: actions/checkout@v2
29+
- name: Fetch Certificates
30+
env:
31+
CRT: ${{ secrets.NGINX_CRT }}
32+
KEY: ${{ secrets.NGINX_KEY }}
33+
run: |
34+
echo "${CRT}" | base64 --decode > docker/nginx-repo.crt
35+
echo "${KEY}" | base64 --decode > docker/nginx-repo.key
36+
- name: Build & Test Client
37+
if: (github.event_name != 'schedule')
38+
run: make test
39+
- name: Switch Repository (Nightly)
40+
if: (github.event_name == 'schedule')
41+
run: |
42+
sed -i 's|plus-pkgs|pkgs-test|g' docker/Dockerfile
43+
sed -i '20,31d' docker/Dockerfile
44+
sed -i 's|deb https|deb [trusted=yes] https|g' docker/Dockerfile
45+
sed -i 's|nginx-plus=\${NGINX_PLUS_VERSION}|nginx-plus|g' docker/Dockerfile
46+
- name: Build & Test Client (Nightly)
47+
if: (github.event_name == 'schedule')
48+
run: make test
49+
env:
50+
NGINX_PLUS_VERSION: nightly

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)

build/ci/Jenkinsfile

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

0 commit comments

Comments
 (0)