@@ -34,10 +34,10 @@ REFLEX=$(GOPATH)/bin/reflex
3434$(REFLEX ) :
3535 go install github.com/cespare/reflex@latest
3636
37- GOLANGCILINTVERSION: =1.64.8
37+ GOLANGCILINTVERSION: =2.12.2
3838GOLANGCILINT =$(GOPATH ) /bin/golangci-lint
3939$(GOLANGCILINT ) :
40- curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/master /install.sh | sh -s -- -b $(GOPATH ) /bin v$(GOLANGCILINTVERSION )
40+ curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/v $( GOLANGCILINTVERSION ) /install.sh | sh -s -- -b $(GOPATH ) /bin v$(GOLANGCILINTVERSION )
4141
4242VENOMVERSION: =v1.0.0-rc.6
4343VENOM =$(GOPATH ) /bin/venom
@@ -48,22 +48,29 @@ GOCOVMERGE=$(GOPATH)/bin/gocovmerge
4848$(GOCOVMERGE ) :
4949 go install github.com/wadey/gocovmerge@latest
5050
51+ CADDYVERSION: =v2.8.4
5152CADDY =$(GOPATH ) /bin/caddy
5253$(CADDY ) :
53- cd /tmp; go get github.com/caddyserver/caddy/v2/...
54+ go install github.com/caddyserver/caddy/v2/cmd/caddy@$(CADDYVERSION )
55+
56+ # All generated/runtime artifacts live under build/ so the repository root stays clean.
57+ BUILD_DIR =build
58+ SESSIONS_DIR =$(BUILD_DIR ) /sessions
59+ COVERAGE_DIR =$(BUILD_DIR ) /coverage
5460
5561.PHONY : persistence
5662persistence :
57- rm -rf ./sessions || true
58- cp -r tests/sessions sessions
63+ rm -rf ./$(SESSIONS_DIR ) || true
64+ mkdir -p $(BUILD_DIR )
65+ cp -r tests/sessions $(SESSIONS_DIR )
5966
6067.PHONY : start
6168start : $(REFLEX ) persistence
6269 $(REFLEX ) --start-service \
6370 --decoration=' none' \
6471 --regex=' \.go$$' \
6572 --inverse-regex=' ^vendor|node_modules|.cache/' \
66- -- go run $(GO_LDFLAGS ) main.go --log-level=$(LEVEL ) --static-files ./build/client --persistence-directory ./sessions
73+ -- go run $(GO_LDFLAGS ) main.go --log-level=$(LEVEL ) --static-files ./build/client --persistence-directory ./$( SESSIONS_DIR )
6774
6875.PHONY : build
6976build :
@@ -79,15 +86,15 @@ format:
7986
8087.PHONY : test
8188test :
82- mkdir -p coverage
83- go test -v -race -coverprofile=coverage /test-cover.out ./server/...
89+ mkdir -p $( COVERAGE_DIR )
90+ go test -v -race -coverprofile=$( COVERAGE_DIR ) /test-cover.out ./server/...
8491
8592PID_FILE =/tmp/$(APPNAME ) .test.pid
8693.PHONY : test-integration
8794test-integration : $(VENOM ) check-default-ports persistence
88- mkdir -p coverage
89- go test -race -coverpkg=" ./..." -c . -o $(APPNAME ) .test
90- SMOCKER_PERSISTENCE_DIRECTORY=./sessions . /$(APPNAME ) .test -test.coverprofile=coverage /test-integration-cover.out > /dev/null 2>&1 & echo $$ ! > $(PID_FILE )
95+ mkdir -p $( COVERAGE_DIR )
96+ go test -race -coverpkg=" ./..." -c . -o $(BUILD_DIR ) / $( APPNAME ) .test
97+ SMOCKER_PERSISTENCE_DIRECTORY=./$( SESSIONS_DIR ) $( BUILD_DIR ) /$(APPNAME ) .test -test.coverprofile=$( COVERAGE_DIR ) /test-integration-cover.out > /dev/null 2>&1 & echo $$ ! > $(PID_FILE )
9198 sleep 5
9299 $(VENOM ) run tests/features/$(SUITE )
93100 kill ` cat $( PID_FILE) ` 2> /dev/null || true
@@ -96,19 +103,36 @@ test-integration: $(VENOM) check-default-ports persistence
96103start-integration : $(VENOM )
97104 $(VENOM ) run tests/features/$(SUITE )
98105
99- coverage/test-cover.out :
106+ # End-to-end UI non-regression tests (Playwright). Builds the client and backend, serves the
107+ # built client through smocker (seeded with tests/sessions), runs the suite, then stops the
108+ # server. Requires the Playwright browser to be installed (npx playwright install chromium).
109+ E2E_MOCK_PORT ?= 8080
110+ E2E_ADMIN_PORT ?= 8081
111+ .PHONY : test-e2e
112+ test-e2e : build persistence
113+ npm run build
114+ SMOCKER_PERSISTENCE_DIRECTORY=./$(SESSIONS_DIR ) ./$(BUILD_DIR ) /$(APPNAME ) \
115+ --static-files ./$(BUILD_DIR ) /client \
116+ --mock-server-listen-port=$(E2E_MOCK_PORT ) --config-listen-port=$(E2E_ADMIN_PORT ) \
117+ > $(BUILD_DIR ) /e2e-smocker.log 2>&1 & \
118+ SMK_PID=$$ ! ; \
119+ for i in $$ (seq 1 30); do curl -sf localhost:$( E2E_ADMIN_PORT) /version > /dev/null 2>&1 && break ; sleep 0.3; done ; \
120+ SMOCKER_E2E_URL=http://localhost:$(E2E_ADMIN_PORT ) npx playwright test --config tests/e2e/playwright.config.ts; \
121+ RC=$$? ; kill $$ SMK_PID 2> /dev/null || true ; exit $$ RC
122+
123+ $(COVERAGE_DIR ) /test-cover.out :
100124 $(MAKE ) test
101125
102- coverage /test-integration-cover.out :
126+ $( COVERAGE_DIR ) /test-integration-cover.out :
103127 $(MAKE ) test-integration
104128
105129.PHONY : coverage
106- coverage : $(GOCOVMERGE ) coverage /test-cover.out coverage /test-integration-cover.out
107- $(GOCOVMERGE ) coverage /test-cover.out coverage /test-integration-cover.out > coverage /cover.out
130+ coverage : $(GOCOVMERGE ) $( COVERAGE_DIR ) /test-cover.out $( COVERAGE_DIR ) /test-integration-cover.out
131+ $(GOCOVMERGE ) $( COVERAGE_DIR ) /test-cover.out $( COVERAGE_DIR ) /test-integration-cover.out > $( COVERAGE_DIR ) /cover.out
108132
109133.PHONY : clean
110134clean :
111- rm -rf ./build ./coverage
135+ rm -rf ./$( BUILD_DIR )
112136
113137.PHONY : build-docker
114138build-docker :
@@ -133,9 +157,10 @@ optimize:
133157
134158build/smocker.tar.gz :
135159 $(MAKE ) build
136- yarn install --frozen-lockfile --ignore-scripts
137- yarn build
138- cd build/; tar -czvf smocker.tar.gz *
160+ npm ci --ignore-scripts
161+ npm run build
162+ # Package only the release artifacts, not test/runtime output that may also live in build/.
163+ cd build/; tar -czvf smocker.tar.gz smocker client
139164
140165.PHONY : release
141166release : build/smocker.tar.gz
0 commit comments