-
Notifications
You must be signed in to change notification settings - Fork 773
Feature: add code boilerplate check into circleci #813
Feature: add code boilerplate check into circleci #813
Conversation
.circleci/config.yml
Outdated
@@ -102,6 +112,7 @@ workflows: | |||
ci: | |||
jobs: | |||
- markdownlint-misspell-shellcheck | |||
- gocode-format-check |
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.
You can add this in gocode-check-via-gometalinter-swagger
.
@@ -116,14 +116,9 @@ func main() { | |||
os.Exit(1) | |||
} | |||
|
|||
hasErr := false | |||
for _, filePath := range os.Args[1:] { | |||
if err := verifyFile(filePath); err != nil { | |||
fmt.Printf("error validating %q: %v\n", filePath, err) |
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.
This message should be printed in stderr, while now it is streamed to stdout, which seems to be incorrect. WDYT? @SataQiu
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.
pouchcontainer/pouchlinter:v0.2.1
has no GCC installed.
Emm, I don't know where GCC is used...
Update pouchcontainer/pouchlinter:v0.2.1
or create a new job using circleci/golang:1.12.6
?
WDYT? @allencloud
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.
Latest pouchcontainer/pouchlinter:v0.2.2 has installed gcc if you need it.
ref: dragonflyoss/linter#17 (comment) 😄 hope it help for you.
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.
OK! Let's bump to pouchcontainer/pouchlinter:v0.2.2
. 😆
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.
But in pouchcontainer/pouchlinter:v0.2.2
we removed gometaliner. We need to update circle-ci part to migrate to golangci-lint first. So I will open a PR tonight and after that you can work on this PR. Is it ok? I will finish it ASAP.
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.
OK. Waiting for your good news. @yeya24
35b601d
to
54fc602
Compare
54fc602
to
a39eae3
Compare
@@ -78,15 +77,15 @@ func checkBoilerplate(content string) error { | |||
return fmt.Errorf("the file is missing a boilerplate") | |||
} | |||
if index < len(boilerplate) { | |||
return errors.New("boilerplate has missing lines") | |||
return fmt.Errorf("boilerplate has missing lines") |
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 am wondering if the change is unnecessary, since I think both are the same. WDYT?
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.
Just want to clean something as I already imported fmt
. :)
.circleci/config.yml
Outdated
@@ -62,6 +62,9 @@ jobs: | |||
command: | | |||
make go-mod-vendor | |||
gometalinter --disable-all --skip vendor --skip test -E deadcode ./... | |||
- run: |
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 think we need rebase this part onto the latest master branch.
a39eae3
to
09fa632
Compare
09fa632
to
8d274e4
Compare
Codecov Report
@@ Coverage Diff @@
## master #813 +/- ##
==========================================
+ Coverage 39.63% 39.66% +0.02%
==========================================
Files 109 109
Lines 6433 6429 -4
==========================================
Hits 2550 2550
+ Misses 3675 3671 -4
Partials 208 208
Continue to review full report at Codecov.
|
8d274e4
to
348a128
Compare
@allencloud @yeya24 |
d6afc5b
to
348a128
Compare
Agree with that. If you want to only add boilerplate check, could please change the PR's title? 😄 |
Need review. @yeya24 @allencloud |
hack/boilerplate-check.sh
Outdated
|
||
check() { | ||
# boilerplate check | ||
echo "CHECK: boilerpalte, check code boilerplate" |
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.
This sentence looks weird. Why not just use Begin to check code boilerplate
here?
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.
Because I write Begin to check code boilerplate
in Makefile. Maybe just remove this? WDYT?
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.
Yes, just keep one comment is OK.
hack/check.sh
Outdated
@@ -10,7 +10,7 @@ cd "${curDir}/../" || return | |||
check() { | |||
# gofmt | |||
echo "CHECK: gofmt, check code formats" | |||
result=$(find . -name '*.go' -print0 | xargs -0 gofmt -s -l -d 2>/dev/null) | |||
result=$(find . ! -path './vendor*' -name '*.go' -print0 | xargs -0 gofmt -s -l -d 2>/dev/null) |
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.
Do you need to add vendor
here? @SataQiu
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.
This is an implicit bug. It does not exclude possible vendor
directory. If we run make go-mod-vendor
and then run make check
, it will failed.
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.
We should not check vendor, Right?
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.
Yes, but after migrating to golangci-lint we don't run make go-mod-vendor
now. So I think you can remove this.
a61e4a7
to
fac9805
Compare
Signed-off-by: SataQiu <[email protected]>
fac9805
to
c8c81cb
Compare
Generally LGTM. While I still have a question, if I am new guy to contribute to dragonfly, when I forgot to add the boilerplate, then the CI would fail, but what exactly error message the CI output would throw to me? Is the error message friendly to a new guy? |
Someting like this:
If we have a command like |
No, I do not think so. I think the boilerplate should be made from the developer manually. Everyone should be aware of the copyright part and some others. If the script helps to do this, then lots of developer can escape from deep understanding the duties and obligations. |
LGTM, thanks a lot for your great work. |
…leci Feature: add code boilerplate check into circleci
…leci Feature: add code boilerplate check into circleci
Ⅰ. Describe what this PR did
Feature: add code format check into circleci
check-boilerplate.go
always exit with 0, so we can catch the outputⅡ. Does this pull request fix one issue?
Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)
Ⅳ. Describe how to verify it
make boilerplate-check
Ⅴ. Special notes for reviews