11# gh-app-auth Makefile
22
3- .PHONY : help build test lint clean install dev-setup security-scan release deps vet gocyclo staticcheck ineffassign misspell test-coverage-check markdownlint yamllint actionlint cli-smoke-test package-deb package-rpm packages
3+ .PHONY : help build test lint clean install dev-setup security-scan release deps vet gocyclo staticcheck ineffassign misspell test-coverage-check markdownlint yamllint actionlint cli-smoke-test package-deb package-rpm packages test-e2e test-e2e-local
44
55# Default target
66help :
@@ -28,13 +28,15 @@ help:
2828 @echo " uninstall Uninstall extension from GitHub CLI"
2929 @echo " dev-setup Set up development environment (config only)"
3030 @echo " validate-tools Validate core tools are installed"
31- @echo " validate-lint-tools Validate linting tools can run "
31+ @echo " validate-lint-tools Validate linting tools are installed "
3232 @echo " security-scan Run security scans (gosec, govulncheck)"
3333 @echo " deps Download and verify dependencies"
3434 @echo " dev Quick development cycle (fmt + lint + test + build)"
3535 @echo " ci CI pipeline simulation (mirrors GitHub CI)"
3636 @echo " quality Full quality check (all linters + tests + security)"
3737 @echo " release Build release binaries for all platforms"
38+ @echo " test-e2e Run E2E tests (requires test infra + secrets)"
39+ @echo " test-e2e-local Run E2E tests with locally built binary"
3840 @echo " "
3941 @echo " Packaging targets:"
4042 @echo " package-deb Build DEB package for amd64"
4749 @echo " validate-packages Verify binary/package architectures match targets"
4850 @echo " "
4951 @echo " Presentation targets:"
52+ @echo " presentation-setup Install presentation tools (mermaid-cli, mermaid-filter)"
5053 @echo " presentation Build both HTML and PDF presentations"
5154 @echo " presentation-html Build interactive HTML presentation"
52- @echo " presentation-pdf Build PDF presentation"
55+ @echo " presentation-pdf Build PDF presentation (requires presentation-setup) "
5356 @echo " presentation-serve Serve presentation locally on :8000"
5457 @echo " presentation-clean Clean presentation build artifacts"
5558
@@ -62,16 +65,17 @@ COMMIT := $(shell git rev-parse --short HEAD)
6265BUILD_TIME := $(shell date -u +"% Y-% m-% dT% H:% M:% SZ")
6366LDFLAGS := -ldflags "-X main.Version=$(VERSION ) -X main.Commit=$(COMMIT ) -X main.BuildTime=$(BUILD_TIME ) "
6467
65- # Go tool commands
66- GOLANGCI_LINT := go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
67- GOIMPORTS := go run golang.org/x/tools/cmd/goimports@latest
68- STATICCHECK := go run honnef.co/go/tools/cmd/staticcheck@latest
69- GOCYCLO := go run github.com/fzipp/gocyclo/cmd/gocyclo@latest
70- INEFFASSIGN := go run github.com/gordonklaus/ineffassign@latest
71- MISSPELL := go run github.com/client9/misspell/cmd/misspell@latest
72- GOSEC := go run github.com/securego/gosec/v2/cmd/gosec@latest
73- GOVULNCHECK := go run golang.org/x/vuln/cmd/govulncheck@latest
74- ACTIONLINT := go run github.com/rhysd/actionlint/cmd/actionlint@latest
68+ # Tool paths
69+ GOPATH := $(shell go env GOPATH)
70+ GOLANGCI_LINT := $(GOPATH ) /bin/golangci-lint
71+ GOIMPORTS := $(GOPATH ) /bin/goimports
72+ STATICCHECK := $(GOPATH ) /bin/staticcheck
73+ GOCYCLO := $(GOPATH ) /bin/gocyclo
74+ INEFFASSIGN := $(GOPATH ) /bin/ineffassign
75+ MISSPELL := $(GOPATH ) /bin/misspell
76+ GOSEC := $(GOPATH ) /bin/gosec
77+ GOVULNCHECK := $(GOPATH ) /bin/govulncheck
78+ NFPM_CMD := $(GOPATH ) /bin/nfpm
7579
7680# Build the extension
7781build :
@@ -112,7 +116,7 @@ test-coverage-check:
112116 echo " ✅ Coverage $$ COVERAGE% meets threshold $( COVERAGE_THRESHOLD) %" ; \
113117 fi
114118
115- # Lint code with golangci-lint
119+ # Lint code with golangci-lint (comprehensive)
116120lint :
117121 @echo " Running golangci-lint..."
118122 $(GOLANGCI_LINT ) run
@@ -154,10 +158,11 @@ yamllint:
154158 @command -v yamllint > /dev/null 2>&1 || { echo " ⚠️ yamllint not found, skipping (install: pip install yamllint)" ; exit 0; }
155159 yamllint -d relaxed . || echo " ⚠️ YAML lint issues found"
156160
157- # Run actionlint on GitHub workflow files
161+ # Run actionlint on GitHub workflow files (requires actionlint binary)
158162actionlint :
159163 @echo " Running actionlint..."
160- @$(ACTIONLINT ) || echo " ⚠️ Action lint issues found"
164+ @command -v actionlint > /dev/null 2>&1 || { echo " ⚠️ actionlint not found, skipping (install: go install github.com/rhysd/actionlint/cmd/actionlint@latest)" ; exit 0; }
165+ actionlint || echo " ⚠️ Action lint issues found"
161166
162167# CLI smoke test - verify binary works
163168cli-smoke-test : build
@@ -173,8 +178,8 @@ lint-all: vet staticcheck gocyclo ineffassign misspell markdownlint yamllint act
173178# Format code
174179fmt :
175180 @echo " Formatting code..."
176- $(GOIMPORTS ) -w .
177181 gofmt -s -w .
182+ $(GOIMPORTS ) -w .
178183
179184# Clean build artifacts
180185clean :
@@ -193,25 +198,45 @@ uninstall:
193198 @echo " Uninstalling extension from GitHub CLI..."
194199 gh extension remove app-auth || true
195200
196- # Set up development environment (configuration only, no tool installation)
201+ # Set up development environment
197202dev-setup :
198203 @echo " Setting up development environment..."
199204 go mod download
205+ @echo " Installing linting tools..."
206+ go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
207+ go install golang.org/x/tools/cmd/goimports@latest
208+ go install github.com/securego/gosec/v2/cmd/gosec@latest
209+ go install honnef.co/go/tools/cmd/staticcheck@latest
210+ go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
211+ go install github.com/gordonklaus/ineffassign@latest
212+ go install github.com/client9/misspell/cmd/misspell@latest
213+ go install golang.org/x/vuln/cmd/govulncheck@latest
214+ go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest
200215 @echo " Setting up git commit template..."
201216 git config commit.template .gitmessage
202217 @echo " Development environment ready!"
203218 @echo " "
204219 @echo " 💡 Tip: Use 'git commit' (without -m) to use the conventional commit template"
205220 @echo " 📖 See CONTRIBUTING.md for conventional commit guidelines"
206221
222+ # Set up presentation tools (installs mermaid-cli and mermaid-filter globally)
223+ presentation-setup :
224+ @echo " Setting up presentation tools..."
225+ @command -v npm > /dev/null 2>&1 || { echo " npm is required. Install Node.js first" ; exit 1; }
226+ @echo " Installing Mermaid CLI..."
227+ npm install -g @mermaid-js/mermaid-cli
228+ @echo " Installing mermaid-filter for pandoc..."
229+ npm install -g mermaid-filter
230+ @echo " ✅ Presentation tools installed globally"
231+
207232# Run security scans
208233security-scan :
209234 @echo " Running security scans..."
210235 $(GOSEC ) -fmt sarif -out gosec.sarif ./... || true
211236 @echo " Running vulnerability check..."
212237 $(GOVULNCHECK ) ./... || true
213238
214- # Download and verify dependencies
239+ # Download and verify dependencies
215240deps :
216241 @echo " Downloading dependencies..."
217242 go mod download
@@ -265,18 +290,18 @@ validate-tools:
265290 @command -v git > /dev/null 2>&1 || { echo " ❌ Git is required but not installed" ; exit 1; }
266291 @echo " ✅ Core tools are installed."
267292
268- # Validate that linting tools can be executed
293+ # Validate that linting tools are installed
269294validate-lint-tools :
270- @echo " Validating linting tools can be executed ..."
271- @$(GOLANGCI_LINT ) version > /dev/null 2>&1 || { echo " ❌ golangci-lint failed " ; exit 1; }
272- @$(GOIMPORTS ) -l . > /dev/null 2>&1 || { echo " ❌ goimports failed " ; exit 1; }
273- @$(STATICCHECK ) --help > /dev/null 2>&1 || { echo " ❌ staticcheck failed " ; exit 1; }
274- @$(GOCYCLO ) . > /dev/null 2>&1 || { echo " ❌ gocyclo failed " ; exit 1; }
275- @$(INEFFASSIGN ) . > /dev/null 2>&1 || { echo " ❌ ineffassign failed " ; exit 1; }
276- @$(MISSPELL ) --help > /dev/null 2>&1 || { echo " ❌ misspell failed " ; exit 1; }
277- @$(GOSEC ) --help > /dev/null 2>&1 || { echo " ❌ gosec failed " ; exit 1; }
278- @$(GOVULNCHECK ) --help > /dev/null 2>&1 || { echo " ❌ govulncheck failed " ; exit 1; }
279- @echo " ✅ All linting tools work "
295+ @echo " Validating linting tools are installed ..."
296+ @test -f $(GOLANGCI_LINT ) || { echo " ❌ golangci-lint not installed. Run 'make dev-setup' " ; exit 1; }
297+ @test -f $(GOIMPORTS ) || { echo " ❌ goimports not installed. Run 'make dev-setup' " ; exit 1; }
298+ @test -f $(STATICCHECK ) || { echo " ❌ staticcheck not installed. Run 'make dev-setup' " ; exit 1; }
299+ @test -f $(GOCYCLO ) || { echo " ❌ gocyclo not installed. Run 'make dev-setup' " ; exit 1; }
300+ @test -f $(INEFFASSIGN ) || { echo " ❌ ineffassign not installed. Run 'make dev-setup' " ; exit 1; }
301+ @test -f $(MISSPELL ) || { echo " ❌ misspell not installed. Run 'make dev-setup' " ; exit 1; }
302+ @test -f $(GOSEC ) || { echo " ❌ gosec not installed. Run 'make dev-setup' " ; exit 1; }
303+ @test -f $(GOVULNCHECK ) || { echo " ❌ govulncheck not installed. Run 'make dev-setup' " ; exit 1; }
304+ @echo " ✅ All linting tools are installed "
280305
281306# Quick development cycle
282307dev : fmt lint test build
@@ -333,6 +358,28 @@ ci: deps validate-tools validate-lint-tools
333358quality : validate-lint-tools fmt lint-all test-coverage-check security-scan
334359 @echo " Quality check complete!"
335360
361+ # Run E2E tests using a pre-built or user-supplied binary.
362+ # Requires test infrastructure (see docs/E2E_INFRASTRUCTURE.md) and secrets:
363+ # export E2E_APP_ID=<app-id>
364+ # export E2E_PRIVATE_KEY_B64=$(base64 -w 0 </path/to/key.pem>)
365+ # export E2E_GITHUB_TOKEN=<github-token-with-repo-scope>
366+ # Optional: export E2E_BINARY_PATH=<path/to/binary> (builds from source if unset)
367+ .PHONY : test-e2e
368+ test-e2e :
369+ @echo " Running E2E tests (requires test infrastructure)..."
370+ go test -v -tags=e2e -timeout=15m ./test/e2e/...
371+
372+ # Run E2E tests using a locally built binary (no prerelease needed).
373+ # Builds the binary from source automatically.
374+ .PHONY : test-e2e-local
375+ test-e2e-local :
376+ @echo " Building binary for E2E tests..."
377+ go build -o /tmp/gh-app-auth-e2e-local .
378+ @echo " Running E2E tests with local binary..."
379+ E2E_BINARY_PATH=/tmp/gh-app-auth-e2e-local \
380+ go test -v -tags=e2e -timeout=15m ./test/e2e/...
381+ rm -f /tmp/gh-app-auth-e2e-local
382+
336383# Packaging targets
337384.PHONY : package-deb package-deb-arm64 package-deb-arm package-rpm package-rpm-arm64 package-rpm-arm packages packages-local validate-packages
338385
477524endif
478525
479526# Presentation targets
480- .PHONY : presentation presentation-html presentation-pdf presentation-serve presentation-clean
527+ .PHONY : presentation presentation-setup presentation- html presentation-pdf presentation-serve presentation-clean
481528
482529# Build presentation HTML
483530presentation-html :
@@ -509,10 +556,9 @@ presentation-pdf:
509556 @echo " Building presentation PDF..."
510557 @command -v pandoc > /dev/null 2>&1 || { echo " Pandoc is required. Install: apt install pandoc" ; exit 1; }
511558 @command -v xelatex > /dev/null 2>&1 || { echo " XeLaTeX is required. Install: apt install texlive-xetex" ; exit 1; }
512- @echo " Ensuring mermaid-filter is available..."
513- @command -v mermaid-filter > /dev/null 2>&1 || { echo " Installing mermaid-filter..." && npm install -g mermaid-filter; }
514- @mkdir -p dist/presentation
515- export PATH=" $$ (npm config get prefix)/bin:$$ PATH" ; \
559+ @command -v mmdc > /dev/null 2>&1 || { echo " Mermaid CLI is required. Run: make presentation-setup" ; exit 1; }
560+ @npm list -g mermaid-filter > /dev/null 2>&1 || { echo " mermaid-filter is required. Run: make presentation-setup" ; exit 1; }
561+ mkdir -p dist/presentation
516562 pandoc docs/presentation.md \
517563 -o dist/presentation/presentation.pdf \
518564 --pdf-engine=xelatex \
0 commit comments