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
84 changes: 84 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI

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

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: true

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

test:
name: Test
runs-on: ubuntu-latest
needs: lint # Only run tests if lint passes
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: true

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

- name: Upload coverage
uses: codecov/codecov-action@v4
with:
files: ./coverage.out
fail_ci_if_error: false
continue-on-error: true

build:
name: Build
runs-on: ubuntu-latest
needs: test # Only build if tests pass
strategy:
matrix:
goos: [linux, darwin, windows]
goarch: [amd64, arm64]
exclude:
- goos: windows
goarch: arm64
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: true

- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
binary_name="dev-cli"
if [ "$GOOS" = "windows" ]; then
binary_name="${binary_name}.exe"
fi
go build -o "dist/${GOOS}-${GOARCH}/${binary_name}" .

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: dev-cli-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/
retention-days: 7
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: true

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76 changes: 76 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# golangci-lint configuration for dev-cli
# Focused on Docker API safety and common Go bugs
# Run: golangci-lint run ./...

run:
timeout: 5m
modules-download-mode: readonly

linters:
enable:
# Critical for Docker SDK - catch unhandled errors
- errcheck
# Static analysis for common bugs
- staticcheck
# Lightweight linter, catches common mistakes
- revive
# Detect ineffectual assignments
- ineffassign
# Check for unchecked type assertions
- unconvert
# Detect unused code
- unused
# Check for goroutine leaks (important for streaming logs)
- govet
# Check printf-style functions
- goprintffuncname

disable:
# Too noisy for dev tools
- gocritic
- gocyclo
- funlen
- gocognit

linters-settings:
errcheck:
# Check for ignored errors in defer statements
check-blank: true
# Don't report on explicitly ignored errors with _
exclude-functions:
- io.Copy
- (io.Closer).Close

revive:
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: error-return
- name: error-strings
- name: exported
- name: increment-decrement
- name: var-declaration
- name: package-comments
disabled: true # Not needed for internal packages

staticcheck:
checks:
- all
- -SA1019 # Ignore deprecation warnings for now

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

exclude-rules:
# Exclude some linters from running on test files
- path: _test\.go
linters:
- errcheck

# Exclude lll issues for long lines in go.mod
- path: go\.mod
linters:
- lll
68 changes: 68 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# GoReleaser configuration for dev-cli
# Triggered by: git tag v0.1.0 && git push origin v0.1.0

version: 2

project_name: dev-cli

before:
hooks:
- go mod tidy

builds:
- id: dev-cli
main: ./main.go
binary: dev-cli
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
ignore:
- goos: windows
goarch: arm64
ldflags:
- -s -w
- -X main.version={{.Version}}
- -X main.commit={{.ShortCommit}}
- -X main.date={{.Date}}

archives:
- id: default
format: tar.gz
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
format_overrides:
- goos: windows
format: zip
files:
- README.md
- LICENSE

checksum:
name_template: 'checksums.txt'

snapshot:
version_template: "{{ incpatch .Version }}-next"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- '^ci:'
- '^chore:'
- Merge pull request
- Merge branch

release:
github:
owner: opx0 # GitHub username/org
name: devops-agent-cli
draft: false
prerelease: auto
name_template: "v{{ .Version }}"
48 changes: 48 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# dev-cli Makefile
# Development tasks for linting, testing, and building

.PHONY: all build test lint clean install

# Default target
all: lint test build

# Build the CLI binary
build:
go build -o dev-cli .

# Run tests with race detection (important for sync.RWMutex in Registry)
test:
go test -v -race ./...

# Run short tests (skip integration tests that need Docker)
test-short:
go test -v -short ./...

# Run linter
lint:
golangci-lint run ./...

# Install golangci-lint if not present
install-lint:
@which golangci-lint > /dev/null || \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin

# Clean build artifacts
clean:
rm -f dev-cli
go clean

# Install the CLI locally
install: build
cp dev-cli $(GOPATH)/bin/ 2>/dev/null || cp dev-cli ~/go/bin/

# Run integration tests only (requires Docker)
test-integration:
go test -v -race -run Integration ./...

# Check for issues without fixing
check: lint test-short

# Tidy dependencies
tidy:
go mod tidy
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ sqlite3 ~/.devlogs/history.db "SELECT command, exit_code FROM history WHERE exit

## Configuration

The CLI is configured via `~/.dev-cli/config.yaml` or Environment Variables.
The CLI is configured via `~/.devlogs/config.yaml` or Environment Variables.

| Variable | Description | Default |
| -------------------------- | ------------------ | --------------------------- |
Expand Down
Loading
Loading