Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (100 loc) · 3.95 KB
/
Copy pathMakefile
File metadata and controls
129 lines (100 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
GOBIN = $(GOPATH)/bin
help:
@echo "Please use 'make <target>' where <target> is one of the following:"
@echo " docker-run to run the app with Docker (docker-compose)."
@echo " run to run the app without Docker (go run)."
@echo " build to build the app without Docker (go build)."
@echo " pre-commit to run essential checks before you would make a commit."
@echo " dev-dependencies to install all required Go dev dependencies"
@echo " gomod to run tidy you go.mod file and load vendor files."
@echo " update-mocks to update mocks."
@echo " gci to apply gci."
@echo " lint to perform linting."
@echo " test run all Go unit tests."
@echo " test-unit run JS unit + integration tests (Vitest + MSW)."
@echo " test-ui run UI tests with Playwright."
@echo " test-ui-headed run UI tests in headed mode (visible browser)."
@echo " test-ui-setup install Playwright and dependencies."
@echo " coverage-report open coverage report generated by make test."
dev-dependencies: | $(GOBIN)/mockgen $(GOBIN)/gci $(GOBIN)/golangci-lint
.PHONY: run-dev
run-dev:
HTTP_PORT=3000 DB_PATH=data/agg.db nodemon --watch './**/*.go' --signal SIGTERM --exec 'go' run cmd/main.go
.PHONY: run
run:
CGO_ENABLED=0 GOOS=linux go run -mod=vendor ./cmd/main.go
.PHONY: docker-run
docker-run:
docker-compose -f docker-compose.yaml build
docker-compose -f docker-compose.yaml up
.PHONY: build
build:
CGO_ENABLED=0 GOOS=linux go build -mod=vendor -a -installsuffix cgo -o lite-reader ./cmd/main.go
pre-commit: gomod update-mocks lint test test-unit
.PHONY: gomod
gomod:
@go mod tidy
@go mod vendor
$(GOBIN)/mockgen:
@go install go.uber.org/mock/mockgen@latest
@$(MAKE) gomod
update-mocks: | $(GOBIN)/mockgen
@find ./internal/mocks ! -name 'definition.go' -type f -exec rm {} +
GO111MODULE=on go generate -mod=vendor -tags=mocks ./...
@$(MAKE) gci
.PHONY: test
test:
@mkdir -p reports
@go test -coverprofile=reports/codecoverage_all.cov ./... -mod=vendor -cover -race -p=4
@go tool cover -func=reports/codecoverage_all.cov > reports/functioncoverage.out
@go tool cover -html=reports/codecoverage_all.cov -o reports/coverage.html
@echo "View report at $(PWD)/reports/coverage.html"
@tail -n 1 reports/functioncoverage.out
.PHONY: coverage-report
coverage-report:
@open reports/coverage.html
$(GOBIN)/gci:
@go install github.com/daixiang0/gci@v0.3.3
@$(MAKE) gomod
gci: | $(GOBIN)/gci
@gci write --Section Standard --Section Default --Section "Prefix(github.com/cubny/lite-reader)" $(shell ls -d $(PWD)/*/ | grep -v vendor)
$(GOBIN)/golangci-lint:
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v2.12.2
.PHONY: lint
lint: | $(GOBIN)/golangci-lint
golangci-lint run -v
.PHONY: ci-run
ci-run:
docker-compose build
docker-compose up
.PHONY: docs
docs:
docker run -v $(CURDIR):/local -w /local quay.io/goswagger/swagger generate spec -o ./docs/swagger.json
docker run -v $(CURDIR):/local -w /local quay.io/goswagger/swagger generate spec -o ./docs/swagger.yaml
# UI Testing targets
.PHONY: test-ui-setup
test-ui-setup:
@echo "Installing Playwright and dependencies..."
@npm install
@npm run playwright:install
.PHONY: run-test-server
run-test-server:
@echo "Starting test server with mock feeds..."
@HTTP_PORT=3000 DB_PATH=data/test-agg.db CGO_ENABLED=0 go run -mod=vendor ./cmd/testserver/main.go
.PHONY: test-ui
test-ui:
@echo "Running UI tests..."
@mkdir -p reports/playwright
@TEST_DB_PATH=data/test-agg.db npm run test:ui
.PHONY: test-ui-headed
test-ui-headed:
@echo "Running UI tests in headed mode..."
@mkdir -p reports/playwright
@TEST_DB_PATH=data/test-agg.db npm run test:ui:headed
.PHONY: test-unit
test-unit:
@echo "Running JS unit + integration tests..."
@npm run test:unit
.PHONY: test-all
test-all: test test-unit test-ui
@echo "All tests completed!"