-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Setup lint and format of Go, Proto and yaml/markdown #223
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
Changes from 17 commits
6b3114a
edfcdc4
03b7ec6
dae34ca
2634215
3ddd996
148437f
24e0c94
95b9f03
fa0922d
b653572
806f0d3
f94b0b5
e8726b1
f3da299
052883a
1969802
d0ef850
89eb13c
4ace54c
668e958
0315f55
19cd7a4
c9c16c7
9390348
796072a
85f28a3
ba084b9
53ed749
471c0b4
333be80
8ae682b
78cfba0
2dde124
0c45f8d
0c005a6
715542a
c4d4c9c
db8be91
25b790d
d673938
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,37 @@ | ||
--- | ||
name: CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
# The "build" workflow | ||
lint: | ||
# The type of runner that the job will run on | ||
golangci-lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
version: latest | ||
|
||
prettier-lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
|
||
# Install and run golangci-lint as a separate step, it's much faster this | ||
# way because this action has caching. It'll get run again in `make lint` | ||
# below, but it's still much faster in the end than installing | ||
# golangci-lint manually in the `Run lint` step. | ||
- uses: golangci/golangci-lint-action@v2 | ||
- name: Prettify code | ||
uses: creyD/[email protected] | ||
with: | ||
prettier_options: >- | ||
--check **/*.{ts,js,md,yaml,yml,sass,css,scss,html} | ||
only_changed: false | ||
dry: true | ||
|
||
proto-lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: bufbuild/[email protected] | ||
- uses: bufbuild/buf-lint-action@v1 | ||
with: | ||
input: "proto" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,56 @@ | ||
--- | ||
run: | ||
timeout: 5m | ||
timeout: 10m | ||
|
||
issues: | ||
skip-dirs: | ||
- gen | ||
linters: | ||
enable-all: true | ||
disable: | ||
- exhaustivestruct | ||
- revive | ||
- lll | ||
- interfacer | ||
- scopelint | ||
- maligned | ||
- golint | ||
- gofmt | ||
- gochecknoglobals | ||
- gochecknoinits | ||
- gocognit | ||
- funlen | ||
- exhaustivestruct | ||
- tagliatelle | ||
- godox | ||
- ireturn | ||
|
||
# We should strive to enable these: | ||
- testpackage | ||
- stylecheck | ||
- wrapcheck | ||
- paralleltest | ||
- noctx | ||
- nlreturn | ||
- ifshort | ||
- gomnd | ||
- goerr113 | ||
- errorlint | ||
- forcetypeassert | ||
- errname | ||
- wsl | ||
- unparam | ||
- makezero | ||
- gosec | ||
- gocritic | ||
- forbidigo | ||
- dupl | ||
- goconst | ||
- unconvert | ||
- exhaustive | ||
- varnamelen | ||
- nilnil | ||
|
||
# We might want to enable this, but it might be a lot of work | ||
- cyclop | ||
- nestif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ import ( | |
"strings" | ||
|
||
"github.com/rs/zerolog/log" | ||
|
||
"github.com/tailscale/hujson" | ||
"inet.af/netaddr" | ||
"tailscale.com/tailcfg" | ||
|
@@ -25,7 +24,7 @@ const ( | |
errorInvalidPortFormat = Error("invalid port format") | ||
) | ||
|
||
// LoadACLPolicy loads the ACL policy from the specify path, and generates the ACL rules | ||
// LoadACLPolicy loads the ACL policy from the specify path, and generates the ACL rules. | ||
func (h *Headscale) LoadACLPolicy(path string) error { | ||
policyFile, err := os.Open(path) | ||
if err != nil { | ||
|
@@ -108,7 +107,9 @@ func (h *Headscale) generateACLPolicySrcIP(u string) ([]string, error) { | |
return h.expandAlias(u) | ||
} | ||
|
||
func (h *Headscale) generateACLPolicyDestPorts(d string) ([]tailcfg.NetPortRange, error) { | ||
func (h *Headscale) generateACLPolicyDestPorts( | ||
d string, | ||
) ([]tailcfg.NetPortRange, error) { | ||
tokens := strings.Split(d, ":") | ||
if len(tokens) < 2 || len(tokens) > 3 { | ||
return nil, errorInvalidPortFormat | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the standard gofmt config? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean in general, not just this line... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, its gofumpt,which I think is standard in vscode, and then it is run through golines to break long lines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added note in readme. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 88?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is based on python black (and Raymond Hettinger), which some might hate.
The idea is to make the code more naturally fit on narrow screens, so you can have multiple files open without bad editor wrapping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll adda note in the reader about code style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done