Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
39b5446
Migrate CLI framework from urfave/cli to cobra and viper
claude Nov 17, 2025
e7b10d7
Fix staticcheck S1011: use idiomatic slice append for aliases
claude Nov 17, 2025
3aa069a
Fix Bats integration tests: improve flag parsing and error handling
claude Nov 17, 2025
dada412
Fix single-dash flag handling for -version and -help
claude Nov 17, 2025
853661c
Fix single-dash flag handling for -version and -help
claude Nov 18, 2025
6e1e7c9
fix: Remove unused variable
ocean Nov 19, 2025
1e100b5
fix: Fix top level .ahoy.yml file
ocean Nov 19, 2025
230d382
Migrate CLI framework from urfave/cli to cobra and viper
ocean Nov 20, 2025
ddc8371
Move v3 code to root, restore v2 code in subdirectory for support
ocean Nov 27, 2025
4964c6d
ci: Fix broken test, make sure tests are run on both versions still
ocean Nov 30, 2025
c9cd2a0
ci: Ignore all vendor files in format checking
ocean Nov 30, 2025
6893105
tests: Fix "no ahoy file" test in v2 (was finding parent dir ahoy file)
ocean Dec 1, 2025
91e2304
Merge pull request #12 from ocean/potential-v3
ocean Dec 1, 2025
10fbee8
Update DrevOps logo in README
ocean Dec 18, 2025
5673b27
fix: Remove unneeded nil check
ocean Feb 18, 2026
9e97700
docs: Update Readme
ocean Feb 18, 2026
b2e8914
feat: Improve top-level help output for two-tier help display
ocean Feb 18, 2026
459b575
feat: Add per-command help template with DESCRIPTION section
ocean Feb 18, 2026
eb1fc98
tests: Update BATS tests for two-tier help formatting
ocean Feb 18, 2026
3d71a35
tests: Add help interception tests from CodeRabbit review feedback
ocean Feb 18, 2026
8b6e6ec
feat: Add expandPath() for unified path handling
ocean Feb 19, 2026
e73ace7
feat: Add config validation engine
ocean Feb 19, 2026
f0efa4d
feat: Refactor init command to use native HTTP client
ocean Feb 19, 2026
643bcc3
feat: Add 'ahoy config' command group with validate and init subcommands
ocean Feb 19, 2026
d0f53df
feat: Add hidden --simulate-version flag for validation testing
ocean Feb 19, 2026
b315225
feat: Improve missing import error messages with diagnostic context
ocean Feb 19, 2026
8bb2ed3
tests: Add unit tests for config validation, init, and expandPath
ocean Feb 19, 2026
480438b
tests: Add BATS integration tests for 'ahoy config' command group
ocean Feb 19, 2026
dd314ab
fix: Fix the file path usage in the tests
ocean Feb 22, 2026
abc74f0
fix: Fix critical nil-pointer panics, dead code, and unsafe file write
ocean Feb 24, 2026
913c83c
refactor: Remove Viper dependency, add AHOY_FILE and AHOY_VERBOSE env…
ocean Feb 24, 2026
0369562
fix: Remove dead versionFlagSet/helpFlagSet checks from BeforeCommand
ocean Feb 24, 2026
d4b1000
fix: Fix silent error swallowing and wrong exit code on invalid flag
ocean Feb 24, 2026
5053ef0
fix: Propagate YAML parse error detail through ConfigReport
ocean Feb 24, 2026
8ffac3e
fix: Correct ValidationIssue.Type comment to match assigned values
ocean Feb 24, 2026
efbe7eb
fix: Validate URL scheme in downloadFile, replace live network test
ocean Feb 24, 2026
2785a28
tests: Add direct ValidateConfig unit tests for all four validation b…
ocean Feb 24, 2026
6b51f13
tests: Add BATS test asserting exit code 1 for error-severity validation
ocean Feb 24, 2026
6980f24
chore: Remove commented-out debug lines
ocean Feb 24, 2026
a01198d
fix: Make comments more accurate
ocean Feb 24, 2026
d50895b
tests: Add BATS regression tests for stderr-capture deadlock
ocean May 8, 2026
0aff8e1
fix: Document and refactor legacy single-dash flag pre-parser
ocean May 8, 2026
1cd2487
fix: Validate URL scheme and use atomic write in downloadFile
ocean May 8, 2026
0834fd8
fix: Update ValidationIssue.Type comment to match implementation
ocean May 8, 2026
659f130
fix: Replace stderr buffering with goroutine drain to prevent deadlock
ocean May 8, 2026
f749468
fix: Remove no-op SetFlagErrorFunc and improve SilenceErrors comment
ocean May 8, 2026
979fd51
fix: Wire debug logger output to --verbose flag
ocean May 8, 2026
798dd5d
fix: Send deprecated ahoy init notice to stderr
ocean May 8, 2026
4c8ea75
fix: Remove redundant absolute path check in expandPath
ocean May 8, 2026
ee8765c
style: Use standard hyphens in inline comments
ocean May 8, 2026
505c200
fix: Restore Unix-style absolute path check in expandPath
ocean May 9, 2026
b2e44c2
ci: Add Homebrew coreutils to macOS runners so timeout command works …
ocean May 9, 2026
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
114 changes: 114 additions & 0 deletions .ahoy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
ahoyapi: v2
commands:
build:
usage: Build ahoy with version information using Goreleaser.
description: |
Compiles the ahoy binary using Goreleaser with version
information automatically embedded.

This creates a snapshot build with proper version flags and
optimisation.
The binary will be created in the dist directory.
cmd: goreleaser build --config ../.goreleaser.yml --snapshot --clean --single-target

build-all:
usage: Build all supported architectures and OSes using Goreleaser.
description: |
Builds ahoy for all supported platforms (linux, darwin, windows) and
architectures (amd64, arm64, arm) using Goreleaser configuration.
Creates optimised binaries for distribution with proper naming and
packaging.
cmd: goreleaser build --config ../.goreleaser.yml --snapshot --clean

install:
usage: Install ahoy locally using go install.
description: |
Installs ahoy directly to your GOPATH/bin using go install.
This is useful for development but doesn't include version information
that Goreleaser builds provide.
cmd: "go install"

bats:
usage: "Run the BATS bash testing command."
description: |
Executes the BATS (Bash Automated Testing System) test suite.
This runs integration tests that verify ahoy's command-line behavior
and functionality across different scenarios.
cmd: |
bats tests

test:
usage: Run automated tests.
description: |
Executes the complete test suite for ahoy including:
- Go vet for code quality checks
- Go unit tests with race detection
- BATS integration tests for command-line behavior
Stops on first failure and reports overall results.
cmd: |
set -euo pipefail
TESTS=(
'go vet'
'go test -v -race'
'bats tests'
)
for cmd in "${TESTS[@]}"; do
printf "\n=== TEST: %s ===\n\n" "$cmd"
eval "$cmd"
done
echo "All tests passed."

gomod:
usage: Manage Go module dependencies.
description: |
Performs complete Go module maintenance:
- Tidies the go.mod file by removing unused dependencies
- Downloads and vendors all dependencies
- Verifies downloaded modules against checksums
cmd: |
go mod tidy
go mod vendor
go mod verify

gofmt:
usage: Format Go code according to standards.
description: |
Automatically formats all Go source files in the current directory
according to Go's standard formatting rules.
This ensures consistent code style across the project.
cmd: gofmt -w .

release:
usage: Create a release using Goreleaser.
description: |
Creates a full release using Goreleaser including:
- Building for all platforms and architectures
- Generating checksums and SBOMs
- Creating archives and signing artifacts
Requires proper git tags and GPG setup for signing.
cmd: goreleaser release --config ../.goreleaser.yml --clean

echo:
usage: Display a message
description: |
This is a simple command that echoes any arguments passed to it.
Useful for testing and basic output.
cmd: echo "$@"

list:
usage: List directory contents
description: |
Lists all files and directories in the specified location.

Shows hidden files (starting with .) and supports all standard
ls options.

If no directory is specified, lists the current directory.
cmd: ls -a "$@"

whalesay:
usage: Make a whale say something
description: |
Uses Docker to run the whalesay container with a dragon figure to
display your message in ASCII art.
cmd: docker run --rm docker/whalesay cowsay -f dragon "$@"
24 changes: 15 additions & 9 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
version: [v3, v2]
include:
- version: v3
directory: .
- version: v2
directory: ./v2
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./v2
working-directory: ${{ matrix.directory }}

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -42,13 +48,13 @@ jobs:
# Create proper directory structure that BATS expects
New-Item -ItemType Directory -Force -Path "C:\bats\bin"
New-Item -ItemType Directory -Force -Path "C:\bats\libexec\bats-core"

# Copy the main bats script
Copy-Item "bin\bats" "C:\bats\bin\bats"

# Copy the core BATS files that are expected
Copy-Item "libexec\bats-core\*" "C:\bats\libexec\bats-core\" -Recurse -Force

# Add to PATH
echo "C:\bats\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
cd ..
Expand All @@ -71,9 +77,9 @@ jobs:
sudo apt-get update
sudo apt-get install -y php

- name: Install PHP (macOS)
- name: Install PHP and coreutils (macOS)
if: runner.os == 'macOS'
run: brew install php
run: brew install php coreutils

- name: Install PHP (Windows)
if: runner.os == 'Windows'
Expand Down Expand Up @@ -118,7 +124,7 @@ jobs:
# Test that the binary works (issue #147 fix validation)
.\ahoy.exe --version
.\ahoy.exe --help

# Test with a simple config file
.\ahoy.exe -f testdata\simple.ahoy.yml echo "Windows functional test passed"
shell: pwsh
Expand All @@ -142,14 +148,14 @@ jobs:
uses: actions/upload-artifact@v4
if: always() && runner.os != 'Windows'
with:
name: test-results-${{ matrix.os }}
name: test-results-${{ matrix.os }}-${{ matrix.version }}
path: /tmp/test-reports/
retention-days: 30

- name: Upload test results (Windows)
uses: actions/upload-artifact@v4
if: always() && runner.os == 'Windows'
with:
name: test-results-${{ matrix.os }}
name: test-results-${{ matrix.os }}-${{ matrix.version }}
path: C:\tmp\test-reports\
retention-days: 30
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Dockerfile for security testing.

FROM scratch
ENTRYPOINT ["/ahoy"]
COPY ahoy /
65 changes: 65 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
GITCOMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
VERSION := $(shell git describe --tags --abbrev=0 $(GITCOMMIT) 2>/dev/null)

GITBRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
BUILDTIME := $(shell TZ=UTC date "+%Y-%m-%dT%H:%M:%SZ")
LDFLAGS := "-s -w -X main.version=$(VERSION) -X main.GitCommit=$(GITCOMMIT) -X main.GitBranch=$(GITBRANCH) -X main.BuildTime=$(BUILDTIME)"

# Set binary name based on OS
ifeq ($(OS),Windows_NT)
BINARY_NAME := ahoy.exe
else
BINARY_NAME := ahoy
endif

SRCS = $(shell find . -name '*.go' | grep -v '/vendor/')

OS := linux darwin windows
ARCH := amd64 arm64

TESTARGS ?=

default:
go build -ldflags $(LDFLAGS) -v -o ./$(BINARY_NAME)

install:
cp ahoy /usr/local/bin/ahoy
chmod +x /usr/local/bin/ahoy

build_dir:
mkdir -p ./builds

cross: build_dir
$(foreach os,$(OS), \
$(foreach arch,$(ARCH), \
$(if $(filter windows,$(os)), \
GOOS=$(os) GOARCH=$(arch) go build -trimpath -ldflags $(LDFLAGS) -v -o ./builds/ahoy-bin-$(os)-$(arch).exe, \
GOOS=$(os) GOARCH=$(arch) go build -trimpath -ldflags $(LDFLAGS) -v -o ./builds/ahoy-bin-$(os)-$(arch) \
); \
) \
)

clean:
rm -vRf ./builds/ahoy-bin-*

fmtcheck:
$(foreach file,$(SRCS),gofmt $(file) | diff -u $(file) - || exit;)

staticcheck:
@ go install honnef.co/go/tools/cmd/staticcheck@latest
staticcheck ./...

vet:
go vet ./...

gocyclo:
@ go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
gocyclo -over 25 -avg -ignore "vendor" .

test: fmtcheck staticcheck vet
go test ./*.go $(TESTARGS)

version:
@echo $(VERSION)

.PHONY: clean test fmtcheck staticcheck vet gocyclo version testdeps cross build_dir default install
Loading
Loading