Skip to content
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

build: Use golangci action and make parallel. #3160

Closed
wants to merge 2 commits into from

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Jul 21, 2023

This updates the GitHub workflow to use the official golangci-lint action which has additional caching logic and also creates GitHub annotations for any issues which makes it easier to identify issues versus needing to dig through build logs.

It also arranges for the linters to run as a separate job which executes in parallel to the go build and tests.

Since the repository has multiple modules and golangci-lint does not support running all modules in the repository directly, this uses a separate job to resolve the modules dynamically and then feeds those into the separate linter job as a matrix of modules (work directories) so the linters run on all modules in the repo.

In order to avoid running the linters as a part of the normal test job while still allowing developers to invoke all of the tests and linters via the "run_tests.sh" script, this separates the linter logic into a separate "lint.sh" script and conditionally invokes that script only when not running as a GitHub action.

Finally, it pins the dependencies for both the action itself as well as the golangci-lint version by using their respective hashes.

This updates to the following Github Actions:

- actions/setup-go@fac708d #v4.0.1
- actions/checkout@c85c95e #v3.5.3
@davecgh davecgh added this to the 1.9.0 milestone Jul 21, 2023
@davecgh davecgh force-pushed the build_parallel_lint branch 7 times, most recently from efd1186 to c37ca08 Compare July 21, 2023 01:23
This updates the GitHub workflow to use the official golangci-lint
action which has additional caching logic and also creates GitHub
annotations for any issues which makes it easier to identify issues
versus needing to dig through build logs.

It also arranges for the linters to run as a separate job which executes
in parallel to the go build and tests.

Since the repository has multiple modules and golangci-lint does not
support running all modules in the repository directly, this uses a
separate job to resolve the modules dynamically and then feeds those
into the separate linter job as a matrix of modules (work directories)
so the linters run on all modules in the repo.

In order to avoid running the linters as a part of the normal test job
while still allowing developers to invoke all of the tests and linters
via the "run_tests.sh" script, this separates the linter logic into a
separate "lint.sh" script and conditionally invokes that script only
when not running as a GitHub action.

Finally, it pins the dependencies for both the action itself as well as
the golangci-lint version by using their respective hashes.
@davecgh
Copy link
Member Author

davecgh commented Jul 21, 2023

This works as of the latest updates, but it's really not ideal due to the way it has to create multiple jobs that each require independent runners and that it also requires repeating the pinned dependencies which themselves can't be abstracted into variables because GitHub's actions don't support any of the necessary contexts in the uses clause.

Given that, I prefer to wait until golangci-lint can properly lint all modules from a single invocation instead.

@davecgh davecgh closed this Jul 21, 2023
@davecgh davecgh deleted the build_parallel_lint branch July 21, 2023 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant