Skip to content

Commit

Permalink
Move to Github actions; bump dependencies (#93)
Browse files Browse the repository at this point in the history
* Move to Github actions; fix test race condition

* bump: version v1.1.0

Co-authored-by: GuessWhoSamFoo <[email protected]>
  • Loading branch information
GuessWhoSamFoo and GuessWhoSamFoo authored Aug 18, 2022
1 parent 10f5315 commit e38f014
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 130 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: build
on:
push:
branches:
- '*'
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- run: "go vet ./..."
- name: Lint
uses: dominikh/[email protected]
with:
version: "2022.1.1"
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Unit Tests
run: |
make test-unit
integration-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Integration Tests
run: |
make test-integration
snapshot-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Snapshot Build
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser
version: latest
args: release --debug --snapshot --skip-publish --rm-dist
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: release
on:
workflow_run:
workflows: [build]
types:
- completed
push:
tags:
- 'v*'

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Tagged Release
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser
version: latest
args: release --debug --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64 changes: 0 additions & 64 deletions .jenkins

This file was deleted.

3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# synse-client-go
#

PKG_VERSION := 1.0.0
PKG_VERSION := v1.1.0


.PHONY: build
Expand Down Expand Up @@ -36,7 +36,6 @@ test: test-unit test-integration ## Run all tests (unit, integration)

.PHONY: test-unit
test-unit: ## Run unit tests
@ # Note: this requires go1.10+ in order to do multi-package coverage reports
go test -short -race -coverprofile=coverage.out -covermode=atomic ./...

.PHONY: test-integration
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://build.vio.sh/buildStatus/icon?job=vapor-ware/synse-client-go/master)](https://build.vio.sh/blue/organizations/jenkins/vapor-ware%2Fsynse-client-go/activity)
[![Build Status](https://github.com/vapor-ware/synse-client-go/workflows/build/badge.svg)](https://github.com/vapor-ware/synse-client-go/actions)
[![Godoc](https://godoc.org/github.com/vapor-ware/synse-client-go/synse?status.svg)](https://godoc.org/github.com/vapor-ware/synse-client-go/synse)
[![Go Report Card](https://goreportcard.com/badge/github.com/vapor-ware/synse-client-go)](https://goreportcard.com/report/github.com/vapor-ware/synse-client-go)

Expand Down
21 changes: 13 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
module github.com/vapor-ware/synse-client-go

go 1.12
go 1.19

require (
github.com/creasty/defaults v1.6.0
github.com/go-resty/resty/v2 v2.7.0
github.com/gorilla/websocket v1.5.0
github.com/mitchellh/mapstructure v1.5.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.7.0
)

require (
github.com/creasty/defaults v1.3.0
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gorilla/websocket v1.4.2
github.com/kr/pretty v0.1.0 // indirect
github.com/mitchellh/mapstructure v1.2.2
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.4.0
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/net v0.0.0-20211029224645-99673261e6eb // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/resty.v1 v1.12.0
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
38 changes: 19 additions & 19 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
github.com/creasty/defaults v1.3.0 h1:uG+RAxYbJgOPCOdKEcec9ZJXeva7Y6mj/8egdzwmLtw=
github.com/creasty/defaults v1.3.0/go.mod h1:CIEEvs7oIVZm30R8VxtFJs+4k201gReYyuYHJxZc68I=
github.com/creasty/defaults v1.6.0 h1:ltuE9cfphUtlrBeomuu8PEyISTXnxqkBIoQfXgv7BSc=
github.com/creasty/defaults v1.6.0/go.mod h1:iGzKe6pbEHnpMPtfDXZEr0NVxWnPTjb1bbDy08fPzYM=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY=
github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mitchellh/mapstructure v1.2.2 h1:dxe5oCinTXiTIcfgmZecdCzPmAJKd46KsCWc35r0TV4=
github.com/mitchellh/mapstructure v1.2.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/net v0.0.0-20211029224645-99673261e6eb h1:pirldcYWx7rx7kE5r+9WsOXPXK0+WH5+uZ7uPmJ44uM=
golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/resty.v1 v1.12.0 h1:CuXP0Pjfw9rOuY6EP+UvtNvt5DSqHpIxILZKT/quCZI=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
18 changes: 9 additions & 9 deletions internal/test/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ type HTTPServer struct {
}

// NewHTTPServerV3 returns an instance of a mock http server for v3 API.
func NewHTTPServerV3() HTTPServer {
func NewHTTPServerV3() *HTTPServer {
m := http.NewServeMux()
s := httptest.NewServer(m)

return HTTPServer{
return &HTTPServer{
URL: s.URL[7:], // remove `http://` prefix
server: s,
mux: m,
Expand All @@ -45,11 +45,11 @@ func NewHTTPServerV3() HTTPServer {
}

// NewHTTPSServerV3 returns an instance of a mock https server for v3 API.
func NewHTTPSServerV3() HTTPServer {
func NewHTTPSServerV3() *HTTPServer {
m := http.NewServeMux()
s := httptest.NewTLSServer(m)

return HTTPServer{
return &HTTPServer{
URL: s.URL[8:], // remove `https://`
server: s,
mux: m,
Expand All @@ -58,27 +58,27 @@ func NewHTTPSServerV3() HTTPServer {
}

// ServeUnversioned serves an unversioned endpoint.
func (s HTTPServer) ServeUnversioned(t *testing.T, uri string, statusCode int, response interface{}) {
func (s *HTTPServer) ServeUnversioned(t *testing.T, uri string, statusCode int, response interface{}) {
serve(s.mux, t, uri, statusCode, response)
}

// ServeVersioned serves a versioned endpoint.
func (s HTTPServer) ServeVersioned(t *testing.T, uri string, statusCode int, response interface{}) {
func (s *HTTPServer) ServeVersioned(t *testing.T, uri string, statusCode int, response interface{}) {
serve(s.mux, t, fmt.Sprintf("/%v%v", s.version, uri), statusCode, response)
}

// SetTLS starts TLS using the configured options.
func (s HTTPServer) SetTLS(cfg *tls.Config) {
func (s *HTTPServer) SetTLS(cfg *tls.Config) {
s.tls = cfg
}

// GetCertificates returns the certificate used by the server.
func (s HTTPServer) GetCertificates() *x509.Certificate {
func (s *HTTPServer) GetCertificates() *x509.Certificate {
return s.server.Certificate()
}

// Close closes the unversioned server connection.
func (s HTTPServer) Close() {
func (s *HTTPServer) Close() {
s.server.Close()
}

Expand Down
18 changes: 9 additions & 9 deletions internal/test/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ type WebSocketServer struct {
}

// NewWebSocketServerV3 returns an instance of a mock websocket server for v3 API.
func NewWebSocketServerV3() WebSocketServer {
func NewWebSocketServerV3() *WebSocketServer {
m := http.NewServeMux()
s := httptest.NewServer(m)

return WebSocketServer{
return &WebSocketServer{
URL: s.URL[7:], // remove `http://` prefix
server: s,
mux: m,
Expand All @@ -53,11 +53,11 @@ func NewWebSocketServerV3() WebSocketServer {
}

// NewWebSocketTLSServerV3 returns an instance of a mock websocket tls server for v3 API.
func NewWebSocketTLSServerV3() WebSocketServer {
func NewWebSocketTLSServerV3() *WebSocketServer {
m := http.NewServeMux()
s := httptest.NewTLSServer(m)

return WebSocketServer{
return &WebSocketServer{
URL: s.URL[8:], // remove `https://` prefix
server: s,
mux: m,
Expand All @@ -67,7 +67,7 @@ func NewWebSocketTLSServerV3() WebSocketServer {
}

// Serve reads a request event and writes back a given response.
func (s WebSocketServer) Serve(resp string) {
func (s *WebSocketServer) Serve(resp string) {
s.mux.HandleFunc(
fmt.Sprintf("/%s/%s", s.version, s.entryRoute),
func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -99,7 +99,7 @@ func (s WebSocketServer) Serve(resp string) {
}

// Stream issues a requests and writes back a stream of response data.
func (s WebSocketServer) Stream(responses []string) {
func (s *WebSocketServer) Stream(responses []string) {
s.mux.HandleFunc(
fmt.Sprintf("/%s/%s", s.version, s.entryRoute),
func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -136,16 +136,16 @@ func (s WebSocketServer) Stream(responses []string) {
}

// SetTLS starts TLS using the configured options.
func (s WebSocketServer) SetTLS(cfg *tls.Config) {
func (s *WebSocketServer) SetTLS(cfg *tls.Config) {
s.tls = cfg
}

// GetCertificates returns the certificate used by the server.
func (s WebSocketServer) GetCertificates() *x509.Certificate {
func (s *WebSocketServer) GetCertificates() *x509.Certificate {
return s.server.Certificate()
}

// Close closes the connection.
func (s WebSocketServer) Close() {
func (s *WebSocketServer) Close() {
s.server.Close()
}
Loading

0 comments on commit e38f014

Please sign in to comment.