From 0dd5b8bf85d6f9d4976c4b4ae512310a6bf700b1 Mon Sep 17 00:00:00 2001 From: Steve Sloka Date: Wed, 11 Mar 2020 17:09:47 -0400 Subject: [PATCH] CI: Github Actions (#127) Signed-off-by: Steve Sloka --- .github/workflows/master.yaml | 35 ++++++++++++++++++++++++++++++ .github/workflows/pullrequest.yaml | 29 +++++++++++++++++++++++++ .github/workflows/release.yaml | 34 +++++++++++++++++++++++++++++ .travis.yml | 13 ----------- Makefile | 17 +++++++++++---- 5 files changed, 111 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/master.yaml create mode 100644 .github/workflows/pullrequest.yaml create mode 100644 .github/workflows/release.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/master.yaml b/.github/workflows/master.yaml new file mode 100644 index 00000000..5d323a3d --- /dev/null +++ b/.github/workflows/master.yaml @@ -0,0 +1,35 @@ +name: Build and push :master image + +on: + push: + branches: + - master + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: check format + run: make check_format + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: deps + run: sudo apt-get update -y && sudo apt-get install stunnel4 redis -y + + - name: build and push docker image + run: | + redis-server --port 6380 & + redis-server --port 6381 --requirepass password123 & + redis-server --port 6382 --requirepass password123 & + redis-server --port 6384 --requirepass password123 & + redis-server --port 6385 --requirepass password123 & + echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + make bootstrap bootstrap_redis_tls docker_push + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + VERSION: master \ No newline at end of file diff --git a/.github/workflows/pullrequest.yaml b/.github/workflows/pullrequest.yaml new file mode 100644 index 00000000..2e22c6d8 --- /dev/null +++ b/.github/workflows/pullrequest.yaml @@ -0,0 +1,29 @@ +name: CI Build and Test for PR + +on: + pull_request: + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: check format + run: make check_format + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: deps + run: sudo apt-get update -y && sudo apt-get install stunnel4 redis -y + + - name: build and test + run: | + redis-server --port 6380 & + redis-server --port 6381 --requirepass password123 & + redis-server --port 6382 --requirepass password123 & + redis-server --port 6384 --requirepass password123 & + redis-server --port 6385 --requirepass password123 & + make bootstrap bootstrap_redis_tls tests_unit tests \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..28569b0a --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,34 @@ +name: Build and push :release image + +on: + push: + tags: + - 'v*' + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: check format + run: make check_format + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: deps + run: sudo apt-get update -y && sudo apt-get install stunnel4 redis -y + + - name: build and push docker image + run: | + redis-server --port 6380 & + redis-server --port 6381 --requirepass password123 & + redis-server --port 6382 --requirepass password123 & + redis-server --port 6384 --requirepass password123 & + redis-server --port 6385 --requirepass password123 & + echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + make bootstrap bootstrap_redis_tls docker_push + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e6485c57..00000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -sudo: required -language: go -go: "1.14" -services: redis-server -before_install: sudo apt-get update -y && sudo apt-get install stunnel4 -y -install: make bootstrap bootstrap_redis_tls -before_script: -- redis-server --port 6380 & -- redis-server --port 6381 --requirepass password123 & -- redis-server --port 6382 --requirepass password123 & -- redis-server --port 6384 --requirepass password123 & -- redis-server --port 6385 --requirepass password123 & -script: make check_format tests diff --git a/Makefile b/Makefile index ac0850ae..553f6d5e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,10 @@ export GO111MODULE=on +PROJECT = ratelimit +REGISTRY ?= envoyproxy +IMAGE := $(REGISTRY)/$(PROJECT) MODULE = github.com/envoyproxy/ratelimit - +GIT_REF = $(shell git describe --tags || git rev-parse --short=8 --verify HEAD) +VERSION ?= $(GIT_REF) SHELL := /bin/bash .PHONY: bootstrap @@ -67,6 +71,11 @@ tests_unit: compile tests: compile go test -race -tags=integration $(MODULE)/... -.PHONY: docker -docker: tests - docker build . -t envoyproxy/ratelimit:`git rev-parse HEAD` +.PHONY: docker_image +docker_image: tests + docker build . -t $(IMAGE):$(VERSION) + +.PHONY: docker_push +docker_push: docker_image + docker push $(IMAGE):$(VERSION) +