diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ca11cd14..aecffe40 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,7 @@ on: pull_request: branches: [ master, main ] push: - branches: [master, main ] + branches: [ master, main ] jobs: test: @@ -12,9 +12,8 @@ jobs: strategy: matrix: go-version: - - 1.18.x - - 1.19.x - - 1.20.x + - 1.22.x + - 1.23.x os: [ ubuntu-latest ] runs-on: ${{ matrix.os }} steps: @@ -22,22 +21,18 @@ jobs: uses: actions/checkout@master - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: ${{ matrix.go-version }} + cache: true # caching and restoring go modules and build outputs - run: go env - - name: Cache deps - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - name: Install deps run: go mod download + - name: nilaway + run: make nilaway + - name: Test run: go test -v -race -p=1 -count=1 diff --git a/Makefile b/Makefile index 85b927a5..d4028ebb 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,17 @@ -.PHONY: all .DEFAULT_GOAL := all PACKAGE := github.com/mailgun/mailgun-go +GOPATH=$(shell go env GOPATH) + +NILAWAY = $(GOPATH)/bin/nilaway +$(NILAWAY): + go install go.uber.org/nilaway/cmd/nilaway@latest +.PHONY: all all: export GO111MODULE=on; go test . -v +.PHONY: godoc godoc: mkdir -p /tmp/tmpgoroot/doc -rm -rf /tmp/tmpgopath/src/${PACKAGE} @@ -13,3 +19,8 @@ godoc: tar -c --exclude='.git' --exclude='tmp' . | tar -x -C /tmp/tmpgopath/src/${PACKAGE} echo -e "open http://localhost:6060/pkg/${PACKAGE}\n" GOROOT=/tmp/tmpgoroot/ GOPATH=/tmp/tmpgopath/ godoc -http=localhost:6060 + +# TODO(vtopc): fix mocks and enable nilaway for them too? +.PHONY: nilaway +nilaway: $(NILAWAY) + $(NILAWAY) -include-pkgs="$(PACKAGE)" -test=false -exclude-errors-in-files=mock_ ./... diff --git a/messages.go b/messages.go index 5df22aff..efe0e7d2 100644 --- a/messages.go +++ b/messages.go @@ -914,6 +914,9 @@ func (mg *MailgunImpl) GetStoredAttachment(ctx context.Context, url string) ([]b r.addHeader("Accept", "message/rfc2822") response, err := makeGetRequest(ctx, r) + if err != nil { + return nil, err + } return response.Data, err }