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 <john.olheiser@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/614
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john+gitea@jolheiser.com>
Co-committed-by: John Olheiser <john+gitea@jolheiser.com>
This commit is contained in:
John Olheiser 2023-03-01 08:50:04 +08:00 committed by Lunny Xiao
parent 2c35c11772
commit df1269f18d
2 changed files with 13 additions and 27 deletions

View file

@ -12,7 +12,7 @@ workspace:
steps: steps:
- name: gitea - name: gitea
image: gitea/gitea:dev image: gitea/gitea:1.18
pull: always pull: always
detach: true detach: true
commands: commands:

View file

@ -8,7 +8,12 @@ GITEA_SDK_TEST_PASSWORD ?= test01
PACKAGE := code.gitea.io/sdk/gitea 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) UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux) ifeq ($(UNAME_S),Linux)
GITEA_DL := $(GITEA_DL)linux- GITEA_DL := $(GITEA_DL)linux-
@ -55,31 +60,26 @@ clean:
.PHONY: fmt .PHONY: fmt
fmt: fmt:
find . -name "*.go" -type f | xargs gofmt -s -w; \ 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 .PHONY: vet
vet: vet:
# Default vet # Default vet
cd gitea && $(GO) vet $(PACKAGE) cd gitea && $(GO) vet $(PACKAGE)
# Custom vet # 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) build code.gitea.io/gitea-vet
cd gitea && $(GO) vet -vettool=gitea-vet $(PACKAGE) cd gitea && $(GO) vet -vettool=gitea-vet $(PACKAGE)
.PHONY: ci-lint .PHONY: ci-lint
ci-lint: tool-golangci tool-gofumpt tool-revive ci-lint:
@cd gitea/; echo -n "revive ..."; \ @cd gitea/; echo -n "gofumpt ...";\
revive -config ../.revive.toml .; \ diff=$$($(GO) run $(GOFUMPT_PACKAGE) -extra -l .); \
if [ $$? -eq 1 ]; then \
echo; echo "Doesn't pass revive"; \
exit 1; \
fi; echo " done"; echo -n "gofumpt ...";\
diff=$$(gofumpt -extra -l .); \
if [ -n "$$diff" ]; then \ if [ -n "$$diff" ]; then \
echo; echo "Not gofumpt-ed"; \ echo; echo "Not gofumpt-ed"; \
exit 1; \ exit 1; \
fi; echo " done"; echo -n "golangci-lint ...";\ fi; echo " done"; echo -n "golangci-lint ...";\
golangci-lint run --timeout 5m; \ $(GO) run $(GOLANGCI_LINT_PACKAGE) run --timeout 5m; \
if [ $$? -eq 1 ]; then \ if [ $$? -eq 1 ]; then \
echo; echo "Doesn't pass golangci-lint"; \ echo; echo "Doesn't pass golangci-lint"; \
exit 1; \ exit 1; \
@ -122,17 +122,3 @@ bench:
build: build:
cd gitea && $(GO) 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