Skip to content

chore: test with go 1.20 and cleanup tooling #444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 19, 2023
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
26 changes: 0 additions & 26 deletions .github/workflows/labeler.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
node_version: ['*']
runs-on: ${{ matrix.os }}
steps:
- name: Install Node.js ${{ matrix.node }}
- name: Install Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}
Expand All @@ -33,10 +33,10 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
go_version: [1.17.x, 1.18.x, 1.19.x]
go_version: [1.19.x, 1.20.x]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go ${{ matrix.go }}
- name: Install Go ${{ matrix.go_version }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uses: actions/[email protected]
with:
go-version: ${{ matrix.go_version }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/verify-go-src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
go_version: [1.19.x]
go_version: [1.20.x]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go ${{ matrix.go }}
- name: Install Go ${{ matrix.go_version }}
uses: actions/[email protected]
with:
go-version: ${{ matrix.go_version }}
Expand Down
3 changes: 0 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ The go-client is an [netlify/open-api][open-api] derived http client generated u
- You have cloned this repo OUTSIDE of the go path. (So go modules work).
- You have a $GOPATH set up and $GOPATH/bin is added to your \$PATH

See [GMBE:Tools as dependencies](https://github.com/go-modules-by-example/index/tree/master/010_tools) and [GMBE:Using `gobin` to install/run tools](https://github.com/go-modules-by-example/index/tree/master/017_using_gobin) for a deeper explanation of how a tools.go file works.

## Spec validation

All spec changes must pass go-swagger spec validation.
Expand Down Expand Up @@ -53,7 +51,6 @@ under its [MIT license](LICENSE).
[goreport]: https://goreportcard.com/report/github.com/netlify/go-client
[git-img]: https://img.shields.io/github/release/netlify/go-client.svg
[git]: https://github.com/netlify/go-client/releases/latest
[gobin]: https://github.com/myitcv/gobin
[modules]: https://github.com/golang/go/wiki/Modules
[open-api]: https://github.com/netlify/open-api
[go-swagger]: https://github.com/go-swagger/go-swagger
Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.PHONY: all build deps generate help test validate
CHECK_FILES?=$$(go list ./... | grep -v /vendor/)
SWAGGER_SPEC=swagger.yml

help: ## Show this help.
Expand All @@ -11,13 +10,13 @@ build: ## Build the API Go client.
go build ./go/...

deps: ## Download dependencies.
GO111MODULE=off go get -u github.com/myitcv/gobin && go mod download
go mod download

generate: validate ## Generate the API Go client and the JSON document for the UI.
go generate

test: ## Test the go code.
gobin -m -run github.com/kyoh86/richgo test -v $(CHECK_FILES)
go test -v ./...

validate: deps ## Check that the swagger spec is valid.
gobin -m -run github.com/go-swagger/go-swagger/cmd/swagger@v0.23.0 validate $(SWAGGER_SPEC)
go run github.com/go-swagger/go-swagger/cmd/swagger validate $(SWAGGER_SPEC)
4 changes: 2 additions & 2 deletions generate.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package tools

// todo: Find a better way to ignore tags or make a breaking release
//go:generate gobin -m -run github.com/go-swagger/go-swagger/cmd/swagger flatten swagger.yml -o swagger_flat.json
//go:generate go run github.com/go-swagger/go-swagger/cmd/swagger flatten swagger.yml -o swagger_flat.json
//go:generate sh -c "cat swagger_flat.json | jq '[., (.paths | map_values(.[] |= del(.tags?)) | {paths: .})] | add' > swagger_go.json"
//go:generate gobin -m -run github.com/go-swagger/go-swagger/cmd/swagger generate client -A netlify -f swagger_go.json -t go -c plumbing --default-scheme=https --with-flatten=full
//go:generate go run github.com/go-swagger/go-swagger/cmd/swagger generate client -A netlify -f swagger_go.json -t go -c plumbing --default-scheme=https --with-flatten=full
7 changes: 2 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ require (
github.com/go-openapi/strfmt v0.19.11
github.com/go-openapi/swag v0.19.12
github.com/go-openapi/validate v0.20.0
github.com/go-swagger/go-swagger v0.23.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you need to keep this dependency so that the go run for the go:generate instructions work.

the usual advice on how to do this is by creating a package called tools that has this:

package tools

import (
  _ "github.com/go-swagger/go-swagger"
)

Copy link
Contributor Author

@danez danez Apr 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if go run pkg@version is used then the go module is compiled and run without it being installed or affecting the current module. That is what I did. If you prefer I can change that back to what you are suggesting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if go run pkg@version is used then the go module is compiled and run without it being installed or affecting the current module. That is what I did. If you prefer I can change that back to what you are suggesting.

ah good point. i'd prefer having it in go.mod so renovate can update it though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

github.com/kyoh86/richgo v0.3.3
github.com/myitcv/gobin v0.0.14
github.com/go-swagger/go-swagger v0.24.0
github.com/pkg/errors v0.9.1
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/rsc/goversion v1.2.0
github.com/sirupsen/logrus v1.6.0
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.8.2
golang.org/x/net v0.7.0 // indirect
)
Loading