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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ jobs:
- name: Check out code
uses: actions/checkout@v6
- name: Build
run: go build -mod=readonly ./...
run: make build
- name: Verify
run: go mod verify
- name: Test
run: env "GORACE=halt_on_error=1" go test -v -race -count 10 ./...
run: make test-race
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
- name: Output coverage
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Fuzz

permissions:
contents: read

on:
schedule:
- cron: '0 6 * * *' # daily, 06:00 UTC
workflow_dispatch: # manual trigger from Actions tab

jobs:
fuzz:
name: Fuzz
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Install Go
uses: actions/setup-go@v6
with:
go-version: 1.25.x
- name: Fuzz
run: make fuzz FUZZTIME=5m
- name: Upload crash inputs
if: failure()
uses: actions/upload-artifact@v4
with:
name: fuzz-crashers
path: '**/testdata/fuzz/**'
if-no-files-found: ignore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.idea
/coverage.out
/coverage.html
59 changes: 59 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
.PHONY: all ci build test test-race lint fuzz bench fix cover help

# Default: the fast loop (build + test + lint). Use during active development.
all: build test lint

# Everything CI runs. Use before submitting a PR.
ci: build test-race lint

build:
go build -mod=readonly ./...

# Fast unit tests — includes property tests and fuzz seed corpora
test:
go test ./...

# What CI runs: race detector, 10 iterations, halt on first race
test-race:
env "GORACE=halt_on_error=1" go test -race -count 10 ./...

lint:
golangci-lint run

# Coverage HTML report (opens in browser on most systems; else see coverage.html)
cover:
go test -covermode=count -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "wrote coverage.html"

# Active fuzzing. One target at a time, FUZZTIME per target (default 30s).
# Example: make fuzz FUZZTIME=2m
FUZZTIME ?= 30s
FUZZ_TARGETS := FuzzRollingCounterOps FuzzRollingCounterJSON \
FuzzSortedDurationsPercentile FuzzRollingBucketAdvance FuzzTimedCheckJSON
fuzz:
@for t in $(FUZZ_TARGETS); do \
echo "=== fuzz $$t ($(FUZZTIME)) ==="; \
go test -fuzz="^$$t$$" -fuzztime=$(FUZZTIME) ./faststats/ || exit 1; \
done

bench:
go test -benchmem -run=^$$ -bench=. ./...

# Auto-format: gofmt + goimports on all source
fix:
gofmt -s -w .
@command -v goimports >/dev/null 2>&1 && goimports -w . || echo "goimports not installed, skipped"

help:
@echo "Targets:"
@echo " make fast dev loop: build + test + lint (~5s)"
@echo " make ci everything CI runs — use before submitting a PR (~1min)"
@echo " make build compile all packages"
@echo " make test unit tests (includes property tests, fuzz seeds)"
@echo " make test-race race detector, -count 10"
@echo " make lint golangci-lint run"
@echo " make fuzz active fuzzing, FUZZTIME per target (default 30s)"
@echo " make bench all benchmarks"
@echo " make cover generate coverage.html"
@echo " make fix gofmt + goimports"
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,14 @@ BenchmarkCiruits/iand_circuit/Default/passing/75-8 5000000 349 ns

# [Development](https://github.com/cep21/circuit/blob/master/Makefile)

Make sure your tests pass with `go test` and your lints pass with `golangci-lint run`.
```bash
make # fast dev loop: build + test + lint (~5s)
make ci # everything CI runs — use before submitting a PR (~1min)
make fuzz # active fuzzing (FUZZTIME per target, default 30s)
make help # full target list
```

`make ci` mirrors the GitHub Actions workflow: build, `go test -race -count 10`, and `golangci-lint run`. If it passes locally, CI should pass.

# [Example](https://github.com/cep21/circuit/blob/master/example/main.go)

Expand Down
Loading
Loading