-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add golangci-lint version manager (#3457)
The changes in this pull request involve updates to the Go workflow configuration, the introduction of a new Golang CI Lint Version Manager, and enhancements to documentation files. The workflow modifications include dynamic version handling for golangci-lint and improved job execution conditions. Additionally, the .golangci-version file has been updated to specify a new version. Documentation in CONTRIBUTING.md, README.md, and a new README.md for the Golang CI Lint Version Manager has been added to clarify contribution processes and setup instructions. Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: [email protected] <[email protected]> Co-authored-by: Trajan0x <[email protected]>
- Loading branch information
1 parent
fb55d90
commit 3511c73
Showing
39 changed files
with
2,206 additions
and
572 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,3 +130,6 @@ main | |
.devnet/ | ||
|
||
**/__debug_bin* | ||
|
||
# golang-ci-lint binary | ||
contrib/golang-ci-lint/golang-ci-lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.61.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
coverage: | ||
status: | ||
project: | ||
default: | ||
target: '80%' | ||
threshold: '1%' | ||
patch: | ||
default: | ||
target: '80%' | ||
|
||
ignore: | ||
- '**/testdata/**' | ||
- '**/mocks/**' | ||
- '**/*_test.go' | ||
- '**/cmd/**' | ||
- '**/docs/**' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
project_name: golang-ci-lint | ||
|
||
monorepo: | ||
tag_prefix: contrib/golang-ci-lint/ | ||
dir: contrib/golang-ci-lint/ | ||
|
||
builds: | ||
- id: golang-ci-lint | ||
binary: golang-ci-lint | ||
gcflags: | ||
- all=-dwarflocationlists=true | ||
ldflags: | ||
- -s -w -extldflags '-static' | ||
tags: | ||
- netgo | ||
env: | ||
- CGO_ENABLED=0 | ||
main: main.go | ||
flags: | ||
- -trimpath | ||
goos: | ||
- linux | ||
goarch: | ||
- amd64 | ||
|
||
dockers: | ||
- goos: linux | ||
goarch: amd64 | ||
image_templates: | ||
- 'ghcr.io/synapsecns/sanguine/golang-ci-lint:latest' | ||
- 'ghcr.io/synapsecns/sanguine/golang-ci-lint:{{ .FullCommit }}' | ||
- 'ghcr.io/synapsecns/sanguine/golang-ci-lint:{{ .Tag }}' | ||
build_flag_templates: | ||
- '--label=org.opencontainers.image.created={{.Date}}' | ||
- '--label=org.opencontainers.image.name={{.ProjectName}}' | ||
- '--label=org.opencontainers.image.revision={{.FullCommit}}' | ||
- '--label=org.opencontainers.image.version={{.Version}}' | ||
- '--label=org.opencontainers.image.source={{.GitURL}}' | ||
dockerfile: ../../docker/golang-ci-lint.Dockerfile | ||
ids: | ||
- golang-ci-lint | ||
|
||
source: | ||
enabled: true | ||
|
||
archives: | ||
- format: tar.gz | ||
wrap_in_directory: true | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
name_template: '{{.ProjectName}}-{{.Version}}_{{.Os}}_{{.Arch}}' | ||
files: | ||
- README.md | ||
|
||
checksum: | ||
name_template: checksums.txt | ||
|
||
changelog: | ||
sort: asc | ||
|
||
report_sizes: true | ||
|
||
metadata: | ||
mod_timestamp: '{{ .CommitTimestamp }}' | ||
|
||
sboms: | ||
- artifacts: archive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../make/go.Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# Golang CI Lint Version Manager | ||
|
||
A standalone tool for managing and running specific versions of golangci-lint across different repositories. This package can be used in any Go project to ensure consistent linting with version pinning, regardless of where it's installed. | ||
|
||
## Features | ||
- **Cross-Repository Usage**: Can be installed and used in any Go project | ||
- **Version Pinning**: Automatically uses the version specified in `.golangci-version` | ||
- **Architecture Support**: Downloads correct binary for your system (AMD64/ARM64) | ||
- **Binary Caching**: Avoids redundant downloads of the same version | ||
- **Secure Downloads**: Verifies binary checksums for security | ||
- **CI/CD Integration**: Easy to integrate with GitHub Actions and other CI systems | ||
|
||
## Installation | ||
|
||
As a standalone tool: | ||
```bash | ||
go install github.com/synapsecns/sanguine/contrib/golang-ci-lint@latest | ||
``` | ||
|
||
Or in your project's go.mod: | ||
```go | ||
require github.com/synapsecns/sanguine/contrib/golang-ci-lint v1.0.0 | ||
``` | ||
|
||
## Usage | ||
|
||
### 1. Version Configuration | ||
Create a `.golangci-version` file in your repository root: | ||
``` | ||
1.61.0 | ||
``` | ||
|
||
### 2. Running the Linter | ||
|
||
As a standalone binary: | ||
```bash | ||
golang-ci-lint run --fix --config=.golangci.yml | ||
``` | ||
|
||
Or using go run: | ||
```bash | ||
go run github.com/synapsecns/sanguine/contrib/golang-ci-lint run --fix --config=.golangci.yml | ||
``` | ||
|
||
### 3. Makefile Integration | ||
|
||
Add to your project's Makefile: | ||
```makefile | ||
.PHONY: lint | ||
lint: | ||
go run github.com/synapsecns/sanguine/contrib/golang-ci-lint run --fix --config=.golangci.yml | ||
``` | ||
|
||
### 4. CI/CD Integration | ||
|
||
GitHub Actions example: | ||
```yaml | ||
name: Lint | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
- name: Install golang-ci-lint manager | ||
run: go install github.com/synapsecns/sanguine/contrib/golang-ci-lint@latest | ||
- name: Run linter | ||
run: golang-ci-lint run --config=.golangci.yml | ||
``` | ||
|
||
## Common Use Cases | ||
|
||
1. **Multiple Projects**: Use the same linter version across all your repositories | ||
2. **CI/CD Pipelines**: Ensure consistent linting in automated workflows | ||
3. **Team Collaboration**: Maintain consistent code style across development teams | ||
4. **Version Control**: Lock linter version to avoid unexpected behavior changes | ||
|
||
## Troubleshooting | ||
|
||
1. **Binary Not Found** | ||
```bash | ||
# Clear the cache and redownload | ||
rm -rf ~/.cache/golangci-lint | ||
golang-ci-lint run | ||
``` | ||
|
||
2. **Version Mismatch** | ||
- Ensure `.golangci-version` exists in repository root | ||
- Check file permissions and format | ||
|
||
3. **Architecture Issues** | ||
- The tool automatically detects and downloads the correct binary | ||
- Supported architectures: linux-amd64, linux-arm64, darwin-amd64, darwin-arm64, windows-amd64 | ||
- MacOS (/private/var) symlink handling: | ||
- Properly resolves /private/var to /var for temp directories | ||
- Maintains secure path validation across symlinked paths | ||
- Handles platform-specific temp directory structures | ||
|
||
## Contributing | ||
|
||
Contributions are welcome! Please ensure: | ||
- Cross-platform compatibility: | ||
- Linux: Standard path resolution | ||
- MacOS: Handles /private/var symlinks and temp directories | ||
- Windows: Supports standard Windows paths | ||
- Backward compatibility with existing `.golangci-version` files | ||
- Proper error handling and user feedback | ||
|
||
## License | ||
|
||
MIT License - See LICENSE file for details |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/synapsecns/sanguine/contrib/golang-ci-lint | ||
|
||
go 1.22.4 | ||
|
||
require github.com/integralist/go-findroot v0.0.0-20160518114804-ac90681525dc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/integralist/go-findroot v0.0.0-20160518114804-ac90681525dc h1:4IZpk3M4m6ypx0IlRoEyEyY1gAdicWLMQ0NcG/gBnnA= | ||
github.com/integralist/go-findroot v0.0.0-20160518114804-ac90681525dc/go.mod h1:UlaC6ndby46IJz9m/03cZPKKkR9ykeIVBBDE3UDBdJk= |
Oops, something went wrong.