-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 development scripts #2928
Add development scripts #2928
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2928 +/- ##
=======================================
Coverage 98.17% 98.17%
=======================================
Files 143 143
Lines 12597 12597
=======================================
Hits 12367 12367
Misses 156 156
Partials 74 74 |
# Conflicts: # .github/workflows/linter.yml
Would it bother/upset you if I asked you to rename all the bash scripts in the "scripts" directory to have a ".sh" suffix? |
I can go either way on script names. I noticed .gitignore has a |
Ah, yes, please leave the |
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 looks great, @WillAbides !
Thank you so much for doing this! I think it will help users and maintainers alike.
While you are touching parts of CONTRIBUTING.md, I hope you don't mind if I ask you to tweak a couple things that aren't actually related to your PR? That would be awesome.
Co-authored-by: Glenn Lewis <[email protected]>
Co-authored-by: Glenn Lewis <[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.
Excellent, @WillAbides - thank you!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
Thank you, @valbeat ! @WillAbides - do you want to change "scripts" back to your original "script" before I merge? |
Thanks. I'll update it in the morning. |
@gmlewis It's ready to go now |
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.
Thank you, @WillAbides !
LGTM.
Merging.
closes #2927
Scripts
This adds the four scripts proposed in #2927.
The scripts all follow the basic pattern of iterating over the go modules in the repo and running the appropriate commands in each directory. Because of this, there is some duplicate code. I chose to keep it this way because deduping it added complexity, and I wanted to keep these scripts as simple as possible to understand.
The only dependencies for these scripts are git and a posix shell.
script/fmt.sh
is the simplest one. It runsgo fmt ./...
in each module directory.script/generate.sh
runsgo generate ./...
andgo mod tidy -compat '1.17'
in each module directory. It also has a--check
flag which causes it to run on a temporary git worktree and fail if any new diff is created.script/lint.sh
runsgolangci-lint run
on each module then runsscript/generate.sh --check
. It installs golangci-lint inbin/
if needed.script/test.sh
runsgo test
in each module directory. If arguments are provided, those are used as arguments forgo test
, otherwise it uses the default arguments-race -covermode atomic ./...
script/lint.sh
andscript/test.sh
skip the module inexample/newreposecretwithlibsodium
because it cannot compile unless libsodium is available.CONTRIBUTING.md
Workflow changes
linter.yml
script/lint.sh
instead of using the golangci-lint action.script/lint.sh
iterates over modules, I was able to remove the run matrix. We now only run one lint job instead of four.script/lint.sh
validatesgo generate
.tests.yml
script/test.sh
instead of runninggo test
multiple times in separate steps.go generate
now that it is checked in lint.Misc changes
Running
script/test.sh
exposed an issue where theexamples
module won't compile on Windows becausesyscall.Stdin
is typed differently on Windows. I resolved this by replacingsyscall.Stdin
withint(os.Stdin.Fd())