-
Notifications
You must be signed in to change notification settings - Fork 178
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 Build/Test/Lint/go mod/vendor consistency workflow #328
Add Build/Test/Lint/go mod/vendor consistency workflow #328
Conversation
With golangci, i think its better to maintain a Also i think it might be better to have this as another job within the test workflow that way we consolidate tests to a single file WDYT? It would be great if there was also a makefile target for it so its easier for developers to test it before submitting a PR example of Makefile target: Invoking it locally via Makefile can be done at a later stage though. |
@adrianchiris Good point. Ill rework it to what you suggested. |
ddd2e06
to
90a1f96
Compare
Will add the makefile updates in a following PR. Thanks for the great input @adrianchiris. Combining build, test, lint it into one workflow is more ergonomic and gives you an overview on a single 'webpage'. |
@martinkennelly will you be able to add another commit to fix the issues discovered in the tests you added ? |
Workflow added to build binary using multiple golang versions. Also, executes unit tests and various static analysis tools. Golanglint-ci conf file added to repository to enable local testing. Signed-off-by: Kennelly, Martin <[email protected]>
Signed-off-by: Martin Kennelly <[email protected]>
Disabled golint due to currently in archive mode. Sorted imports correctly. Correctly grammar/format mistakes. Modified go.(mod|sum) to add context. Signed-off-by: Martin Kennelly <[email protected]>
Executed go mod vendor to ensure vendor dir is consistent with go.mod. Signed-off-by: Martin Kennelly <[email protected]>
71c8b6b
to
37d9a4a
Compare
Signed-off-by: Martin Kennelly <[email protected]>
@adrianchiris Force push was re-basing against master. In the commit "Partial fix for static analysis errors", I needed to add "context" to the go mod file to fix an issue. I then executed go mod tidy in that same commit. In the next commit, I then added the changes from go mod vendor to a separate commit which may aid your review of all the static scan fixes. Enjoy the review :)... |
pkg/netdevice/netDeviceProvider.go
Outdated
@@ -104,16 +106,16 @@ func hasDefaultRoute(pciAddr string) (bool, error) { | |||
} | |||
|
|||
if len(ifNames) > 0 { // there's at least one interface name found | |||
for _, ifName := range ifNames { | |||
link, err := netlink.LinkByName(ifName) | |||
for iIfName := range ifNames { |
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.
not really a fan of this, do you recall which CI check complains for the string copy here ?
i dont think these memory optimizations should be a strict requirement.
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.
Linter message:
hugeParam: X is heavy (C bytes); consider passing it by pointer (gocritic)
yeah - I did it just to silence the CI check output. Definitely agree it shouldn't be a strict requirement since this software is just a control plane component and it's dealing with objects in memory that are relatively small mem footprint (~300bytes) and are few in number.
Do you not like it because it reduces readability? I think it's fine but happy to revert if you want.
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 not like it because it reduces readability?
yes exactly. so essentially i prefer to ignore this check or make it less restrictive so it would work in most cases.
perhaps just set a bigger threshold for this.
from gocritic docs:
@hugeParam.sizeThreshold
size in bytes that makes the warning trigger (default 80)
so maybe set this to a higher number ? (512?)
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
pkg/types/types.go
Outdated
DeviceType DeviceType `json:"deviceType,omitempty"` | ||
Selectors *json.RawMessage `json:"selectors,omitempty"` | ||
SelectorObj interface{} | ||
ResourcePrefix string `json:"resourcePrefix,omitempty"` // optional resource prefix that will overwrite |
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.
nit: you can put long comments above the variable, I think its clearer that way, especially for multiline comments
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
name: Hadolint | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: brpaz/[email protected] |
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.
should we just ignore DL3018
for now ?
alternative is to just fix the packages we install to whatever is being installed today.
(this has its downside though...)
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 don't think we should ignore it because it will reduce the need for a discussion and outcome. I will create an issue following this PR to get consensus for this issue. We may just want to ignore it..
Pros for setting it to a version:
We get a version we know that works - more deterministic.
Cons for settings it to a version:
We need to update the version before its no longer available in the package managers repo or it will break our builds.
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 +1 on opening an issue and meanwhile ignore so check passes with current state of things.
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. Ignored following community response on the issue.
looking at ShellCheck issues, they seem relatively straight forward. most remaining golang-ci issues dont seem to be too complex, but are not instant fixes. |
Signed-off-by: Martin Kennelly <[email protected]>
Signed-off-by: Martin Kennelly <[email protected]>
Signed-off-by: Martin Kennelly <[email protected]>
Disabled because we are not using any complicated flags in entrypoint.sh. Did not want to replace with printf. We are set to alpines almquist shell by default in our images and ash supports "-e" flag. Signed-off-by: Martin Kennelly <[email protected]>
Signed-off-by: Martin Kennelly <[email protected]>
This partially reverts commit aa3d514 pointless memory optimisation. Signed-off-by: Martin Kennelly <[email protected]>
This is a control plane component. As such, we are moving relatively little data in memory and there is no "hot path". Strictly following the gocritic advice reduces readability when pure perf isn't that important. Signed-off-by: Martin Kennelly <[email protected]>
As a community, we decided not to pin pkg versions. If we do not pin, we consume pkg fixes. If we do not pin, we test against latest pkgs. We wish to let downstream pin if they wish. Signed-off-by: Martin Kennelly <[email protected]>
528f575
to
0690c55
Compare
Signed-off-by: Martin Kennelly <[email protected]>
Use COPY instead of ADD per DL3020. Ignore pinning version per GH issue 368. Signed-off-by: Martin Kennelly <[email protected]>
@adrianchiris I needed to bump hadolint version to get ignore option and then it showed up issues in rhel7 dockerfile. Corrected them minor issue and needed to add an ignore tag for yum to hadolint. I think we are good for merge. Thanks for all your support here. Edit: There's a lot of commits. Don't mind squashing but there is some value in them as well.. Leave it up to you. |
Thanks for working on this Martin ! I see Mellanox CI is failing on this PR with error deploying device plugin.
|
Incorrectly passing args to SRIOV DP binary using exec. Ignored shellcheck error as word splitting is desirable. Globbing is disabled. Fix could be converting to an array but it is too much work for no gain. Signed-off-by: Martin Kennelly <[email protected]>
Thanks Martin ! LGTM, I will followup with a fix for remaining golangci-lint issues. |
@adrianchiris Embarrassingly, I did not. Lesson learned. |
Signed-off-by: Kennelly, Martin [email protected]
#327