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
181 changes: 112 additions & 69 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,70 +15,32 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.24.x'
cache: true # Enable automatic caching

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

- name: Download dependencies
run: go mod download

- name: Run go fmt check
- name: Run format check
run: |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "❌ Code is not formatted. Run 'make fmt' to fix:"
gofmt -s -l .
echo ""
echo "Diff:"
gofmt -s -d .
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"
echo "βœ… Code is properly formatted and tidy"

- name: Run go mod tidy check
run: |
go mod tidy
if ! git diff --quiet go.mod go.sum; then
echo "❌ go.mod or go.sum is not tidy. Run 'go mod tidy' to fix"
git diff go.mod go.sum
exit 1
fi
echo "βœ… go.mod and go.sum are tidy"

- name: Run go vet
run: |
echo "πŸ” Running go vet..."
go vet ./...
echo "βœ… go vet passed"

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

- name: Run tests
run: |
echo "πŸ§ͺ Running tests..."
go test -v -race -coverprofile=coverage.out ./...
echo "βœ… Tests passed"

- name: Generate coverage report
run: |
go tool cover -html=coverage.out -o coverage.html
go tool cover -func=coverage.out
- name: Run tests with coverage
run: make test-coverage

- name: Upload coverage reports
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: |
Expand All @@ -88,10 +50,96 @@ jobs:
- name: Test build
run: |
echo "πŸ”¨ Testing build..."
go build -v -ldflags="-s -w" -o openrouter-cc-test main.go
./openrouter-cc-test --help > /dev/null
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
Expand All @@ -117,9 +165,10 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.24.x'
cache: true

- name: Build for ${{ matrix.goos }}-${{ matrix.goarch }}
env:
Expand All @@ -129,32 +178,26 @@ jobs:
run: |
echo "πŸ”¨ Building for ${{ matrix.goos }}-${{ matrix.goarch }}..."
if [ "$GOOS" = "windows" ]; then
go build -ldflags="-s -w" -o openrouter-cc-${{ matrix.goos }}-${{ matrix.goarch }}.exe main.go
go build -ldflags="-s -w" -o athena-${{ matrix.goos }}-${{ matrix.goarch }}.exe ./cmd/athena
else
go build -ldflags="-s -w" -o openrouter-cc-${{ matrix.goos }}-${{ matrix.goarch }} main.go
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@v4
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.24.x'
cache: true

- name: Run Gosec Security Scanner
uses: securecodewarrior/github-action-gosec@master
with:
args: './...'

- name: Run govulncheck
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
- name: Run vulnerability check
run: make vuln
36 changes: 18 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,31 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.24.x'
cache: true

- name: Run go fmt
- name: Run format check
run: |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "Code is not formatted. Run 'go fmt ./...' to fix:"
gofmt -s -l .
make format
if ! git diff --quiet; then
echo "Code is not formatted. Run 'make format' to fix:"
git diff
exit 1
fi

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

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

- name: Run tests
run: go test -v ./...
run: make test

- name: Test build
run: go build -v ./...
run: make build

build:
needs: lint-and-test
Expand Down Expand Up @@ -72,9 +71,10 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.24.x'
cache: true

- name: Build binary
env:
Expand All @@ -84,9 +84,9 @@ jobs:
run: |
mkdir -p dist
if [ "$GOOS" = "windows" ]; then
go build -ldflags="-s -w" -o dist/athena-${{ matrix.platform }}.exe main.go
go build -ldflags="-s -w" -o dist/athena-${{ matrix.platform }}.exe ./cmd/athena
else
go build -ldflags="-s -w" -o dist/athena-${{ matrix.platform }} main.go
go build -ldflags="-s -w" -o dist/athena-${{ matrix.platform }} ./cmd/athena
fi

- name: Create wrapper script (Unix)
Expand Down Expand Up @@ -338,7 +338,7 @@ jobs:
EOF

- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.platform }}
path: dist/
Expand All @@ -352,7 +352,7 @@ jobs:
- uses: actions/checkout@v4

- name: Download all artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: artifacts

Expand Down
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ help: ## Show this help message

# Development commands
build: ## Build the binary
ifeq ($(OS),Windows_NT)
go build -ldflags="-s -w" -o athena.exe ./cmd/athena
else
go build -ldflags="-s -w" -o athena ./cmd/athena
endif

test: ## Run tests
go test -v ./...
Expand All @@ -20,11 +24,15 @@ test-coverage: ## Run tests with coverage
lint: ## Run linting
golangci-lint run

vuln: ## Run vulnerability check
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...

format: ## Format code
gofmt -s -w .
go mod tidy

check: format lint test ## Run all checks (format, vet, lint, test)
check: format lint test vuln ## Run all checks (format, lint, test, vuln)

clean: ## Clean build artifacts
rm -f athena athena-*
Expand Down
Loading
Loading