Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
440 changes: 440 additions & 0 deletions .github/CONTRIBUTING.md

Large diffs are not rendered by default.

119 changes: 119 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: CI

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

jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.21', '1.22', '1.23']

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-

- name: Download dependencies
run: go mod download

- name: Verify dependencies
run: go mod verify

- name: Run go vet
run: go vet ./...

- name: Run tests
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.out
flags: unittests
name: codecov-umbrella

lint:
name: Lint
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'

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
args: --timeout=5m

build:
name: Build
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'

- name: Build
run: go build -v -o subzy main.go

- name: Test binary
run: ./subzy version

security:
name: Security Scan
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'

- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: '-no-fail -fmt sarif -out results.sarif ./...'

- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif

- name: Run govulncheck
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,10 @@ build/*
*.syso

.idea

# Binary
subzy

# Test coverage files
coverage.out
coverage.html
89 changes: 89 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
run:
timeout: 5m
tests: true
modules-download-mode: readonly

linters:
enable:
- bodyclose
- dogsled
- errcheck
- goconst
- gocritic
- gofmt
- goimports
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- revive
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- whitespace

linters-settings:
govet:
check-shadowing: true
gofmt:
simplify: true
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
errcheck:
check-type-assertions: true
check-blank: true
goconst:
min-len: 3
min-occurrences: 3
misspell:
locale: US
revive:
rules:
- name: exported
severity: warning
disabled: false
- name: package-comments
severity: warning
disabled: true
- name: unexported-return
severity: warning
disabled: false

issues:
exclude-rules:
# Exclude some linters from running on tests files
- path: _test\.go
linters:
- goconst
- errcheck
- gosec

# Maximum issues count per one linter
max-issues-per-linter: 50

# Maximum count of issues with the same text
max-same-issues: 3

# Show only new issues
new: false

# Fix found issues (if supported by the linter)
fix: false

output:
format: colored-line-number
print-issued-lines: true
print-linter-name: true
uniq-by-line: true
sort-results: true
81 changes: 81 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
repos:
- repo: local
hooks:
# Go formatting
- id: go-fmt
name: Go Format
entry: gofmt -w
language: system
files: \.go$
description: Run gofmt on Go files

# Go imports
- id: go-imports
name: Go Imports
entry: bash -c 'goimports -w $(find . -type f -name "*.go" | grep -v vendor)'
language: system
files: \.go$
description: Run goimports on Go files
pass_filenames: false

# Go vet
- id: go-vet
name: Go Vet
entry: go vet ./...
language: system
pass_filenames: false
description: Run go vet

# Go mod tidy
- id: go-mod-tidy
name: Go Mod Tidy
entry: go mod tidy
language: system
pass_filenames: false
description: Ensure go.mod and go.sum are tidy

# Go test (short)
- id: go-test-short
name: Go Test (short)
entry: go test -short ./...
language: system
pass_filenames: false
description: Run short tests

# golangci-lint (if installed)
- id: golangci-lint
name: golangci-lint
entry: bash -c 'if command -v golangci-lint >/dev/null 2>&1; then golangci-lint run; else echo "golangci-lint not installed, skipping"; fi'
language: system
pass_filenames: false
description: Run golangci-lint if available

# Check for large files
- id: check-added-large-files
name: Check for large files
entry: bash -c 'for file in $(git diff --cached --name-only --diff-filter=A); do size=$(wc -c < "$file" 2>/dev/null || echo 0); if [ "$size" -gt 1048576 ]; then echo "Error: $file is larger than 1MB"; exit 1; fi; done'
language: system
pass_filenames: false
description: Prevent committing files larger than 1MB

# Check for merge conflicts
- id: check-merge-conflict
name: Check for merge conflicts
entry: bash -c 'if git diff --cached | grep -q "^<<<<<<<\\|^=======\\|^>>>>>>>"; then echo "Error: Merge conflict markers found"; exit 1; fi'
language: system
pass_filenames: false
description: Check for merge conflict markers

# Standard pre-commit hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer
- id: check-yaml
- id: check-json
- id: check-added-large-files
args: ['--maxkb=1024']
- id: check-merge-conflict
- id: detect-private-key
Loading
Loading