From ecea6a00afef7531a6f1200c6a0c8838f5307719 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Moal Date: Tue, 22 Jun 2021 11:42:51 +0200 Subject: [PATCH] Add CI tests using Github actions --- .github/workflows/test.yml | 45 ++++++++++++++++++++++++++++++++++++++ Makefile | 8 +++++++ 2 files changed, 53 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 Makefile diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..66f0c74 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,45 @@ +on: [push, pull_request] +name: Test +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + go-version: [1.15.x, 1.16.x] + + services: + etc: + image: quay.io/coreos/etcd + ports: + - 2379:2379 + env: + ETCD_ADVERTISE_CLIENT_URLS: http://0.0.0.0:2379 + ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379 + consul: + image: consul + ports: + - 8500:8500 + vault096: + image: vault:0.9.6 + ports: + - 8200:8200 + env: + VAULT_DEV_ROOT_TOKEN_ID: root + VAULT_DEV_LISTEN_ADDRESS: 0.0.0.0:8200 + vault010: + image: vault:0.10.0 + ports: + - 8222:8200 + env: + VAULT_DEV_ROOT_TOKEN_ID: root + VAULT_DEV_LISTEN_ADDRESS: 0.0.0.0:8200 + + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + - name: Checkout code + uses: actions/checkout@v2 + - name: Test + run: make test diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4d463a3 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +VAULT_ADDR ?= http://127.0.0.1:8200 + +.PHONY: test + +test: + go build + VAULT_ADDR="$(VAULT_ADDR)" \ + go test -v -race -cover -timeout=1m ./... && echo OK || (echo FAIL && exit 1)