Skip to content

Commit d5186a2

Browse files
authored
Merge pull request #52 from opencredo/update_go_version
Update Go version and add build script
2 parents 278d4fc + 1c86d54 commit d5186a2

26 files changed

+166
-28
lines changed

.travis.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
branches:
2+
only:
3+
- master
4+
15
language: go
26

37
go:
4-
- 1.7
5-
- 1.8
6-
- 1.9
8+
- 1.13.x
9+
- 1.14.x
10+
11+
env:
12+
- CGO_ENABLED=0
713

8-
script: travis_wait 20 go test ./... -v -parallel 10 -timeout 60m
14+
script: travis_wait 20 ./scripts/build.sh

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This is the official client for interfacing with UpCloud's API using the Go prog
88

99
## Installation and requirements
1010

11-
You'll need Go 1.7 or higher to use the client. You can use the following command to retrieve the client:
11+
You'll need Go 1.13 or higher to use the client. You can use the following command to retrieve the client:
1212

1313
```
1414
go get github.com/UpCloudLtd/upcloud-go-api

go.mod

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module github.com/UpCloudLtd/upcloud-go-api
2+
3+
go 1.14
4+
5+
require (
6+
github.com/blang/semver v3.5.1+incompatible
7+
github.com/hashicorp/go-cleanhttp v0.5.1
8+
github.com/kr/pretty v0.1.0 // indirect
9+
github.com/stretchr/testify v1.6.1
10+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
11+
)

go.sum

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
2+
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
3+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
4+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5+
github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM=
6+
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
7+
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
8+
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
9+
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
10+
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
11+
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
12+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
13+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
14+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
15+
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
16+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
17+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
18+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
19+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
20+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
21+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

scripts/build.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Stop build script if there are any errors
5+
#
6+
set -x
7+
set -e
8+
9+
PROJECT_HOME=$(git rev-parse --show-toplevel)
10+
if [[ -z "$GOBIN" ]]; then
11+
GOBIN="$(go env GOPATH)/bin"
12+
fi
13+
14+
# Get build dependencies
15+
pushd /tmp
16+
if [[ ! -e $GOBIN/staticcheck ]]; then
17+
go get honnef.co/go/tools/cmd/staticcheck
18+
fi
19+
if [[ ! -e $GOBIN/goimports ]]; then
20+
go get golang.org/x/tools/cmd/goimports
21+
fi
22+
popd
23+
24+
# Go Mod Download
25+
go mod download
26+
27+
# Check format of Go files
28+
$PROJECT_HOME/scripts/check-gofmt.sh .
29+
30+
# Check format of Imports
31+
$PROJECT_HOME/scripts/check-goimports.sh .
32+
33+
# Check module tidiness
34+
#$PROJECT_HOME/scripts/check-gomodtidy.sh
35+
36+
# Check for common problems
37+
go vet ./...
38+
39+
# Lint
40+
staticcheck ./...
41+
42+
# Run tests
43+
go test ./... -v -parallel 1 -timeout 60m
44+

scripts/check-gofmt.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
DIR="."
4+
if [[ ! -z "$1" ]]; then
5+
DIR="$1"
6+
fi
7+
8+
go_files=$(gofmt -l -s $(find . -type f -name \*.go))
9+
if [[ ! -z "$go_files" ]]; then
10+
echo "The following files need formatting:"
11+
echo $go_files
12+
exit 1
13+
fi
14+

scripts/check-goimports.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
DIR="."
4+
if [[ ! -z "$1" ]]; then
5+
DIR="$1"
6+
fi
7+
8+
go_files=$(goimports -l $(find . -type f -name \*.go))
9+
if [[ ! -z "$go_files" ]]; then
10+
echo "The following files need imports fixed:"
11+
for f in $go_files; do
12+
echo $f
13+
done
14+
exit 1
15+
fi
16+

scripts/check-gomodtidy.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
go_files=$(go mod tidy -v 2>&1)
4+
if [[ ! -z "$go_files" ]]; then
5+
echo "The following modules need tidied."
6+
echo $go_files
7+
echo "If run locally they will have been tidied for you."
8+
exit 1
9+
fi
10+

upcloud/account_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package upcloud
22

33
import (
44
"encoding/xml"
5-
"github.com/stretchr/testify/assert"
65
"testing"
6+
7+
"github.com/stretchr/testify/assert"
78
)
89

910
// TestUnmarshalAccount tests that Account objects unmarshal correctly

upcloud/firewall_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package upcloud
22

33
import (
44
"encoding/xml"
5-
"github.com/stretchr/testify/assert"
65
"testing"
6+
7+
"github.com/stretchr/testify/assert"
78
)
89

910
// TestUnmarshalFirewallRules tests the FirewallRules and FirewallRule are unmarshaled correctly

0 commit comments

Comments
 (0)