Skip to content

Commit

Permalink
fix: add github build and test actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse0Michael committed Apr 10, 2020
1 parent 2829caa commit 520e814
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 45 deletions.
21 changes: 0 additions & 21 deletions .circleci/config.yml

This file was deleted.

18 changes: 18 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Release Workflow
on:
push:
branches:
- master

jobs:
build:
name: tag
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test Workflow
on:
push:

jobs:
test:
name: test
runs-on: ubuntu-latest
container: golang:1.14-alpine
env:
CGO_ENABLED: 0
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Test
run: |
go mod download
mkdir .coverage
go test -v ./assured -cover -coverprofile=.coverage/assured.coverprofile
- name: Coveralls
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: .coverage/assured.coverprofile
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bin/
coverage/
.coverage/
vendor/
.vscode/
debug
28 changes: 11 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
GO ?= go
COVERAGEDIR = coverage
ifdef CIRCLE_ARTIFACTS
COVERAGEDIR=$(CIRCLE_ARTIFACTS)/coverage
endif

COVERAGEDIR = .coverage
LDFLAGS = -ldflags '-X main.gitSHA=$(shell git rev-parse HEAD)'

all: build test cover
dependencies:
go mod download
build:
if [ ! -d bin ]; then mkdir bin; fi
$(GO) build $(LDFLAGS) -v -o bin/go-rest-assured
go build $(LDFLAGS) -v -o bin/go-rest-assured
fmt:
go mod tidy
gofmt -w -l -s *.go
assert-no-diff:
test -z "$(shell git status --porcelain)"
test:
if [ ! -d $(COVERAGEDIR) ]; then mkdir $(COVERAGEDIR); fi
$(GO) test -v ./assured -cover -coverprofile=$(COVERAGEDIR)/assured.coverprofile
go test -v ./assured -cover -coverprofile=$(COVERAGEDIR)/assured.coverprofile
cover:
if [ ! -d $(COVERAGEDIR) ]; then mkdir $(COVERAGEDIR); fi
$(GO) tool cover -html=$(COVERAGEDIR)/assured.coverprofile -o $(COVERAGEDIR)/assured.html
coveralls:
if [ ! -d $(COVERAGEDIR) ]; then mkdir $(COVERAGEDIR); fi
gover $(COVERAGEDIR) $(COVERAGEDIR)/coveralls.coverprofile
goveralls -coverprofile=$(COVERAGEDIR)/coveralls.coverprofile -service=circle-ci -repotoken=$(COVERALLS_TOKEN)
assert-no-diff:
test -z "$(shell git status --porcelain)"
go tool cover -html=$(COVERAGEDIR)/assured.coverprofile
clean:
$(GO) clean
go clean
rm -f bin/go-rest-assured
rm -rf coverage/
rm -rf $(COVERAGEDIR)
rm -rf vendor/
10 changes: 8 additions & 2 deletions assured/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ func TestClient(t *testing.T) {
HTTPClient: *httpClient,
}
client := NewClient(ctx, settings)
time.Sleep(time.Second)

url := client.URL()
require.Equal(t, "http://localhost:9091/when", url)

require.NoError(t, client.Given(*testCall1()))
require.NoError(t, client.Given(*testCall2()))
require.NoError(t, client.Given(*testCall3()))
Expand Down Expand Up @@ -137,6 +137,7 @@ func TestClientCallbacks(t *testing.T) {
delayCalled = true
}))
client := NewDefaultClient()
time.Sleep(time.Second)

require.NoError(t, client.Given(Call{
Path: "test/assured",
Expand Down Expand Up @@ -177,19 +178,22 @@ func TestClientCallbacks(t *testing.T) {
func TestClientClose(t *testing.T) {
client := NewDefaultClient()
client2 := NewDefaultClient()
time.Sleep(time.Second)

require.NotEqual(t, client.URL(), client2.URL())

require.NoError(t, client.Given(*testCall1()))
require.NoError(t, client2.Given(*testCall1()))

client.Close()
time.Sleep(time.Second)
err := client.Given(*testCall1())

require.Error(t, err)
require.Contains(t, err.Error(), `connection refused`)

client2.Close()
time.Sleep(time.Second)
err = client2.Given(*testCall1())

require.Error(t, err)
Expand All @@ -199,6 +203,7 @@ func TestClientClose(t *testing.T) {
func TestClientGivenNoMethod(t *testing.T) {
httpClient := http.Client{}
client := NewDefaultClient()
time.Sleep(time.Second)

err := client.Given(Call{Path: "NoMethodMan"})
require.NoError(t, err)
Expand Down Expand Up @@ -269,7 +274,7 @@ func TestClientBadRequestFailure(t *testing.T) {
err = client.ClearAll()

require.Error(t, err)
require.Equal(t, `parse http://localhost:-1/clear: invalid port ":-1" after host`, err.Error())
require.Equal(t, `parse "http://localhost:-1/clear": invalid port ":-1" after host`, err.Error())
}

func TestClientVerifyHttpClientFailure(t *testing.T) {
Expand Down Expand Up @@ -323,6 +328,7 @@ func TestClientVerifyBodyFailure(t *testing.T) {
func TestClientPathSanitization(t *testing.T) {
httpClient := &http.Client{}
client := NewDefaultClient()
time.Sleep(time.Second)

require.NoError(t, client.Given(Call{Method: "GET", Path: "///yoyo/path///", StatusCode: http.StatusAccepted}))

Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ go 1.12
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-kit/kit v0.0.0-20180313180314-feff11c78971
github.com/go-logfmt/logfmt v0.3.0
github.com/go-stack/stack v1.7.0
github.com/gorilla/context v1.1.1
github.com/go-logfmt/logfmt v0.3.0 // indirect
github.com/go-stack/stack v1.7.0 // indirect
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/handlers v1.3.0
github.com/gorilla/mux v0.0.0-20180120075819-c0091a029979
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 // indirect
github.com/pborman/uuid v0.0.0-20160209185913-a97ce2ca70fa
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ github.com/go-logfmt/logfmt v0.3.0 h1:8HUsc87TaSWLKwrnumgC8/YconD2fJQsRJAsWaPg2i
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-stack/stack v1.7.0 h1:S04+lLfST9FvL8dl4R31wVUC/paZp/WQZbLmUgWboGw=
github.com/go-stack/stack v1.7.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/handlers v1.3.0 h1:tsg9qP3mjt1h4Roxp+M1paRjrVBfPSOpBuVclh6YluI=
github.com/gorilla/handlers v1.3.0/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
github.com/gorilla/mux v0.0.0-20180120075819-c0091a029979 h1:UsXWMy9j+GSCN/I1/Oyc4wGaeW2CDYqeqAkEvWPu+cs=
github.com/gorilla/mux v0.0.0-20180120075819-c0091a029979/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/pborman/uuid v0.0.0-20160209185913-a97ce2ca70fa h1:l8VQbMdmwFH37kOOaWQ/cw24/u8AuBz5lUym13Wcu0Y=
github.com/pborman/uuid v0.0.0-20160209185913-a97ce2ca70fa/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34=
Expand Down

0 comments on commit 520e814

Please sign in to comment.