Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: CI

on:
push:
branches: [main]
branches-ignore:
- "dependabot/**" # Skip dependabot branches (they create PRs)
pull_request:

concurrency:
Expand All @@ -21,18 +22,19 @@ jobs:

- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"
cache: true

- name: Lint
uses: golangci/golangci-lint-action@v7
with:
version: v2.1.6
version: v2.8.0

- name: Test
run: go test -race -coverprofile=coverage.txt -timeout=2m ./...

- name: Upload coverage to Codecov
if: github.ref == 'refs/heads/main'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release
on:
push:
tags:
- 'v*'
- "v*"
workflow_dispatch:
# Manual trigger for re-running failed releases (requires existing tag)

Expand All @@ -20,7 +20,7 @@ jobs:

- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"
cache: true

- name: Run GoReleaser
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# Test binary, built with `go test -c`
*.test

# GoReleaser output
dist/

# Output of the go coverage tool
*.out
coverage.out
Expand Down
24 changes: 14 additions & 10 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ before:
- go test ./...

builds:
# CLI binary (stacktower) - for end users
- id: stacktower
main: ./main.go
main: ./cmd/stacktower
binary: stacktower
env:
- CGO_ENABLED=0
Expand All @@ -25,12 +26,15 @@ builds:
- arm64
ldflags:
- -s -w
- -X main.version={{.Version}}
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -X github.com/matzehuels/stacktower/pkg/buildinfo.Version={{.Version}}
- -X github.com/matzehuels/stacktower/pkg/buildinfo.Commit={{.Commit}}
- -X github.com/matzehuels/stacktower/pkg/buildinfo.Date={{.Date}}

archives:
# CLI archive (for Homebrew, manual download)
- id: stacktower
builds:
- stacktower
formats:
- tar.gz
name_template: >-
Expand All @@ -50,7 +54,7 @@ archives:
- README.md

checksum:
name_template: 'checksums.txt'
name_template: "checksums.txt"

snapshot:
version_template: "{{ incpatch .Version }}-next"
Expand All @@ -60,11 +64,11 @@ changelog:
use: github
filters:
exclude:
- '^docs:'
- '^test:'
- '^chore:'
- '^ci:'
- 'README'
- "^docs:"
- "^test:"
- "^chore:"
- "^ci:"
- "README"
- Merge pull request
- Merge branch
groups:
Expand Down
134 changes: 99 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,53 @@
.PHONY: all build clean fmt lint test cover e2e e2e-test e2e-real e2e-parse blog blog-diagrams blog-showcase install-tools snapshot release help
.PHONY: all build clean fmt fmt-check lint test cover vuln e2e blog install-tools snapshot release help

# =============================================================================
# Variables
# =============================================================================

BINARY := stacktower
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -X github.com/matzehuels/stacktower/pkg/buildinfo.Version=$(VERSION) \
-X github.com/matzehuels/stacktower/pkg/buildinfo.Commit=$(COMMIT) \
-X github.com/matzehuels/stacktower/pkg/buildinfo.Date=$(DATE)

# =============================================================================
# Default Target
# =============================================================================

all: check build

# =============================================================================
# Build Targets
# =============================================================================

build:
@echo "Building CLI (bin/$(BINARY))..."
@go build -ldflags "$(LDFLAGS)" -o bin/$(BINARY) ./cmd/stacktower

install:
@echo "Installing CLI..."
@go install -ldflags "$(LDFLAGS)" ./cmd/stacktower

clean:
@rm -rf bin/ dist/ coverage.out output/ tmp/

# =============================================================================
# Quality Checks
# =============================================================================

check: fmt lint test vuln

fmt:
@gofmt -s -w .
@goimports -w -local stacktower .
@goimports -w -local github.com/matzehuels/stacktower .

fmt-check:
@echo "Checking formatting..."
@test -z "$$(gofmt -l .)" || (echo "Files not formatted:"; gofmt -l .; exit 1)
@test -z "$$(goimports -l -local github.com/matzehuels/stacktower .)" || (echo "Imports not formatted:"; goimports -l -local github.com/matzehuels/stacktower .; exit 1)
@echo "Formatting OK"

lint:
@golangci-lint run
Expand All @@ -20,23 +59,33 @@ cover:
@go test -race -coverprofile=coverage.out ./...
@go tool cover -func=coverage.out

build:
@go build -o bin/$(BINARY) .
vuln:
@govulncheck ./...

install:
@go install .
install-tools:
@go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
@go install golang.org/x/tools/cmd/goimports@latest
@go install golang.org/x/vuln/cmd/govulncheck@latest

# =============================================================================
# End-to-End Tests
# =============================================================================

e2e: build
@./scripts/test_e2e.sh all
@./scripts/test_cli_e2e.sh all

e2e-test: build
@./scripts/test_e2e.sh test
@./scripts/test_cli_e2e.sh test

e2e-real: build
@./scripts/test_e2e.sh real
@./scripts/test_cli_e2e.sh real

e2e-parse: build
@./scripts/test_e2e.sh parse
@./scripts/test_cli_e2e.sh parse

# =============================================================================
# Blog Assets
# =============================================================================

blog: blog-diagrams blog-showcase

Expand All @@ -46,37 +95,52 @@ blog-diagrams: build
blog-showcase: build
@./scripts/blog_showcase.sh

install-tools:
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@go install golang.org/x/tools/cmd/goimports@latest
@go install golang.org/x/vuln/cmd/govulncheck@latest

vuln:
@govulncheck ./...
# =============================================================================
# Release
# =============================================================================

snapshot:
@goreleaser release --snapshot --clean --skip=publish

release:
@goreleaser release --clean

clean:
@rm -rf bin/ dist/ coverage.out
# =============================================================================
# Help
# =============================================================================

help:
@echo "make - Run checks and build"
@echo "make check - Format, lint, test, vulncheck (same as CI)"
@echo "make fmt - Format code"
@echo "make lint - Run golangci-lint"
@echo "make test - Run tests"
@echo "make cover - Run tests with coverage"
@echo "make build - Build binary"
@echo "make e2e - Run all end-to-end tests"
@echo "make e2e-test - Render examples/test/*.json"
@echo "make e2e-real - Render examples/real/*.json"
@echo "make e2e-parse - Parse packages to examples/real/"
@echo "make blog - Generate all blogpost diagrams"
@echo "make blog-diagrams - Generate blogpost example diagrams"
@echo "make blog-showcase - Generate blogpost showcase diagrams"
@echo "make vuln - Check for vulnerabilities"
@echo "make clean - Remove build artifacts"
@echo "Stacktower Makefile"
@echo ""
@echo "BUILDING:"
@echo " make build - Build CLI binary (bin/stacktower)"
@echo " make install - Install CLI to GOPATH"
@echo ""
@echo "QUALITY:"
@echo " make check - Run all checks (fmt, lint, test, vuln)"
@echo " make fmt - Format code"
@echo " make fmt-check - Check formatting (CI-style, no writes)"
@echo " make lint - Run golangci-lint"
@echo " make test - Run tests"
@echo " make cover - Run tests with coverage"
@echo " make vuln - Check for vulnerabilities"
@echo ""
@echo "TESTING:"
@echo " make e2e - Run all CLI end-to-end tests"
@echo " make e2e-test - Run test examples"
@echo " make e2e-real - Run real package examples"
@echo " make e2e-parse - Run parse tests"
@echo ""
@echo "BLOG:"
@echo " make blog - Generate all blog assets"
@echo " make blog-diagrams - Generate blog diagrams"
@echo " make blog-showcase - Generate blog showcase"
@echo ""
@echo "RELEASE:"
@echo " make snapshot - Build release locally (no publish)"
@echo " make release - Build and publish release"
@echo ""
@echo "OTHER:"
@echo " make clean - Remove build artifacts"
@echo " make install-tools - Install development tools"
@echo " make help - Show this help"
Loading