Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add more golang strictness checks #8931

Merged
merged 2 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/golang-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
on: [push, pull_request]
name: Go Checks

jobs:
unit:
runs-on: ubuntu-latest
name: All
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/setup-go@v2
with:
go-version: "1.17.x"
- name: Check that go.mod is tidy
uses: protocol/[email protected]
with:
run: |
go mod tidy
if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then
echo "go.sum was added by go mod tidy"
exit 1
fi
git diff --exit-code -- go.sum go.mod
- name: gofmt
if: always() # run this step even if the previous one failed
run: |
out=$(gofmt -s -l .)
if [[ -n "$out" ]]; then
echo $out | awk '{print "::error file=" $0 ",line=0,col=0::File is not gofmt-ed."}'
exit 1
fi
- name: go vet
if: always() # run this step even if the previous one failed
uses: protocol/[email protected]
with:
run: go vet ./...
1 change: 1 addition & 0 deletions cmd/ipfs/daemon_linux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build linux
// +build linux

package main
Expand Down
1 change: 1 addition & 0 deletions cmd/ipfs/daemon_other.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !linux
// +build !linux

package main
Expand Down
1 change: 1 addition & 0 deletions cmd/ipfs/runmain_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build testrunmain
// +build testrunmain

package main
Expand Down
1 change: 1 addition & 0 deletions cmd/ipfs/util/signal.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !wasm
// +build !wasm

package util
Expand Down
3 changes: 2 additions & 1 deletion cmd/ipfs/util/ui.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build !windows
//go:build !windows
// +build !windows

package util

Expand Down
1 change: 1 addition & 0 deletions cmd/ipfs/util/ulimit_freebsd.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build freebsd
// +build freebsd

package util
Expand Down
1 change: 1 addition & 0 deletions cmd/ipfs/util/ulimit_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows && !plan9
// +build !windows,!plan9

package util
Expand Down
1 change: 1 addition & 0 deletions cmd/ipfs/util/ulimit_unix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build darwin || linux || netbsd || openbsd
// +build darwin linux netbsd openbsd

package util
Expand Down
1 change: 1 addition & 0 deletions cmd/ipfs/util/ulimit_windows.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build windows
// +build windows

package util
Expand Down
1 change: 1 addition & 0 deletions cmd/ipfswatch/ipfswatch_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !plan9
// +build !plan9

package main
Expand Down
1 change: 1 addition & 0 deletions core/commands/mount_nofuse.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows && nofuse
// +build !windows,nofuse

package commands
Expand Down
10 changes: 5 additions & 5 deletions core/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ var ErrNotOnline = errors.New("this command must be run in online mode. Try runn
const (
RepoDirOption = "repo-dir"
ConfigFileOption = "config-file"
ConfigOption = "config"
DebugOption = "debug"
LocalOption = "local" // DEPRECATED: use OfflineOption
OfflineOption = "offline"
ApiOption = "api"
ConfigOption = "config"
DebugOption = "debug"
LocalOption = "local" // DEPRECATED: use OfflineOption
OfflineOption = "offline"
ApiOption = "api"
)

var Root = &cmds.Command{
Expand Down
1 change: 1 addition & 0 deletions coverage/main/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build testrunmain
// +build testrunmain

package main
Expand Down
1 change: 1 addition & 0 deletions fuse/ipns/ipns_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !nofuse && !openbsd && !netbsd && !plan9
// +build !nofuse,!openbsd,!netbsd,!plan9

package ipns
Expand Down
1 change: 1 addition & 0 deletions fuse/ipns/ipns_unix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !nofuse && !openbsd && !netbsd && !plan9
// +build !nofuse,!openbsd,!netbsd,!plan9

// package fuse/ipns implements a fuse filesystem that interfaces
Expand Down
1 change: 1 addition & 0 deletions fuse/ipns/link_unix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !nofuse && !openbsd && !netbsd && !plan9
// +build !nofuse,!openbsd,!netbsd,!plan9

package ipns
Expand Down
1 change: 1 addition & 0 deletions fuse/ipns/mount_unix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build (linux || darwin || freebsd || netbsd || openbsd) && !nofuse
// +build linux darwin freebsd netbsd openbsd
// +build !nofuse

Expand Down
1 change: 1 addition & 0 deletions fuse/mount/fuse.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !nofuse && !windows && !openbsd && !netbsd && !plan9
// +build !nofuse,!windows,!openbsd,!netbsd,!plan9

package mount
Expand Down
1 change: 1 addition & 0 deletions fuse/node/mount_darwin.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !nofuse
// +build !nofuse

package node
Expand Down
1 change: 1 addition & 0 deletions fuse/node/mount_nofuse.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows && nofuse
// +build !windows,nofuse

package node
Expand Down
1 change: 1 addition & 0 deletions fuse/node/mount_notsupp.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build (!nofuse && openbsd) || (!nofuse && netbsd) || (!nofuse && plan9)
// +build !nofuse,openbsd !nofuse,netbsd !nofuse,plan9

package node
Expand Down
1 change: 1 addition & 0 deletions fuse/node/mount_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !openbsd && !nofuse && !netbsd && !plan9
// +build !openbsd,!nofuse,!netbsd,!plan9

package node
Expand Down
1 change: 1 addition & 0 deletions fuse/node/mount_unix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows && !openbsd && !netbsd && !plan9 && !nofuse
// +build !windows,!openbsd,!netbsd,!plan9,!nofuse

package node
Expand Down
1 change: 1 addition & 0 deletions fuse/readonly/ipfs_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !nofuse && !openbsd && !netbsd && !plan9
// +build !nofuse,!openbsd,!netbsd,!plan9

package readonly
Expand Down
1 change: 1 addition & 0 deletions fuse/readonly/mount_unix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build (linux || darwin || freebsd) && !nofuse
// +build linux darwin freebsd
// +build !nofuse

Expand Down
4 changes: 3 additions & 1 deletion plugin/loader/load_nocgo.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// +build !cgo,!noplugin
//go:build !cgo && !noplugin && (linux || darwin || freebsd)
// +build !cgo
// +build !noplugin
// +build linux darwin freebsd

package loader
Expand Down
1 change: 1 addition & 0 deletions plugin/loader/load_noplugin.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build noplugin
// +build noplugin

package loader
Expand Down
4 changes: 3 additions & 1 deletion plugin/loader/load_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// +build cgo,!noplugin
//go:build cgo && !noplugin && (linux || darwin || freebsd)
// +build cgo
// +build !noplugin
// +build linux darwin freebsd

package loader
Expand Down
1 change: 1 addition & 0 deletions test/dependencies/dependencies.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build tools
// +build tools

package tools
Expand Down