From c8db4bbdc3b4c9e62fc42acdee7559098969f31f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E9=A3=8E?= Date: Mon, 11 May 2026 14:55:30 +0800 Subject: [PATCH] =?UTF-8?q?chore(gitea):=20=E7=B2=BE=E7=AE=80=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=20workflow=EF=BC=8C=E7=A7=BB=E9=99=A4=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=20CI=EF=BC=8C=E4=BF=9D=E7=95=99=20main/bt=20=E8=A7=A6?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- .gitea/workflows/deploy.yml | 38 +-------- .gitea/workflows/playwright.yml | 100 ----------------------- .gitea/workflows/test-backend.yml | 46 ----------- .gitea/workflows/test-docker-compose.yml | 31 ------- 4 files changed, 1 insertion(+), 214 deletions(-) delete mode 100644 .gitea/workflows/playwright.yml delete mode 100644 .gitea/workflows/test-backend.yml delete mode 100644 .gitea/workflows/test-docker-compose.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index e754350..eb87c52 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -23,6 +23,7 @@ jobs: FRONTEND_HOST=${{ secrets.FRONTEND_HOST }} ENVIRONMENT=production PROJECT_NAME=${{ secrets.PROJECT_NAME }} + STACK_NAME=${{ secrets.STACK_NAME }} BACKEND_CORS_ORIGINS=${{ secrets.BACKEND_CORS_ORIGINS }} SECRET_KEY=${{ secrets.SECRET_KEY }} FIRST_SUPERUSER=${{ secrets.FIRST_SUPERUSER }} @@ -40,16 +41,6 @@ jobs: POSTGRES_USER=${{ secrets.POSTGRES_USER }} POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }} SENTRY_DSN=${{ secrets.SENTRY_DSN }} - MQTT_HOST=${{ secrets.MQTT_HOST }} - MQTT_PORT=${{ secrets.MQTT_PORT }} - MQTT_USERNAME=${{ secrets.MQTT_USERNAME }} - MQTT_PASSWORD=${{ secrets.MQTT_PASSWORD }} - MQTT_TOPIC_PATTERN=${{ secrets.MQTT_TOPIC_PATTERN }} - MQTT_CLIENT_ID=${{ secrets.MQTT_CLIENT_ID }} - RAW_HOT_RETENTION_DAYS=${{ secrets.RAW_HOT_RETENTION_DAYS }} - RAW_ARCHIVE_BASE_DIR=${{ secrets.RAW_ARCHIVE_BASE_DIR }} - PARSER_BATCH_SIZE=${{ secrets.PARSER_BATCH_SIZE }} - PARSER_POLL_INTERVAL_MS=${{ secrets.PARSER_POLL_INTERVAL_MS }} DOCKER_IMAGE_BACKEND=${{ secrets.DOCKER_IMAGE_BACKEND }} DOCKER_IMAGE_FRONTEND=${{ secrets.DOCKER_IMAGE_FRONTEND }} ENVEOF @@ -57,16 +48,6 @@ jobs: # Fallback defaults if image name secrets are empty sed -i 's/^DOCKER_IMAGE_BACKEND=$/DOCKER_IMAGE_BACKEND=backend/' .env.production sed -i 's/^DOCKER_IMAGE_FRONTEND=$/DOCKER_IMAGE_FRONTEND=frontend/' .env.production - sed -i 's/^MQTT_HOST=$/MQTT_HOST=1Panel-emqx-Rniy/' .env.production - sed -i 's/^MQTT_PORT=$/MQTT_PORT=1883/' .env.production - sed -i 's/^MQTT_USERNAME=$/MQTT_USERNAME=weefnn/' .env.production - sed -i 's/^MQTT_PASSWORD=$/MQTT_PASSWORD=123456/' .env.production - sed -i 's%^MQTT_TOPIC_PATTERN=$%MQTT_TOPIC_PATTERN=terminal/+/raw%' .env.production - sed -i 's/^MQTT_CLIENT_ID=$/MQTT_CLIENT_ID=spatialhub-mqtt-ingestor/' .env.production - sed -i 's/^RAW_HOT_RETENTION_DAYS=$/RAW_HOT_RETENTION_DAYS=90/' .env.production - sed -i 's%^RAW_ARCHIVE_BASE_DIR=$%RAW_ARCHIVE_BASE_DIR=/data/archive/gnss%' .env.production - sed -i 's/^PARSER_BATCH_SIZE=$/PARSER_BATCH_SIZE=200/' .env.production - sed -i 's/^PARSER_POLL_INTERVAL_MS=$/PARSER_POLL_INTERVAL_MS=300/' .env.production - name: Build Docker images run: docker compose --env-file .env.production -f compose.prod.yml build @@ -103,22 +84,5 @@ jobs: exit 1 fi - - name: Verify mqtt workers - run: | - if docker compose --env-file .env.production -f compose.prod.yml ps mqtt-ingestor --status running | grep -q mqtt-ingestor; then - echo "✅ mqtt-ingestor is running!" - else - echo "❌ mqtt-ingestor is not running" - docker compose --env-file .env.production -f compose.prod.yml logs mqtt-ingestor - exit 1 - fi - if docker compose --env-file .env.production -f compose.prod.yml ps mqtt-parser-worker --status running | grep -q mqtt-parser-worker; then - echo "✅ mqtt-parser-worker is running!" - else - echo "❌ mqtt-parser-worker is not running" - docker compose --env-file .env.production -f compose.prod.yml logs mqtt-parser-worker - exit 1 - fi - - name: Cleanup old Docker images run: docker image prune -f || true diff --git a/.gitea/workflows/playwright.yml b/.gitea/workflows/playwright.yml deleted file mode 100644 index 3dd590c..0000000 --- a/.gitea/workflows/playwright.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: Playwright Tests - -on: - push: - branches: - - main - - bt - pull_request: - types: - - opened - - synchronize - workflow_dispatch: - -jobs: - test-playwright: - timeout-minutes: 60 - runs-on: ubuntu-latest - steps: - - name: Checkout - run: | - set -euo pipefail - git clone "http://172.17.0.1:3000/${{ github.repository }}.git" . - git checkout "${{ github.sha }}" - - - name: Detect relevant file changes - id: changes - run: | - set -euo pipefail - CHANGED=false - - if [ "${{ github.event_name }}" = "pull_request" ]; then - BASE="${{ github.base_ref }}" - git fetch origin "+refs/heads/${BASE}:refs/remotes/origin/${BASE}" --depth=200 2>/dev/null \ - || git fetch origin --depth=200 - if git rev-parse "origin/${BASE}" >/dev/null 2>&1; then - FILES=$(git diff --name-only "origin/${BASE}...HEAD" || true) - else - FILES=$(git show --name-only --pretty=format: HEAD) - fi - else - BEFORE="${{ github.event.before }}" - if [ -z "${BEFORE}" ] || [ "${BEFORE}" = "0000000000000000000000000000000000000000" ]; then - FILES=$(git show --name-only --pretty=format: HEAD) - else - FILES=$(git diff --name-only "${BEFORE}" "${{ github.sha }}" || true) - fi - fi - - while IFS= read -r line; do - [ -z "${line}" ] && continue - case "${line}" in - backend/*|frontend/*|.env|compose*|.gitea/workflows/playwright.yml|.github/workflows/playwright.yml) - CHANGED=true - break - ;; - esac - done <<< "${FILES}" - - echo "changed=${CHANGED}" >> "${GITHUB_OUTPUT}" - echo "Relevant changes for Playwright: ${CHANGED}" - - - name: Skip Playwright (no relevant changes) - if: steps.changes.outputs.changed != 'true' - run: echo "Skipping Playwright — no changes under backend/, frontend/, compose, .env, or playwright workflows." - - - name: Install uv and Bun - if: steps.changes.outputs.changed == 'true' - run: | - set -euo pipefail - export PATH="${HOME}/.bun/bin:${PATH}" - export UV_PYTHON_DOWNLOADS=automatic - - sudo apt-get update -qq - sudo apt-get install -y python3 python3-venv curl unzip ca-certificates - - python3 -m venv /tmp/gitea-ci-venv - /tmp/gitea-ci-venv/bin/pip install --upgrade pip - /tmp/gitea-ci-venv/bin/pip install "uv>=0.4" - export PATH="/tmp/gitea-ci-venv/bin:${PATH}" - - # Official Bun installer (not GitHub Actions) - curl -fsSL https://bun.sh/install | bash - - - name: Generate client, build images, run Playwright - if: steps.changes.outputs.changed == 'true' - run: | - set -euo pipefail - export PATH="/tmp/gitea-ci-venv/bin:${HOME}/.bun/bin:${PATH}" - export BUN_INSTALL="${HOME}/.bun" - - (cd backend && uv sync) - bun ci - bash scripts/generate-client.sh - - docker compose build - docker compose down -v --remove-orphans || true - docker compose run --rm playwright bunx playwright test \ - --fail-on-flaky-tests \ - --trace=retain-on-failure - docker compose down -v --remove-orphans || true diff --git a/.gitea/workflows/test-backend.yml b/.gitea/workflows/test-backend.yml deleted file mode 100644 index 9f7476c..0000000 --- a/.gitea/workflows/test-backend.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Test Backend - -on: - push: - branches: - - main - - bt - pull_request: - types: - - opened - - synchronize - -jobs: - test-backend: - runs-on: ubuntu-latest - steps: - - name: Checkout and run backend tests - run: | - set -euo pipefail - export UV_PYTHON_DOWNLOADS=automatic - - git clone "http://172.17.0.1:3000/${{ github.repository }}.git" . - git checkout "${{ github.sha }}" - - sudo apt-get update -qq - sudo apt-get install -y python3 python3-venv ca-certificates - - # PEP 668: do not pip install into system Python; bootstrap uv inside a throwaway venv - python3 -m venv /tmp/gitea-ci-venv - /tmp/gitea-ci-venv/bin/pip install --upgrade pip - /tmp/gitea-ci-venv/bin/pip install "uv>=0.4" - export PATH="/tmp/gitea-ci-venv/bin:${PATH}" - - docker compose down -v --remove-orphans || true - docker compose up -d db mailcatcher - - (cd backend && uv run bash scripts/prestart.sh) - (cd backend && uv run bash scripts/tests-start.sh "Coverage for ${{ github.sha }}") - - docker compose down -v --remove-orphans || true - - if [ -d backend/htmlcov ]; then - echo "Coverage HTML generated under backend/htmlcov (view on runner if needed)." - fi - - (cd backend && uv run coverage report --fail-under=90) diff --git a/.gitea/workflows/test-docker-compose.yml b/.gitea/workflows/test-docker-compose.yml deleted file mode 100644 index 913d94f..0000000 --- a/.gitea/workflows/test-docker-compose.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Test Docker Compose - -on: - push: - branches: - - main - - bt - pull_request: - types: - - opened - - synchronize - -jobs: - test-docker-compose: - runs-on: ubuntu-latest - steps: - - name: Checkout and verify compose stack - run: | - set -euo pipefail - - git clone "http://172.17.0.1:3000/${{ github.repository }}.git" . - git checkout "${{ github.sha }}" - - docker compose build - docker compose down -v --remove-orphans || true - docker compose up -d --wait backend frontend adminer - - curl -fsS http://localhost:8000/api/v1/utils/health-check - curl -fsS http://localhost:5173 - - docker compose down -v --remove-orphans || true