Skip to content

Commit

Permalink
Merge pull request #59 from adamdecaf/download-ci-tools
Browse files Browse the repository at this point in the history
build: download tools used by TravisCI instead of installing them
  • Loading branch information
adamdecaf authored Aug 15, 2019
2 parents 9238dc4 + ec8f359 commit 1259914
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 12 deletions.
30 changes: 23 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,37 @@ matrix:
# - os: windows
# go: 1.12.x
before_install:
- GO111MODULE=off go get -u github.com/client9/misspell/cmd/misspell
- GO111MODULE=off go get -u golang.org/x/lint/golint
- GO111MODULE=off go get github.com/fzipp/gocyclo
- GO111MODULE=off go get -u honnef.co/go/tools/cmd/staticcheck
- GO111MODULE=off go get golang.org/x/tools/cmd/cover
# Setup directory for binaries
- mkdir ./bin
- export PATH=$PATH:$PWD/bin
# Misspell
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget -O misspell.tar.gz https://github.com/client9/misspell/releases/download/v0.3.4/misspell_0.3.4_linux_64bit.tar.gz; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget -O misspell.tar.gz https://github.com/client9/misspell/releases/download/v0.3.4/misspell_0.3.4_mac_64bit.tar.gz; fi
- tar xf misspell.tar.gz && cp ./misspell ./bin/misspell
# staticcheck
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget -O staticcheck.tar.gz https://github.com/dominikh/go-tools/releases/download/2019.2.2/staticcheck_linux_amd64.tar.gz; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget -O staticcheck.tar.gz https://github.com/dominikh/go-tools/releases/download/2019.2.2/staticcheck_darwin_amd64.tar.gz; fi
- tar xf staticcheck.tar.gz && cp ./staticcheck/staticcheck ./bin/staticcheck
# golint
- go get -u golang.org/x/lint/golint
# gocyclo
# - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget -O ./bin/gocyclo https://github.com/adamdecaf/gocyclo/releases/download/2019-08-09/gocyclo-linux-amd64; fi
# - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget -O ./bin/gocyclo https://github.com/adamdecaf/gocyclo/releases/download/2019-08-09/gocyclo-darwin-amd64; fi
# - chmod +x ./bin/gocyclo
before_script:
- GOFILES=$(find . -type f -name '*.go' | grep -v client)
- go mod graph
script:
# Just check gofmt on linux, it's the fastest builder
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then test -z $(gofmt -s -l $GOFILES); fi
- go test ./... -race -coverprofile=coverage.txt -covermode=atomic
- misspell -error -locale US $GOFILES
#- gocyclo -over $GOFILES
# - gocyclo -over 25 $GOFILES # TODO(adam): need to re-enable (top 2 methods below)
# 115 wire (*Reader).parseLine ./reader.go:88:1
# 45 wire (*FEDWireMessage).isBusinessCodeValid ./fedWireMessage.go:228:1
- golint -set_exit_status $GOFILES
- staticcheck ./cmd/*/*.go *.go # TODO(brooke): later add ./pkg/*/*.go
- staticcheck *.go
- staticcheck ./cmd/server/*.go
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then choco install -y mingw; export PATH=/c/tools/mingw64/bin:"$PATH";fi
after_success:
- bash <(curl -s https://codecov.io/bash)
Expand Down
10 changes: 8 additions & 2 deletions cmd/server/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ var (
filesCreated = prometheus.NewCounterFrom(stdprometheus.CounterOpts{
Name: "wire_files_created",
Help: "The number of WIRE files created",
}, []string{"destination", "origin"})
}, nil) // TODO(adam): add key/value pairs []string{"destination", "origin"}

filesDeleted = prometheus.NewCounterFrom(stdprometheus.CounterOpts{
Name: "wire_files_deleted",
Help: "The number of WIRE files deleted",
}, nil)

errNoFileId = errors.New("no File ID found")
errNoFEDWireMessageID = errors.New("No FEDWireMessage ID found")
errNoFEDWireMessageID = errors.New("no FEDWireMessage ID found")
)

func addFileRoutes(logger log.Logger, r *mux.Router, repo WireFileRepository) {
Expand Down Expand Up @@ -105,6 +105,9 @@ func createFile(logger log.Logger, repo WireFileRepository) http.HandlerFunc {
logger.Log("files", fmt.Sprintf("creatd file=%s", req.ID), "requestId", requestId)
}

// record a metric for files created
filesCreated.Add(1) // TODO(adam): add key/value pairs (like in ACH)

w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusCreated)
json.NewEncoder(w).Encode(req)
Expand Down Expand Up @@ -149,6 +152,9 @@ func deleteFile(logger log.Logger, repo WireFileRepository) http.HandlerFunc {
if requestId := moovhttp.GetRequestId(r); requestId != "" {
logger.Log("files", fmt.Sprintf("deleted file=%s", fileId), "requestId", requestId)
}

filesDeleted.Add(1)

w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(`{"error": null}`)
Expand Down
2 changes: 1 addition & 1 deletion fiBeneficiaryAdvice.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type FIBeneficiaryAdvice struct {
// tag
tag string
// Advice
Advice Advice `json:"advice,omitEmpty"`
Advice Advice `json:"advice,omitempty"`

// validator is composed for data validation
validator
Expand Down
2 changes: 1 addition & 1 deletion fiDrawdownDebitAccountAdvice.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type FIDrawdownDebitAccountAdvice struct {
// tag
tag string
// Advice
Advice Advice `json:"advice,omitEmpty"`
Advice Advice `json:"advice,omitempty"`

// validator is composed for data validation
validator
Expand Down
2 changes: 1 addition & 1 deletion fiIntermediaryFIAdvice.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type FIIntermediaryFIAdvice struct {
// tag
tag string
// Advice
Advice Advice `json:"advice,omitEmpty"`
Advice Advice `json:"advice,omitempty"`

// validator is composed for data validation
validator
Expand Down

0 comments on commit 1259914

Please sign in to comment.