From df1269f18dbbda25f63eb37ffc93e47309b36a4a Mon Sep 17 00:00:00 2001 From: John Olheiser Date: Wed, 1 Mar 2023 08:50:04 +0800 Subject: [PATCH] Pin CI (#614) This PR pins the CI and various versions of tools in our Makefile to ensure a more stable run. Note that they aren't necessarily the most current versions, as the SDK likely needs more work to bring it back up to par with the main repo. Co-authored-by: jolheiser Co-authored-by: techknowlogick Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/614 Reviewed-by: techknowlogick Reviewed-by: Lunny Xiao Co-authored-by: John Olheiser Co-committed-by: John Olheiser --- .drone.yml | 2 +- Makefile | 38 ++++++++++++-------------------------- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/.drone.yml b/.drone.yml index 335714f..b78700c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,7 +12,7 @@ workspace: steps: - name: gitea - image: gitea/gitea:dev + image: gitea/gitea:1.18 pull: always detach: true commands: diff --git a/Makefile b/Makefile index 7d5b47f..15cbf82 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,12 @@ GITEA_SDK_TEST_PASSWORD ?= test01 PACKAGE := code.gitea.io/sdk/gitea -GITEA_DL := https://dl.gitea.io/gitea/main/gitea-main- +GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.4.0 +GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0 +GITEA_VET_PACKAGE ?= code.gitea.io/gitea-vet@v0.2.1 + +GITEA_VERSION := 1.18 +GITEA_DL := https://dl.gitea.com/gitea/$(GITEA_VERSION)/gitea-$(GITEA_VERSION)- UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Linux) GITEA_DL := $(GITEA_DL)linux- @@ -55,31 +60,26 @@ clean: .PHONY: fmt fmt: find . -name "*.go" -type f | xargs gofmt -s -w; \ - $(GO) run mvdan.cc/gofumpt@latest -extra -w ./gitea + $(GO) run $(GOFUMPT_PACKAGE) -extra -w ./gitea .PHONY: vet vet: # Default vet cd gitea && $(GO) vet $(PACKAGE) # Custom vet - cd gitea && $(GO) get code.gitea.io/gitea-vet + cd gitea && $(GO) get $(GITEA_VET_PACKAGE) cd gitea && $(GO) build code.gitea.io/gitea-vet cd gitea && $(GO) vet -vettool=gitea-vet $(PACKAGE) .PHONY: ci-lint -ci-lint: tool-golangci tool-gofumpt tool-revive - @cd gitea/; echo -n "revive ..."; \ - revive -config ../.revive.toml .; \ - if [ $$? -eq 1 ]; then \ - echo; echo "Doesn't pass revive"; \ - exit 1; \ - fi; echo " done"; echo -n "gofumpt ...";\ - diff=$$(gofumpt -extra -l .); \ +ci-lint: + @cd gitea/; echo -n "gofumpt ...";\ + diff=$$($(GO) run $(GOFUMPT_PACKAGE) -extra -l .); \ if [ -n "$$diff" ]; then \ echo; echo "Not gofumpt-ed"; \ exit 1; \ fi; echo " done"; echo -n "golangci-lint ...";\ - golangci-lint run --timeout 5m; \ + $(GO) run $(GOLANGCI_LINT_PACKAGE) run --timeout 5m; \ if [ $$? -eq 1 ]; then \ echo; echo "Doesn't pass golangci-lint"; \ exit 1; \ @@ -122,17 +122,3 @@ bench: build: cd gitea && $(GO) build -tool-golangci: - @hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ - $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; \ - fi - -tool-gofumpt: - @hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ - $(GO) install mvdan.cc/gofumpt@latest; \ - fi - -tool-revive: - @hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ - $(GO) install github.com/mgechev/revive@latest; \ - fi