Skip to content

Commit 6863de7

Browse files
authored
ci: process hardening — 18 CI workflows, E2E expansion, local guardra… (#1028)
…ils, docs overhaul - Harden js.yml: add tsc --noEmit, prettier --check, next build - Harden go.yml: add go test -race, atlas migrate validate - New security.yml: npm audit + govulncheck (informational) - New docker.yml: Dockerfile build validation - Add develop branch trigger to all 10 check workflows - Add post-deploy smoke test to deploy-prod.yml and deploy-staging.yml - New E2E: discover.cy.ts, smoke.cy.ts, i18n.cy.ts - New Makefile target: make pre-push (6-step local check suite) - New .githooks/pre-push: opt-in git hook - New CONTRIBUTING.md: GitFlow-lite workflow documentation - Consolidate CHANGELOG.md to v0.8.0 with post-mortem - Update README.md: CI badges, Contributing section, make pre-push --------- Co-authored-by: zxxma <zxxma@users.noreply.github.com>
1 parent 0558c75 commit 6863de7

31 files changed

+714
-194
lines changed

.githooks/pre-push

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
#
3+
# Pre-push hook for Zenao
4+
# Runs all local checks before allowing a push to remote.
5+
#
6+
# To enable: git config core.hooksPath .githooks
7+
# To bypass (emergencies only): git push --no-verify
8+
#
9+
10+
echo "🔍 Running pre-push checks..."
11+
echo ""
12+
13+
# Run the full pre-push check suite
14+
make pre-push
15+
16+
if [ $? -ne 0 ]; then
17+
echo ""
18+
echo "❌ Pre-push checks FAILED. Push aborted."
19+
echo " Fix the issues above and try again."
20+
echo " To bypass (emergencies only): git push --no-verify"
21+
exit 1
22+
fi
23+
24+
echo ""
25+
echo "✅ All checks passed. Pushing..."

.github/workflows/buf-gen.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- develop
78
pull_request:
89
merge_group:
910

.github/workflows/buf-lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- develop
78
pull_request:
89
merge_group:
910

.github/workflows/deploy-prod.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,20 @@ jobs:
100100
101101
docker compose -f prod.backend.docker-compose.yml up -d --wait otel-collector jaeger
102102
git restore prod.backend.docker-compose.yml
103-
docker compose -f prod.backend.docker-compose.yml up -d --build backend
103+
docker compose -f prod.backend.docker-compose.yml up -d --build backend
104+
105+
- name: Post-deploy smoke test
106+
run: |
107+
echo "⏳ Waiting 60s for services to stabilize..."
108+
sleep 60
109+
for i in 1 2 3 4 5; do
110+
STATUS=$(curl -s -o /dev/null -w "%{http_code}" --max-time 15 https://zenao.io/)
111+
if [ "$STATUS" = "200" ]; then
112+
echo "✅ Smoke test passed (HTTP $STATUS)"
113+
exit 0
114+
fi
115+
echo "⏳ Attempt $i/5: HTTP $STATUS — retrying in 30s..."
116+
sleep 30
117+
done
118+
echo "❌ Smoke test FAILED after 5 attempts"
119+
exit 1

.github/workflows/deploy-staging.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,20 @@ jobs:
100100
101101
docker compose -f staging.docker-compose.yml up -d --wait otel-collector jaeger
102102
git restore staging.docker-compose.yml
103-
docker compose -f staging.docker-compose.yml up -d --build backend
103+
docker compose -f staging.docker-compose.yml up -d --build backend
104+
105+
- name: Post-deploy smoke test
106+
run: |
107+
echo "⏳ Waiting 60s for services to stabilize..."
108+
sleep 60
109+
for i in 1 2 3 4 5; do
110+
STATUS=$(curl -s -o /dev/null -w "%{http_code}" --max-time 15 https://staging.zenao.io/)
111+
if [ "$STATUS" = "200" ]; then
112+
echo "✅ Smoke test passed (HTTP $STATUS)"
113+
exit 0
114+
fi
115+
echo "⏳ Attempt $i/5: HTTP $STATUS — retrying in 30s..."
116+
sleep 30
117+
done
118+
echo "❌ Smoke test FAILED after 5 attempts"
119+
exit 1

.github/workflows/docker.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Docker Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
pull_request:
9+
merge_group:
10+
11+
jobs:
12+
docker:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Build Docker image
20+
run: docker build --target builder -t zenao-backend-test .

.github/workflows/e2e.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- develop
78
pull_request:
89
merge_group:
910

.github/workflows/go-fmt.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- develop
78
pull_request:
89
merge_group:
910

.github/workflows/go.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- develop
78
pull_request:
89
merge_group:
910

@@ -22,11 +23,29 @@ jobs:
2223
- name: Tidy go.mod
2324
run: go mod tidy
2425

25-
- name: Test
26-
run: go test ./backend/...
26+
- name: Test (with race detection)
27+
run: go test -race -p 1 ./backend/...
2728

2829
- name: Build
2930
run: go build -o zenao-backend ./backend
3031

32+
- name: Get go binaries path
33+
id: go-bin-path
34+
run: echo "PATH=$(go env GOPATH)/bin" >> "$GITHUB_OUTPUT"
35+
36+
- name: Cache atlas
37+
id: cache
38+
uses: actions/cache@v4
39+
with:
40+
path: ${{ steps.go-bin-path.outputs.PATH }}
41+
key: ${{ runner.os }}-atlas-bin5-v1.1.0
42+
43+
- name: Install atlas
44+
if: steps.cache.outputs.cache-hit != 'true'
45+
run: make install-atlas
46+
47+
- name: Validate migrations
48+
run: atlas migrate validate --dir "file://migrations" --dev-url "sqlite://file?mode=memory"
49+
3150
- name: Check diff
3251
run: git diff --exit-code

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- develop
78
pull_request:
89
merge_group:
910

0 commit comments

Comments
 (0)