Files
fa-agent/.gitea/workflows/ci.yml
Jayway Liu 5e1437679b
Verify / verify (push) Successful in 15m25s
fix(ci): npm audit / pip-audit 网络抖动重试三次
runner 到 registry.npmjs.org 的 TLS 连接偶发被断(audit endpoint returned an
error),上一轮测试全绿仍被 audit 步骤标红;改为最多重试 3 次、间隔 15 秒。
真实漏洞是确定性的,重试后依然失败,不会漏报
2026-09-26 16:30:39 +08:00

84 lines
3.3 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Verify
on: [push, pull_request]
permissions:
contents: read
jobs:
verify:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17
env:
POSTGRES_PASSWORD: ci-only-password
POSTGRES_DB: traceiq
ports: ['5432:5432']
options: >-
--health-cmd pg_isready --health-interval 5s
--health-timeout 5s --health-retries 10
env:
# Gitea act_runner 的 job 跑在容器里,与服务容器同网络:主机名必须用服务名
# postgres(GitHub 托管 runner 的 localhost 语义在这里连不通,勿改回)。
DATABASE_URL: postgresql://postgres:ci-only-password@postgres:5432/traceiq
E2E_PASSWORD: CI-Test-Only-SecurePassword882!
PYTHONPATH: .
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
with:
version: '0.10.12'
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: npm
- run: uv sync --frozen --python 3.12
- run: npm ci --registry=https://registry.npmjs.org
- run: uv run ruff check server finance tests scripts
- run: uv run ruff format --check server finance tests scripts
- run: uv run python manage.py makemigrations --check --dry-run
- run: uv run pytest --cov=finance --cov-report=term-missing --cov-fail-under=85
- run: npm run build
# 审计端点在 runner 网络下偶发 TLS 断开(npm error audit endpoint returned
# an error),重试区分网络抖动与真实漏洞:漏洞是确定性的,重试后照样红。
- name: npm audit (production deps)
run: |
for attempt in 1 2 3; do
npm audit --omit=dev --registry=https://registry.npmjs.org && exit 0
echo "::warning::npm audit 第 ${attempt} 次失败,15 秒后重试"
sleep 15
done
exit 1
- name: pip-audit
run: |
for attempt in 1 2 3; do
uv run pip-audit && exit 0
echo "::warning::pip-audit 第 ${attempt} 次失败,15 秒后重试"
sleep 15
done
exit 1
- run: uv run python manage.py migrate --noinput
- run: uv run python manage.py collectstatic --noinput
- run: uv run python manage.py bootstrap --username admin --organization CI
env:
BOOTSTRAP_PASSWORD: ${{ env.E2E_PASSWORD }}
- run: npx playwright install --with-deps chromium
- name: Browser regression
shell: bash
run: |
uv run python manage.py runserver 127.0.0.1:8000 --noreload > /tmp/web.log 2>&1 &
web=$!
uv run python manage.py import_worker > /tmp/worker.log 2>&1 &
worker=$!
trap 'kill "$web" "$worker"' EXIT
for i in {1..30}; do curl -fsS http://127.0.0.1:8000/api/health && break; sleep 1; done
npm run test:e2e
# Gitea 不支持 upload-artifact@v4 的 artifact 协议(GHESNotSupportedError),
# 上传失败不该把已经全绿的测试标红;迁到 GitHub 托管时此步骤自动生效。
- uses: actions/upload-artifact@v4
if: always()
continue-on-error: true
with:
name: browser-results
path: |
playwright-report
test-results