-
Notifications
You must be signed in to change notification settings - Fork 4
Add gofmt & go mod tidy in CI
#139
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
Conversation
.github/workflows/test.yml
Outdated
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'm not exactly sure how this works in a CI...but -w will "fix" the code. Is -d the more "suitable" option here, which displays the issues rather than fixes them?
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 the challenge here is that the failed command is github do not make the test to fail. See this discussion, I think it is still not implemented yet
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 tried on 1e49fd0, to double check the behavior, moving the PR to draft again
edit: after testing gofmt -s -d ., the CI does not fail in that case:

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.
ah I was going to suggest something I thought was smart - but I just found it in the thread you linked lol
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'm currently testing this in my own PR:
script:
# Only the sds-go folder needs to be checked since generation-checks takes care of the generated code
- output=$(gofmt -d -s sds-go)
- if [[ -n "$output" ]]; then echo "gofmt failed"; echo "$output"; exit 1; fi
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.
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.
The script suggested is more complicated than the current one. I'm not sure it's a real improvement
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.
Sorry I'd missed your suggestion - I agree with you and I'll be following that in my own PR.
5b65903 to
1e49fd0
Compare
1e49fd0 to
6997dfb
Compare
|
/merge |
Devflow running:
|
fbryden
left a comment
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
Add
gofmtandgo mod tidyin the CI to make sure go files are always formatted. Before fixing formatting, the CI failed, it demonstrates that the formatter works as expected: