diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..6757ff953 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +name: Lint project +on: [push, pull_request] +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Check out source code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version-file: 'go.mod' + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # Make sure this matches the version we've got in our `Makefile` + version: v1.50.1 diff --git a/Makefile b/Makefile index 146075bc8..f76755631 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +GOBASE=$(shell pwd) +GOBIN=$(GOBASE)/bin + help: @echo "This is a helper makefile for oapi-codegen" @echo "Targets:" @@ -6,6 +9,15 @@ help: @echo " gin_example generate gin example server code" @echo " tidy tidy go mod" +$(GOBIN)/golangci-lint: + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.50.1 + +.PHONY: tools +tools: $(GOBIN)/golangci-lint + +lint: tools + $(GOBIN)/golangci-lint run ./... + generate: go generate ./...