-
Notifications
You must be signed in to change notification settings - Fork 152
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
add fmt check in ci #51
Conversation
f108ba9
to
1eb97df
Compare
Codecov Report
@@ Coverage Diff @@
## main #51 +/- ##
=======================================
Coverage 66.93% 66.93%
=======================================
Files 146 146
Lines 3179 3179
=======================================
Hits 2128 2128
Misses 810 810
Partials 241 241
|
.circleci/config.yml
Outdated
@@ -17,6 +17,9 @@ jobs: | |||
- image: golang:1.15 | |||
steps: | |||
- checkout | |||
- run: | |||
name: Enforce Go Formatted Code | |||
command: test -z "$(go fmt ./...)" |
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.
Didn't know that you could use test -z
to return false or true and that CircleCI would exit. Thanks :)
What I envisioned is more verbose. We could display what are the files we need to re-format just like terraform does.
- run:
name: Enforce Go Formatted Code
command: go fmt ./...
- run:
name: Verify No Code Was Generated
command: |
if [[ -z $(git status --porcelain) ]]; then
echo "Git directory is clean."
else
echo "Git directory is dirty. Run `make fmt` locally and commit any formatting fixes or generated code."
git status --porcelain
exit 1
fi
This is what they do in their ci/cd pipeline.
b6d9274
to
167f383
Compare
167f383
to
10bf355
Compare
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.
LGTM
Description
We had badly formated (not passed to fmt) file in main.
make
will create diff that add noise to PR.I added a check on ci during tests phase to prevent PR to be merge when fmt is not ok.