Skip to content

Upgrade to golangci-lint v2 and fix all lint errors #296

Upgrade to golangci-lint v2 and fix all lint errors

Upgrade to golangci-lint v2 and fix all lint errors #296

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
# Linting and basic checks
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Download dependencies
run: go mod download
- name: Verify dependencies
run: go mod verify
- name: Run vet
run: go vet ./...
- name: Run fmt check
run: |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "The following files are not properly formatted:"
gofmt -s -l .
exit 1
fi
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v7
# Fast tests for quick feedback
fast-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Run fast tests
run: go test -race -cover -timeout=3m ./...
# Integration and stress tests
integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Run integration tests
run: make test-integration
# Build and test binaries
build-test:
runs-on: ubuntu-latest
needs: [fast-tests] # Only run if fast tests pass
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Build navigator
run: go build -o navigator ./cmd/navigator
- name: Test binary
run: |
# Create minimal test environment with YAML configuration
mkdir -p /tmp/test-rails/config
cat > /tmp/test-rails/config/navigator.yml << 'EOF'
server:
listen: 0 # Use port 0 for testing
hostname: localhost
public_dir: /tmp/test-rails/public
pools:
max_size: 1
idle_timeout: 300
start_port: 4000
auth:
enabled: false
static:
directories: []
extensions: [html, css, js]
try_files:
enabled: false
applications:
env: {}
tenants: []
managed_processes: []
EOF
mkdir -p /tmp/test-rails/public
# Test that navigator binary starts and exits cleanly with YAML config
echo "Testing navigator..."
timeout 5s ./navigator /tmp/test-rails/config/navigator.yml || [ $? -eq 124 ]
build:
runs-on: ubuntu-latest
needs: [lint, fast-tests, integration-tests, build-test]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Build binaries
run: |
# Navigator
# Linux AMD64
GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o navigator-linux-amd64 ./cmd/navigator
# Linux ARM64
GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -o navigator-linux-arm64 ./cmd/navigator
# macOS AMD64
GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w" -o navigator-darwin-amd64 ./cmd/navigator
# macOS ARM64
GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w" -o navigator-darwin-arm64 ./cmd/navigator
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: navigator-binaries
path: navigator*