Skip to content
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

Added tests in github workflows and updated makefile #84

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: get-version
run: echo "::set-output name=CURRENT_VERSION::$(cat Makefile | head -n1|awk -F= '{print $2}')"
run: |
VERSION=$(grep '^VERSION=' Makefile | awk -F= '{print $2}')
echo "::set-output name=CURRENT_VERSION::$VERSION"

- name: Set up Go
uses: actions/setup-go@v2
with:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: verify

on:
pull_request:
branches: [ '*' ]
push:
branches: [ main ]
workflow_dispatch:

jobs:
verify:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Run tests
run: make all-test
shell: bash
26 changes: 24 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,49 @@
SHELL=bash
VERSION=0.9.16
SOURCE?=./...
VINYLDNS_REPO=github.com/vinyldns/vinyldns
VINYLDNS_DIR="$(GOPATH)/src/$(VINYLDNS_REPO)/"
VINYLDNS_VERSION=latest

# Check that the required version of make is being used
REQ_MAKE_VER:=3.82
ifneq ($(REQ_MAKE_VER),$(firstword $(sort $(MAKE_VERSION) $(REQ_MAKE_VER))))
$(error The version of MAKE $(REQ_MAKE_VER) or higher is required; you are running $(MAKE_VERSION))
endif

ifndef $(GOPATH)
GOPATH=$(shell go env GOPATH)
export GOPATH
endif
.ONESHELL:

all: check-fmt test build integration stop-api validate-version install

.PHONY: fmt
fmt:
gofmt -s -w vinyldns

.PHONY: check-fmt
check-fmt:
test -z "$(shell gofmt -s -l vinyldns | tee /dev/stderr)"

.PHONY: all-test
all-test: test integration

.PHONY: test
test:
go vet $(SOURCE)
GO111MODULE=on go test $(SOURCE) -cover

.PHONY: integration
integration: start-api
GO111MODULE=on go test $(SOURCE) -tags=integration

.PHONY: validate-version
validate-version:
cat vinyldns/version.go | grep 'var Version = "$(VERSION)"'

.PHONY: clone-vinyl
clone-vinyl:
if [ ! -d $(VINYLDNS_DIR) ]; then \
echo "$(VINYLDNS_REPO) not found in your GOPATH (necessary for acceptance tests), getting..."; \
Expand All @@ -36,26 +53,31 @@ clone-vinyl:
else \
git -C $(VINYLDNS_DIR) pull ; \
fi


.PHONY: start-api
start-api: clone-vinyl stop-api
$(GOPATH)/src/$(VINYLDNS_REPO)/quickstart/quickstart-vinyldns.sh \
--api --version-tag $(VINYLDNS_VERSION)

.PHONY: stop-api
stop-api:
$(GOPATH)/src/$(VINYLDNS_REPO)/quickstart/quickstart-vinyldns.sh \
--clean

.PHONY: build
build:
GO111MODULE=on go build -ldflags "-X main.version=$(VERSION)" $(SOURCE)

.PHONY: install
install:
GO111MODULE=on go install $(SOURCE)

.PHONY: release
release: test validate-version
go get github.com/aktau/github-release
github-release release \
--user vinyldns \
--repo go-vinyldns \
--tag $(VERSION) \
--name "$(VERSION)" \
--description "go-vinyldns version $(VERSION)"
--description "go-vinyldns version $(VERSION)"
Loading