-
Notifications
You must be signed in to change notification settings - Fork 7
Fix code formatting issues from PR #12 #13
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
9ea7bcc
Fix code formatting issues in PR #12
bluet 87c284c
Add comprehensive CI/CD setup with code formatting checks
bluet 661b8d8
Add .dccache to gitignore
bluet bebb04a
Fix security and functionality issues from PR review
bluet 88b4d58
Focus on package manager tools instead of OS-specific detection
bluet 4153e7b
Add project documentation and testing infrastructure
bluet d8b0128
Update documentation to reflect current state and tool-focused philos…
bluet de93361
Update Go version to 1.24.3 (latest stable)
bluet dfe09f0
Remove outdated .go-version file
bluet a9a8ca0
Apply code formatting (gofmt + goimports)
bluet 96e1aa9
Fix TestParseFindOutput package ordering issue
bluet 41a0985
remove temp file
bluet 7275ffe
Fix non-deterministic package ordering in ParseFindOutput
bluet 58ebcd4
Fix documentation issues found in PR review
bluet 552392e
Fix remaining nitpick issues from PR review
bluet 2391ec2
Fix Go version in .tool-versions
bluet 432aa6e
Revert Go version - 1.24.3 was correct
bluet 9aac6b2
Align Go version requirements with .tool-versions
bluet b4ff570
Update CI workflows and go.mod to Go 1.23/1.24
bluet 4f4e365
Modernize development infrastructure and documentation
bluet 6a4ac33
Upgrade to Apache License 2.0 and enhance README badges
bluet 89b0b4a
Sync all documentation with latest project status
bluet 1bde898
Address PR #13 review comments
bluet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,55 @@ | ||
| # CI/CD Workflows | ||
|
|
||
| This directory contains GitHub Actions workflows for the go-syspkg project. | ||
|
|
||
| ## Workflows | ||
|
|
||
| ### 1. Lint and Format (`lint.yml`) | ||
| Runs on every push and pull request to ensure code quality: | ||
| - **gofmt**: Checks code formatting | ||
| - **go vet**: Reports suspicious constructs | ||
| - **golangci-lint**: Comprehensive linting with multiple linters | ||
| - **go mod tidy**: Ensures go.mod and go.sum are up to date | ||
|
|
||
| ### 2. Test (`test.yml`) | ||
| Runs comprehensive tests across multiple platforms: | ||
| - **OS Matrix**: Ubuntu and macOS | ||
| - **Go Versions**: 1.21, 1.22, 1.23 | ||
| - **Coverage**: Uploads test coverage to Codecov | ||
| - **Race Detection**: Runs tests with race detector enabled | ||
|
|
||
| ## Local Development | ||
|
|
||
| ### Running Checks Locally | ||
| ```bash | ||
| # Format code | ||
| make format | ||
|
|
||
| # Check formatting and run linters | ||
| make check | ||
|
|
||
| # Run specific checks | ||
| gofmt -l . # List files that need formatting | ||
| go vet ./... # Run go vet | ||
| golangci-lint run # Run all linters | ||
| ``` | ||
|
|
||
| ### Pre-commit Hooks | ||
| Install pre-commit to run checks automatically before commits: | ||
| ```bash | ||
| pip install pre-commit | ||
| pre-commit install | ||
| ``` | ||
|
|
||
| ## Configuration Files | ||
|
|
||
| - `.golangci.yml`: Configures golangci-lint with enabled/disabled linters | ||
| - `.pre-commit-config.yaml`: Defines pre-commit hooks | ||
| - `Makefile`: Contains format and check targets | ||
|
|
||
| ## Adding New Checks | ||
|
|
||
| To add new linting rules: | ||
| 1. Update `.golangci.yml` to enable/disable linters | ||
| 2. Update the `lint.yml` workflow if needed | ||
| 3. Test locally with `make check` |
This file contains hidden or 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,58 @@ | ||
| name: Lint and Format | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: Lint and Format Check | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.21' | ||
| cache: true | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| go mod download | ||
| go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | ||
|
|
||
| - name: Run gofmt | ||
| run: | | ||
| # Check if gofmt reports any formatting issues | ||
| if [ -n "$(gofmt -l .)" ]; then | ||
| echo "The following files need formatting:" | ||
| gofmt -l . | ||
| echo "" | ||
| echo "Please run 'gofmt -w .' to format your code" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Run go vet | ||
| run: go vet ./... | ||
|
|
||
| - name: Run golangci-lint | ||
| run: golangci-lint run --timeout=5m | ||
|
|
||
| - name: Run go mod tidy check | ||
| run: | | ||
| go mod tidy | ||
| if [ -n "$(git status --porcelain)" ]; then | ||
| echo "go mod tidy produced changes:" | ||
| git diff | ||
| echo "" | ||
| echo "Please run 'go mod tidy' and commit the changes" | ||
| exit 1 | ||
| fi | ||
|
|
||
This file contains hidden or 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,44 @@ | ||
| name: Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Test | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest] | ||
| go-version: ['1.21', '1.22', '1.23'] | ||
|
|
||
|
bluet marked this conversation as resolved.
Outdated
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: ${{ matrix.go-version }} | ||
| cache: true | ||
|
|
||
| - name: Install dependencies | ||
| run: go mod download | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... | ||
|
|
||
| - name: Upload coverage to Codecov | ||
| if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.21' | ||
| uses: codecov/codecov-action@v4 | ||
| with: | ||
| file: ./coverage.txt | ||
| flags: unittests | ||
| name: codecov-umbrella | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -50,4 +50,4 @@ go.work | |
|
|
||
| bin/ | ||
| tmp/ | ||
| **/*.log | ||
| **/*.log.dccache | ||
This file contains hidden or 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,102 @@ | ||
| # golangci-lint configuration | ||
| # https://golangci-lint.run/usage/configuration/ | ||
|
|
||
| run: | ||
| timeout: 5m | ||
| tests: true | ||
| exclude-dirs: | ||
| - vendor | ||
| - testdata | ||
| - testing | ||
|
|
||
| linters: | ||
| enable: | ||
| # Default linters | ||
| - errcheck | ||
| - gosimple | ||
| - govet | ||
| - ineffassign | ||
| - staticcheck | ||
| - typecheck | ||
| - unused | ||
| # Additional linters | ||
| - gofmt | ||
| - goimports | ||
| - misspell | ||
| - unconvert | ||
| - gocyclo | ||
| - goprintffuncname | ||
| - gosec | ||
| - nakedret | ||
| - noctx | ||
| - nolintlint | ||
| - predeclared | ||
| - thelper | ||
| - tparallel | ||
| - unparam | ||
|
|
||
| disable: | ||
| - depguard | ||
| - dogsled | ||
| - dupl | ||
| - funlen | ||
| - gochecknoinits | ||
| - goconst | ||
| - gocritic | ||
| - gocognit | ||
| - lll | ||
| - nestif | ||
| - testpackage | ||
| - wrapcheck | ||
| - exhaustive | ||
| - exhaustruct | ||
| - nlreturn | ||
|
|
||
| linters-settings: | ||
| gofmt: | ||
| simplify: true | ||
| goimports: | ||
| local-prefixes: github.com/bluet/syspkg | ||
| govet: | ||
| enable: | ||
| - shadow | ||
| misspell: | ||
| locale: US | ||
| gocyclo: | ||
| min-complexity: 20 | ||
|
|
||
| issues: | ||
| exclude-rules: | ||
| # Exclude some linters from running on tests files | ||
| - path: _test\.go | ||
| linters: | ||
| - gosec | ||
| - gocyclo | ||
|
|
||
| # Exclude shadow warning for common patterns | ||
| - linters: | ||
| - govet | ||
| text: "shadow: declaration of \"err\"" | ||
|
|
||
| # Exclude misspelling in specific cases | ||
| - linters: | ||
| - misspell | ||
| text: "cancelled" | ||
|
|
||
| # Exclude unnecessary conversion in utils (string([]byte) is explicit) | ||
| - path: utils\.go | ||
| linters: | ||
| - unconvert | ||
| text: "unnecessary conversion" | ||
|
|
||
| # Exclude high cyclomatic complexity for main function | ||
| - path: cmd/syspkg/main\.go | ||
| linters: | ||
| - gocyclo | ||
| text: "cyclomatic complexity.*of func `main`" | ||
|
|
||
| # Maximum issues count per one linter | ||
| max-issues-per-linter: 50 | ||
|
|
||
| # Maximum count of issues with the same text | ||
| max-same-issues: 10 |
This file contains hidden or 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,21 @@ | ||
| # See https://pre-commit.com for more information | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v4.5.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| - id: end-of-file-fixer | ||
| - id: check-yaml | ||
| - id: check-added-large-files | ||
| - id: check-merge-conflict | ||
|
|
||
| - repo: https://github.com/dnephin/pre-commit-golang | ||
| rev: v0.5.1 | ||
| hooks: | ||
| - id: go-fmt | ||
| - id: go-vet | ||
| - id: go-imports | ||
| - id: go-cyclo | ||
| args: [-over=15] | ||
| - id: go-mod-tidy | ||
| - id: golangci-lint |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.