Skip to content

clean up cmd and logging #18

clean up cmd and logging

clean up cmd and logging #18

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
lint-and-test:
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.24.x'
cache: true # Enable automatic caching
- name: Run format check
run: |
make format
if ! git diff --quiet; then
echo "❌ Code is not formatted. Run 'make format' to fix:"
git diff
exit 1
fi
echo "✅ Code is properly formatted and tidy"
- name: Run linting
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout=5m --verbose
- name: Run tests with coverage
run: make test-coverage
- name: Upload coverage reports
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: |
coverage.out
coverage.html
- name: Test build
run: |
echo "🔨 Testing build..."
make build
./athena --help > /dev/null
echo "✅ Build successful"
- name: Check binary size
run: |
BINARY_SIZE=$(stat -f%z athena 2>/dev/null || stat -c%s athena)
echo "📦 Binary size: $(numfmt --to=iec-i --suffix=B $BINARY_SIZE 2>/dev/null || echo $BINARY_SIZE bytes)"
# Warn if binary exceeds 10MB (Cobra should add <5MB)
if [ $BINARY_SIZE -gt 10485760 ]; then
echo "⚠️ Warning: Binary size exceeds 10MB threshold"
echo "Binary size: $BINARY_SIZE bytes"
else
echo "✅ Binary size within acceptable limits"
fi
# Test CLI subcommands on multiple platforms
cli-tests:
runs-on: ${{ matrix.os }}
needs: lint-and-test
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.x'
cache: true
- name: Build binary
run: make build
- name: Test CLI commands (Unix)
if: runner.os != 'Windows'
run: |
echo "🧪 Testing CLI subcommands on ${{ runner.os }}..."
# Test help
./athena --help
./athena start --help
./athena stop --help
./athena status --help
./athena logs --help
./athena code --help
# Test version/help flags work
./athena --version || true # May not have version flag
echo "✅ CLI commands validated on ${{ runner.os }}"
- name: Test CLI commands (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
echo "🧪 Testing CLI subcommands on Windows..."
# Test help
./athena.exe --help
./athena.exe start --help
./athena.exe stop --help
./athena.exe status --help
./athena.exe logs --help
./athena.exe code --help
echo "✅ CLI commands validated on Windows"
- name: CLI response time benchmark
if: runner.os != 'Windows'
run: |
echo "⏱️ Benchmarking CLI response times..."
# Test help command response time (<100ms target)
TIME_START=$(date +%s%N)
./athena --help > /dev/null
TIME_END=$(date +%s%N)
ELAPSED_MS=$(( ($TIME_END - $TIME_START) / 1000000 ))
echo "CLI help command: ${ELAPSED_MS}ms"
if [ $ELAPSED_MS -gt 100 ]; then
echo "⚠️ Warning: CLI response time exceeded 100ms threshold"
else
echo "✅ CLI response time within acceptable limits"
fi
# Test cross-platform builds (only on main branch)
cross-platform-build:
runs-on: ubuntu-latest
needs: lint-and-test
if: github.ref == 'refs/heads/main'
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
- goos: windows
goarch: amd64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.x'
cache: true
- name: Build for ${{ matrix.goos }}-${{ matrix.goarch }}
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
echo "🔨 Building for ${{ matrix.goos }}-${{ matrix.goarch }}..."
if [ "$GOOS" = "windows" ]; then
go build -ldflags="-s -w" -o athena-${{ matrix.goos }}-${{ matrix.goarch }}.exe ./cmd/athena
else
go build -ldflags="-s -w" -o athena-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/athena
fi
echo "✅ Build successful"
# Security scanning
security:
runs-on: ubuntu-latest
needs: lint-and-test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.x'
cache: true
- name: Run vulnerability check
run: make vuln