Skip to content

Disable vet as part of go test#33662

Merged
lunny merged 10 commits into
go-gitea:mainfrom
silverwind:novet
Mar 3, 2025
Merged

Disable vet as part of go test#33662
lunny merged 10 commits into
go-gitea:mainfrom
silverwind:novet

Conversation

@silverwind

@silverwind silverwind commented Feb 20, 2025

Copy link
Copy Markdown
Member

go vet implicitely runs as part of go test, but we already have make lint-go-vet, so we were essentially running it twice. This should hopefully make go test slightly faster.

Ref: https://pkg.go.dev/cmd/go#hdr-Test_packages

As part of building a test binary, go test runs go vet

`go vet` implicitely runs as part of `go test`, but we already have
`make lint-go-vet`.

Ref: https://pkg.go.dev/cmd/go#hdr-Test_packages
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 20, 2025
@silverwind silverwind added the skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. label Feb 20, 2025
@silverwind

silverwind commented Feb 20, 2025

Copy link
Copy Markdown
Member Author

Actually I see we ran vet only with -vettool which replaces the default checks:

The -vettool=prog flag selects a different analysis tool with alternative
or additional checks.

So I've added a command that now runs plain vet as part of lint-go-vet.

@silverwind

Copy link
Copy Markdown
Member Author

Need to check whether gitea-vit replaces or extends the builtin checks. If the latter, we only need to run go vet once.

@silverwind silverwind marked this pull request as draft February 20, 2025 18:10
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 20, 2025
@techknowlogick

Copy link
Copy Markdown
Member

On a lower powered machine this definitely helps.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 20, 2025
@silverwind

silverwind commented Feb 20, 2025

Copy link
Copy Markdown
Member Author

Yeah I agree, go test in general is a massively slow test runner compared to others like vitest, I guess it's partly because it runs vet. But let's wait on the investigation above until I'm certain whether one or two vet calls are needed.

@silverwind

silverwind commented Mar 1, 2025

Copy link
Copy Markdown
Member Author

Before this can merge, I need to know whether gitea-vet extends or replaces the default vet checks, e.g. whether it's sufficient to only run vet once with the -vettool option.

@techknowlogick or @yp05327 do you perhaps know?

@silverwind

silverwind commented Mar 1, 2025

Copy link
Copy Markdown
Member Author

Actually I was able to confirm that -vettool=gitea-vet replaces the default vet checks, by adding version = version to main.go:

$ go vet ./...
# code.gitea.io/gitea
# [code.gitea.io/gitea]
./main.go:52:2: self-assignment of version to version
$ go vet -vettool=gitea-vet ./...
$

So it needs to run it twice and the current approach is fine.

@silverwind silverwind marked this pull request as ready for review March 1, 2025 07:26
@silverwind silverwind enabled auto-merge (squash) March 1, 2025 07:27
@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 1, 2025
@silverwind silverwind disabled auto-merge March 1, 2025 07:36
@pull-request-size pull-request-size Bot added size/S and removed size/XS labels Mar 1, 2025
@silverwind

Copy link
Copy Markdown
Member Author

Actually I found out we were still running it twice because regular go vet also runs as part of golangci-lint:

- govet

So I removed the explicit call to go vet again and renamed the make target to lint-go-gitea-vet to accurately reflect what it does (it has nothing to do with default go vet).

@silverwind

Copy link
Copy Markdown
Member Author

Also I've moved the flag to GOTESTFLAGS, making it being used in all go test commands.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. labels Mar 1, 2025
@silverwind silverwind requested a review from delvh March 1, 2025 07:52
@GiteaBot GiteaBot added lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 1, 2025
@silverwind silverwind removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 1, 2025
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 1, 2025
Comment thread Makefile
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 2, 2025
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 3, 2025
@lunny lunny enabled auto-merge (squash) March 3, 2025 05:11
@lunny lunny merged commit 43c8d85 into go-gitea:main Mar 3, 2025
@GiteaBot GiteaBot added this to the 1.24.0 milestone Mar 3, 2025
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 3, 2025
@silverwind silverwind deleted the novet branch March 3, 2025 06:52
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 3, 2025
* giteaofficial/main:
  Disable `vet` as part of `go test` (go-gitea#33662)
  Refactor error system (go-gitea#33771)
  Add migrations and doctor fixes (go-gitea#33556)
  Refactor mail code (go-gitea#33768)
  Refactor global init code and add more comments (go-gitea#33755)
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Jun 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants