Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 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 May 30, 2025
87c284c
Add comprehensive CI/CD setup with code formatting checks
bluet May 30, 2025
661b8d8
Add .dccache to gitignore
bluet May 30, 2025
bebb04a
Fix security and functionality issues from PR review
bluet May 30, 2025
88b4d58
Focus on package manager tools instead of OS-specific detection
bluet May 30, 2025
4153e7b
Add project documentation and testing infrastructure
bluet May 30, 2025
d8b0128
Update documentation to reflect current state and tool-focused philos…
bluet May 30, 2025
de93361
Update Go version to 1.24.3 (latest stable)
bluet May 30, 2025
dfe09f0
Remove outdated .go-version file
bluet May 30, 2025
a9a8ca0
Apply code formatting (gofmt + goimports)
bluet May 30, 2025
96e1aa9
Fix TestParseFindOutput package ordering issue
bluet May 30, 2025
41a0985
remove temp file
bluet May 30, 2025
7275ffe
Fix non-deterministic package ordering in ParseFindOutput
bluet May 30, 2025
58ebcd4
Fix documentation issues found in PR review
bluet May 30, 2025
552392e
Fix remaining nitpick issues from PR review
bluet May 30, 2025
2391ec2
Fix Go version in .tool-versions
bluet May 30, 2025
432aa6e
Revert Go version - 1.24.3 was correct
bluet May 30, 2025
9aac6b2
Align Go version requirements with .tool-versions
bluet May 30, 2025
b4ff570
Update CI workflows and go.mod to Go 1.23/1.24
bluet May 30, 2025
4f4e365
Modernize development infrastructure and documentation
bluet May 30, 2025
6a4ac33
Upgrade to Apache License 2.0 and enhance README badges
bluet May 30, 2025
89b0b4a
Sync all documentation with latest project status
bluet May 30, 2025
1bde898
Address PR #13 review comments
bluet May 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/README.md
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`
58 changes: 58 additions & 0 deletions .github/workflows/lint.yml
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 ]

Comment thread
coderabbitai[bot] marked this conversation as resolved.
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
Comment thread Fixed
44 changes: 44 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Test

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

Comment thread
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']

Comment thread
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
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,13 @@ go.work

bin/
tmp/
**/*.log
**/*.log.dccache

# Development cache and temporary files
.dccache
*.log

# Temporary development notes (not part of official docs)
*_improvements.md
*_notes.md
*_todo.md
2 changes: 0 additions & 2 deletions .go-version

This file was deleted.

102 changes: 102 additions & 0 deletions .golangci.yml
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
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
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
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
golang 1.21.5
golang 1.24.3

Loading