From a58ebfb46eaa0caf0f643eaf34ae06bd1c7a6fb0 Mon Sep 17 00:00:00 2001 From: David Boenig Date: Wed, 10 Jun 2020 16:05:34 +0100 Subject: [PATCH 1/3] Add workflow for Github Actions --- .github/workflows/ci.yml | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..9325cf2c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,59 @@ +name: Continuous Integration + +on: + push: + branches: + - '**' + pull_request: + branches: + - master + schedule: + - cron: '* 4 * * *' + +env: + DOCKER_BUILDKIT: 1 + DOCKER_NETWORK: ${{ github.run_id }} + DOCKER_NETWORK_ALIAS: nginx-plus-test + DOCKER_NGINX_PLUS: nginx-plus-${{ github.run_id }} + DOCKER_NGINX_PLUS_HELPER: nginx-plus-helper-${{ github.run_id }} + GOLANG_VERSION: 1.14 + +jobs: + + build: + name: Build Go Client + runs-on: ubuntu-18.04 + if: (github.repository == 'nginxinc/nginx-plus-go-client') + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + - name: Fetch Certificates + env: + CRT: ${{ secrets.NGINX_CRT }} + KEY: ${{ secrets.NGINX_KEY }} + run: | + echo "${CRT}" | base64 --decode > docker/nginx-repo.crt + echo "${KEY}" | base64 --decode > docker/nginx-repo.key + - name: Setup Go Environment + uses: actions/setup-go@v2 + with: + go-version: '^${{ env.GOLANG_VERSION }}' + - name: Import packages + run: | + go get -u github.com/nginxinc/nginx-plus-go-client/client + go get -u github.com/nginxinc/nginx-plus-go-client/tests/helpers + - name: Build & Test Client + if: (github.event_name != 'schedule') + run: make test + - name: Switch Repository (Nightly) + if: (github.event_name == 'schedule') + run: | + sed -i 's|plus-pkgs|pkgs-test|g' docker/Dockerfile + sed -i '20,31d' docker/Dockerfile + sed -i 's|deb https|deb [trusted=yes] https|g' docker/Dockerfile + sed -i 's|nginx-plus=\${NGINX_PLUS_VERSION}|nginx-plus|g' docker/Dockerfile + - name: Build & Test Client (Nightly) + if: (github.event_name == 'schedule') + run: make test + env: + NGINX_PLUS_VERSION: nightly \ No newline at end of file From 3ee2b344c2b868b91932cd119a8e9e8a36b9f394 Mon Sep 17 00:00:00 2001 From: David Boenig Date: Mon, 15 Jun 2020 16:01:33 +0100 Subject: [PATCH 2/3] Add workflow for Github Actions --- .github/workflows/ci.yml | 12 ++---------- Makefile | 42 ++++++++++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9325cf2c..2103c868 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: branches: - master schedule: - - cron: '* 4 * * *' + - cron: '* 5 * * *' env: DOCKER_BUILDKIT: 1 @@ -34,14 +34,6 @@ jobs: run: | echo "${CRT}" | base64 --decode > docker/nginx-repo.crt echo "${KEY}" | base64 --decode > docker/nginx-repo.key - - name: Setup Go Environment - uses: actions/setup-go@v2 - with: - go-version: '^${{ env.GOLANG_VERSION }}' - - name: Import packages - run: | - go get -u github.com/nginxinc/nginx-plus-go-client/client - go get -u github.com/nginxinc/nginx-plus-go-client/tests/helpers - name: Build & Test Client if: (github.event_name != 'schedule') run: make test @@ -56,4 +48,4 @@ jobs: if: (github.event_name == 'schedule') run: make test env: - NGINX_PLUS_VERSION: nightly \ No newline at end of file + NGINX_PLUS_VERSION: nightly diff --git a/Makefile b/Makefile index 6cb531db..e8817084 100644 --- a/Makefile +++ b/Makefile @@ -1,38 +1,56 @@ NGINX_PLUS_VERSION=19-1 NGINX_IMAGE=nginxplus:$(NGINX_PLUS_VERSION) DOCKER_NETWORK?=test +DOCKER_NETWORK_ALIAS=nginx-plus-test DOCKER_NGINX_PLUS?=nginx-plus DOCKER_NGINX_PLUS_HELPER?=nginx-plus-helper -export TEST_API_ENDPOINT=http://127.0.0.1:8080/api -export TEST_API_ENDPOINT_OF_HELPER=http://127.0.0.1:8090/api -export TEST_UNAVAILABLE_STREAM_ADDRESS=127.0.0.1:8081 +GOLANG_CONTAINER=golang:1.14 +GOLANGCI_CONTAINER=golangci/golangci-lint:v1.27-alpine + +export TEST_API_ENDPOINT=http://$(DOCKER_NGINX_PLUS):8080/api +export TEST_API_ENDPOINT_OF_HELPER=http://$(DOCKER_NGINX_PLUS_HELPER):8080/api +export TEST_UNAVAILABLE_STREAM_ADDRESS=$(DOCKER_NGINX_PLUS):8081 test: docker-build run-nginx-plus test-run configure-no-stream-block test-run-no-stream-block clean lint: - golangci-lint run + docker run --rm \ + -v $(shell pwd):/go/src/github.com/nginxinc/nginx-plus-go-client \ + -w /go/src/github.com/nginxinc/nginx-plus-go-client \ + $(GOLANGCI_CONTAINER) golangci-lint run docker-build: docker build --build-arg NGINX_PLUS_VERSION=$(NGINX_PLUS_VERSION)~stretch -t $(NGINX_IMAGE) docker run-nginx-plus: docker network create --driver bridge $(DOCKER_NETWORK) - docker run --network=$(DOCKER_NETWORK) -d --name $(DOCKER_NGINX_PLUS) --network-alias=nginx-plus-test --rm -p 8080:8080 -p 8081:8081 $(NGINX_IMAGE) - 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) + docker run --network=$(DOCKER_NETWORK) -d --name $(DOCKER_NGINX_PLUS) --network-alias=$(DOCKER_NETWORK_ALIAS) --rm -p 8080:8080 -p 8081:8081 $(NGINX_IMAGE) + 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) test-run: - go test client/* - go clean -testcache - go test tests/client_test.go + docker run --rm \ + --network=$(DOCKER_NETWORK) \ + -e TEST_API_ENDPOINT \ + -e TEST_API_ENDPOINT_OF_HELPER \ + -e TEST_UNAVAILABLE_STREAM_ADDRESS \ + -v $(shell pwd):/go/src/github.com/nginxinc/nginx-plus-go-client \ + -w /go/src/github.com/nginxinc/nginx-plus-go-client \ + $(GOLANG_CONTAINER) /bin/sh -c "go test client/*; go clean -testcache; go test tests/client_test.go" configure-no-stream-block: docker cp docker/nginx_no_stream.conf $(DOCKER_NGINX_PLUS):/etc/nginx/nginx.conf docker exec $(DOCKER_NGINX_PLUS) nginx -s reload -test-run-no-stream-block: - go clean -testcache - go test tests/client_no_stream_test.go +test-run-no-stream-block: configure-no-stream-block + docker run --rm \ + --network=$(DOCKER_NETWORK) \ + -e TEST_API_ENDPOINT \ + -e TEST_API_ENDPOINT_OF_HELPER \ + -e TEST_UNAVAILABLE_STREAM_ADDRESS \ + -v $(shell pwd):/go/src/github.com/nginxinc/nginx-plus-go-client \ + -w /go/src/github.com/nginxinc/nginx-plus-go-client \ + $(GOLANG_CONTAINER) /bin/sh -c "go clean -testcache; go test tests/client_no_stream_test.go" clean: -docker kill $(DOCKER_NGINX_PLUS) From c13fefe8130fd56cb0c313770ae51196a25e8a1a Mon Sep 17 00:00:00 2001 From: David Boenig Date: Tue, 16 Jun 2020 10:15:18 +0100 Subject: [PATCH 3/3] Remove old pipeline files --- .github/workflows/ci.yml | 1 - build/ci/Jenkinsfile | 7 ------- 2 files changed, 8 deletions(-) delete mode 100644 build/ci/Jenkinsfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2103c868..4fff7bfb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,6 @@ env: DOCKER_NETWORK_ALIAS: nginx-plus-test DOCKER_NGINX_PLUS: nginx-plus-${{ github.run_id }} DOCKER_NGINX_PLUS_HELPER: nginx-plus-helper-${{ github.run_id }} - GOLANG_VERSION: 1.14 jobs: diff --git a/build/ci/Jenkinsfile b/build/ci/Jenkinsfile deleted file mode 100644 index 29045a62..00000000 --- a/build/ci/Jenkinsfile +++ /dev/null @@ -1,7 +0,0 @@ -node { - git( - url: "${libsLocation}", - credentialsId: "${githubCreds}" - ) - load 'nginx-plus-go-client/Jenkinsfile' -} \ No newline at end of file