Reorganize repo: backend/, deploy/, docs/ layout + AGENTS.md

Restructure the monorepo into clear top-level directories:
- backend/: Go module root (cmd, internal, pkg, configs, migrations,
  docs/swagger, scripts, tests, go.mod, Makefile, .air.toml)
- deploy/: Docker (Dockerfile, docker-compose*), quickstart, fluentd
- docs/: project documentation + reports/ (moved from repo root)
- AGENTS.md: new AI coding-agent guide at repo root

Update all references to the new layout:
- Dockerfile: COPY backend/go.mod, COPY backend/ (context = repo root)
- docker-compose files: context ../.., dockerfile deploy/docker/Dockerfile,
  env_file ../../.env, volume mounts ../../backend:/app
- deploy/quickstart/compose.yaml: dockerfile deploy/docker/Dockerfile
- CI: working-directory: backend for go commands, file deploy/docker/Dockerfile,
  coverage path backend/coverage.out, health_check backend/scripts/
- backend/Makefile: docker target uses -f ../deploy/docker/Dockerfile ../
- README: architecture tree, quickstart, config paths updated

Move root stray scripts (rename_models.*, run_m11_tests.sh, verify_build.sh,
gorm_bool_main.go) to backend/scripts/legacy/. All moves via git mv to
preserve history. Build, vet, SQLite tests, and docker compose config verified.
This commit is contained in:
2026-07-07 14:44:12 +08:00
parent d4ef996f49
commit aeddedf2a3
1348 changed files with 176 additions and 57 deletions
+13 -6
View File
@@ -55,13 +55,16 @@ jobs:
uses: golangci/golangci-lint-action@v6
with:
version: v1.64
working-directory: backend
# Vet
- name: Run go vet
working-directory: backend
run: go vet ./...
# Unit + Integration Tests
- name: Run unit & integration tests
working-directory: backend
env:
GOCHAT_ENV: test
GOCHAT_TEST_DB: ${{ matrix.db-mode }}
@@ -78,6 +81,7 @@ jobs:
# E2E Tests (only on postgres matrix)
- name: Run e2e tests
if: matrix.db-mode == 'postgres'
working-directory: backend
env:
GOCHAT_ENV: test
POSTGRES_HOST: localhost
@@ -91,6 +95,7 @@ jobs:
# Benchmark (quick sanity check, not full bench)
- name: Run benchmarks
working-directory: backend
env:
GOCHAT_ENV: test
GOCHAT_TEST_DB: ${{ matrix.db-mode }}
@@ -106,7 +111,7 @@ jobs:
if: matrix.db-mode == 'postgres'
uses: codecov/codecov-action@v4
with:
files: coverage.out
files: backend/coverage.out
# ---- Stage 2: Security Scan ----
security:
@@ -124,9 +129,11 @@ jobs:
uses: securego/gosec@master
with:
args: '-no-fail ./...'
working-directory: backend
# Dependency vulnerability scan
- name: Run govulncheck
working-directory: backend
run: go install golang.org/x/vuln/cmd/govulncheck@latest && govulncheck ./...
# Trivy filesystem scan
@@ -185,7 +192,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
file: ./deploy/docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
@@ -260,8 +267,8 @@ jobs:
# Post-deploy health check
- name: Health check
run: |
chmod +x scripts/health_check.sh
GOCHAT_HOST=gochat-staging GOCHAT_PORT=3000 ./scripts/health_check.sh --full --timeout 30
chmod +x backend/scripts/health_check.sh
GOCHAT_HOST=gochat-staging GOCHAT_PORT=3000 ./backend/scripts/health_check.sh --full --timeout 30
# ---- Stage 6: Deploy to Production ----
deploy-production:
@@ -290,5 +297,5 @@ jobs:
# Post-deploy health check
- name: Health check
run: |
chmod +x scripts/health_check.sh
GOCHAT_HOST=gochat-production GOCHAT_PORT=3000 ./scripts/health_check.sh --full --timeout 30
chmod +x backend/scripts/health_check.sh
GOCHAT_HOST=gochat-production GOCHAT_PORT=3000 ./backend/scripts/health_check.sh --full --timeout 30