diff --git a/.onelint.yaml b/.onelint.yaml new file mode 100644 index 000000000..4fdf54cbc --- /dev/null +++ b/.onelint.yaml @@ -0,0 +1,28 @@ +version: 1 + +profiles: + testx: off + +modules: + - cmd/protoc-gen-nexus-rpc-yaml + - cmd/protoc-gen-resource-id-lint + - cmd/protoc-gen-system-nexus-wit + +format: + # Existing .proto files use 4-space indentation; turn on once formatted. + buf-format: off + gci: off + gofmt: off + gofumpt: off + +lint: + actionlint: on + api-linter: + command: api-linter + files: + - "temporal/**/*.proto" + check: ["--set-exit-status", "-I=.", "--config=api-linter.yaml"] + buf-lint: on + gofix: off + golangci-lint: off + gomodtidy: on diff --git a/Makefile b/Makefile index cd8b75f37..9eae6c235 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ $(VERBOSE).SILENT: ci-build: install proto http-api-docs # Install dependencies. -install: grpc-install api-linter-install buf-install +install: grpc-install api-linter-install buf-install onelint-install # Run all linters and compile proto files. proto: grpc http-api-docs nexus-rpc-yaml system-nexus-wit @@ -36,6 +36,7 @@ OAPI_OUT := openapi OAPI3_PATH := .components.schemas.Payload NEX_GEN ?= nexgen +ONELINT ?= onelint $(PROTO_OUT): mkdir $(PROTO_OUT) @@ -99,15 +100,24 @@ buf-install: printf $(COLOR) "Install/update buf..." go install github.com/bufbuild/buf/cmd/buf@v1.49.0 +onelint-install: + printf $(COLOR) "Install/update onelint and actionlint..." + go install github.com/temporalio/onelint@v0.11.0 + go install github.com/rhysd/actionlint/cmd/actionlint@v1.7.7 + ##### Sync external proto dependencies ##### sync-nexus-annotations: printf $(COLOR) "Sync nexusannotations from buf.build/temporalio/nexus-annotations..." buf export buf.build/temporalio/nexus-annotations --output . ##### Linters ##### +lint: $(STAMPDIR)/buf-dep-prune + printf $(COLOR) "Run linters..." + @$(ONELINT) check + api-linter: printf $(COLOR) "Run api-linter..." - @api-linter --set-exit-status $(PROTO_IMPORTS) --config $(PROTO_ROOT)/api-linter.yaml --output-format json $(PROTO_FILES) | gojq -r 'map(select(.problems != []) | . as $$file | .problems[] | {rule: .rule_doc_uri, location: "\($$file.file_path):\(.location.start_position.line_number)"}) | group_by(.rule) | .[] | .[0].rule + ":\n" + (map("\t" + .location) | join("\n"))' + @$(ONELINT) check --only=api-linter # Every RPC needs a temporal-resource-id request_header annotation for routing, or an entry in # cmd/protoc-gen-resource-id-lint/exemptions.go. @@ -131,7 +141,7 @@ $(STAMPDIR)/buf-dep-prune: $(STAMPDIR) buf.yaml buf-lint: $(STAMPDIR)/buf-dep-prune printf $(COLOR) "Run buf linter..." - (cd $(PROTO_ROOT) && buf lint) + @$(ONELINT) check --only=buf-lint buf-breaking: @printf $(COLOR) "Run buf breaking changes check against main branch..."