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

ci: integrate golangci-lint with new workflow #41

Merged
merged 8 commits into from
Jul 11, 2024

Conversation

supitsdu
Copy link
Owner

@supitsdu supitsdu commented Jul 10, 2024

Tasks

  • Renamed .github/workflows/go.yml to go-standards.yml
  • Integrated golangci-lint into the Go Standards workflow
  • Updated golangci-lint configuration to optimize for CI workflows
  • Added comments and detailed explanations to the workflow and configuration files
  • Utilized latest GitHub actions versions, including actions/upload-artifact@v4

This commit aims to enhance code quality checks by incorporating comprehensive linting and ensuring compatibility with the latest GitHub actions.

- Renamed .github/workflows/go.yml to go-standards.yml
- Integrated golangci-lint into the Go Standards workflow
- Updated golangci-lint configuration to optimize for CI workflows
- Added comments and detailed explanations to the workflow and configuration files
- Utilized latest GitHub actions versions, including actions/upload-artifact@v4

This commit enhances code quality checks by incorporating comprehensive linting and ensuring compatibility with the latest GitHub actions.
@supitsdu supitsdu added in-progress Issues or PRs currently being worked on. ci Issues or PRs related to continuous integration (CI) pipelines. labels Jul 10, 2024
supitsdu added 5 commits July 10, 2024 00:57
- Fixed unchecked errors in the Clipper CLI tool.
- Corrected variable names to follow naming conventions.

These changes ensure the code meets the quality standards set by GolangCI and improve code readability and maintainability.
- Fixed issues reported by golangci-lint in the Clipper CLI tool.
- Updated test files to address linting errors.
- Enhanced code quality and ensured compliance with linting rules.

This commit improves code quality by adhering to golangci-lint standards, enhancing maintainability and readability.
- Adjusted golangci-lint action configuration to generate checkstyle-formatted report.
- Updated artifact upload step to reflect new report file format.
.github/workflows/go-standards.yml Outdated Show resolved Hide resolved
.github/workflows/go-standards.yml Outdated Show resolved Hide resolved
.github/workflows/go-standards.yml Outdated Show resolved Hide resolved
.github/workflows/go-standards.yml Outdated Show resolved Hide resolved
supitsdu added 2 commits July 11, 2024 08:42
- To ensure we always run on the latest stable version of Go we will use
  the stable option as review by @ccoVeile
@supitsdu supitsdu removed the in-progress Issues or PRs currently being worked on. label Jul 11, 2024
@supitsdu supitsdu merged commit 434a90d into main Jul 11, 2024
1 check passed
@supitsdu supitsdu deleted the ci/add-linter-to-workflow branch July 11, 2024 12:10
@@ -1,151 +1,82 @@
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice rework.

I'm curious, where did you find this setting? Did you use an official golangci-lint one and adapted it?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I wrote that by consulting the GolangCI docs and the helper linters command provided by the CLI tool. I didn't find a ready-made config that fit, so I used a trial-and-error approach, adjusting values, checking results, and researching as needed. It's definitely not the best option out there but it tackles the problem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find a ready-made config that fit, so I used a trial-and-error approach, adjusting values, checking results, and researching as needed.

That's exactly why I started working on

https://github.com/ccoVeille/golangci-lint-config-examples

I only worked on the first steps. I will provide more examples after my holidays

}

// IsCIEnvironment checks if the code is running in a CI environment.
func IsCIEnvironment() bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like what you did.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I presumed I would use this quite a few later, always nice to have a helper/utility function and avoid code repetitions.


// IsCIEnvironment checks if the code is running in a CI environment.
func IsCIEnvironment() bool {
return os.Getenv("GITHUB_ACTIONS") == "true"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a regular and documented env variable?

I've never seen it.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, I've searched for a way to use environment variables approach as you suggested before and found this at Learn Github Actions - Variables

It says the following:
GITHUB_ACTIONS
Always set to true when GitHub Actions is running the workflow. You can use this variable to differentiate when tests are being run locally or by GitHub Actions.

Which as the descriptions suggests it fits perfectly for this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Issues or PRs related to continuous integration (CI) pipelines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants