Skip to content

Migrate continuous integration to Github workflows #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Continuous Integration

on:
push:
branches:
- '**'
pull_request:
branches:
- master
schedule:
- cron: '* 5 * * *'

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 }}

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: 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
42 changes: 30 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
7 changes: 0 additions & 7 deletions build/ci/Jenkinsfile

This file was deleted.