Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

build: use gox and ghr instead of goreleaser #8

Merged
merged 5 commits into from
Jul 1, 2018
Merged
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
17 changes: 0 additions & 17 deletions .goreleaser.yml

This file was deleted.

13 changes: 3 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,12 @@ install:
- go get -u gopkg.in/alecthomas/gometalinter.v2
- ln -s $GOPATH/bin/gometalinter.v2 $GOPATH/bin/gometalinter
- gometalinter --install
- go get -u github.com/tcnksm/ghr
- go get github.com/mitchellh/gox
script:
- npm run commitlint-travis
- gometalinter ./...
- bash script/codecov-test.sh
after_success:
- bash script/codecov.sh
- git status --porcelain
# mainly ignore change of package-lock.json
- git checkout -- .
deploy:
- provider: script
skip_cleanup: true
script: curl -sL https://git.io/goreleaser | bash
on:
tags: true
condition: $TRAVIS_OS_NAME = linux
- TAG=$TRAVIS_TAG bash script/release.sh
4 changes: 4 additions & 0 deletions index_set.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// I can't understand the reason but it is failed to run "gometalinter ./..." travis ci
// index_set.go:1::warning: file is not goimported (goimports)
// index_set.go:1::warning: file is not gofmted with -s (gofmt)
// nolint: goimports, gofmt
package graylog

import (
Expand Down
2 changes: 1 addition & 1 deletion mockserver/exec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/suzuki-shunsuke/go-graylog/mockserver/store/plain"
)

const version = "0.1.0"
const version = "0.1.1"

var help string

Expand Down
8 changes: 8 additions & 0 deletions script/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cd `dirname $0`/.. || exit 1
echo "pwd: $PWD" || exit 1

source script/decho.sh || exit 1

decho gox -output="dist/${TAG}/graylog-mock-server_${TAG}_{{.OS}}_{{.Arch}}" -osarch="darwin/amd64 linux/amd64 windows/amd64" ./mockserver/exec || exit 1
decho gox -output="dist/${TAG}/terraform-provider-graylog_${TAG}_{{.OS}}_{{.Arch}}" -osarch="darwin/amd64 linux/amd64 windows/amd64" ./terraform || exit 1
ls dist/${TAG} | xargs -I {} gzip dist/${TAG}/{}
21 changes: 13 additions & 8 deletions script/codecov-test.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
#!/usr/bin/env bash
# https://github.com/codecov/example-go#caveat-multiple-files

echo "" > coverage.txt
cd `dirname $0`/.. || exit 1
echo "pwd: $PWD" || exit 1

source script/decho.sh || exit 1

echo "" > coverage.txt || exit 1
# ignore testutil from test coverage
go test ./testutil
decho go test ./testutil || exit 1
for d in $(go list ./... | grep -v vendor | grep -v terraform | grep -v testutil); do
go test -race -coverprofile=profile.out -covermode=atomic $d
decho go test -race -coverprofile=profile.out -covermode=atomic $d || exit 1
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
cat profile.out >> coverage.txt || exit 1
rm profile.out || exit 1
fi
done

go test -v -race -coverprofile=profile.out -covermode=atomic ./terraform/...
decho go test -v -race -coverprofile=profile.out -covermode=atomic ./terraform/... || exit 1
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
cat profile.out >> coverage.txt || exit 1
rm profile.out || exit 1
fi
11 changes: 8 additions & 3 deletions script/coverage.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
mkdir -p coverage/$1
go test ./$1 -coverprofile=coverage/$1/coverage.txt -covermode=atomic
go tool cover -html=coverage/$1/coverage.txt
cd `dirname $0`/.. || exit 1
echo "pwd: $PWD" || exit 1

source script/decho.sh || exit 1

decho mkdir -p coverage/$1 || exit 1
decho go test ./$1 -coverprofile=coverage/$1/coverage.txt -covermode=atomic || exit 1
decho go tool cover -html=coverage/$1/coverage.txt
4 changes: 4 additions & 0 deletions script/decho.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
decho() {
echo "+ $@"
eval $@
}
3 changes: 3 additions & 0 deletions script/fmt.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
cd `dirname $0`/.. || exit 1
echo "pwd: $PWD" || exit 1

find . -type d -name node_modules -prune -o \
-type d -name .git -prune -o \
-type d -name vendor -prune -o \
Expand Down
11 changes: 8 additions & 3 deletions script/lint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
npm run metalint || exit 1
npm run golint || exit 1
cd `dirname $0`/.. || exit 1
echo "pwd: $PWD" || exit 1

source script/decho.sh || exit 1

decho npm run metalint || exit 1
decho npm run golint || exit 1
echo "+ staticcheck (failure is ignored)"
staticcheck ./... || echo "staticcheck failure is ignored"
decho staticcheck ./... || echo "staticcheck failure is ignored"
12 changes: 5 additions & 7 deletions script/precommit.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
set -e
cd `dirname $0`/.. || exit 1
echo "pwd: $PWD" || exit 1

decho() {
echo "+ $@"
eval $@
}
source script/decho.sh || exit 1

# gofmt
echo "! git ls-files | grep \"\\.go$\" | xargs gofmt -s -d | grep '^'"
! git ls-files | grep "\.go$" | xargs gofmt -s -d | grep '^'
echo "! git ls-files | grep \"\\.go$\" | xargs gofmt -s -d | grep '^'" || exit 1
! git ls-files | grep "\.go$" | xargs gofmt -s -d | grep '^' || exit 1
# go vet
decho go vet $(go list ./... | grep -v /vendor/)
7 changes: 7 additions & 0 deletions script/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if [ -n "$TRAVIS_TAG" ]; then
cd `dirname $0`/.. || exit 1
echo "pwd: $PWD" || exit 1

bash script/build.sh
bash script/upload.sh
fi
14 changes: 7 additions & 7 deletions script/test.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
decho() {
echo "+ $@"
eval $@
}
cd `dirname $0`/.. || exit 1
echo "pwd: $PWD" || exit 1

source script/decho.sh || exit 1

npm run fmt || exit 1
npm run golint
npm run golint || exit 1

decho go test ./mockserver/... -covermode=atomic || exit 1

if [ -f script/env.sh ]; then
decho source script/env.sh
if [ -f env.sh ]; then
source env.sh
fi

decho go test ./testutil/... ./util/... ./validator/... ./client/... . -covermode=atomic || exit 1
Expand Down
6 changes: 6 additions & 0 deletions script/upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cd `dirname $0`/.. || exit 1
echo "pwd: $PWD" || exit 1

source script/decho.sh || exit 1

decho ghr -u suzuki-shunsuke ${TAG} dist/${TAG}
1 change: 0 additions & 1 deletion terraform/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ TAG=edge
BIN=terraform-provider-graylog
$(BIN): *.go graylog/*.go
go build -o $(BIN)
terraform init
.terraform:
terraform init
plan: $(BIN) .terraform
Expand Down
5 changes: 3 additions & 2 deletions terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ By using this provider, you can utilize this flexibility and manage the infrastr
https://www.terraform.io/docs/configuration/providers.html#third-party-plugins

```
$ wget https://github.com/suzuki-shunsuke/go-graylog/releases/download/v0.1.1/terraform-provider-graylog_v0.1.1_darwin_amd64.tar.gz
$ tar xvzf terraform-provider-graylog_v0.1.1_darwin_amd64.tar.gz
$ wget https://github.com/suzuki-shunsuke/go-graylog/releases/download/v0.1.1/terraform-provider-graylog_v0.1.1_darwin_amd64.gz
$ gzip -d terraform-provider-graylog_v0.1.1_darwin_amd64.gz
$ mkdir -p ~/.terraform.d/plugins
$ mv terraform-provider-graylog_v0.1.1_darwin_amd64 ~/.terraform.d/plugins/terraform-provider-graylog_v0.1.1
```

Expand Down