feat(logging): 添加 HTTP 请求日志拦截器(慢请求 + 错误自动记录) #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| services: | |
| mariadb: | |
| image: mariadb:10.11 | |
| env: | |
| MARIADB_ROOT_PASSWORD: test | |
| MARIADB_DATABASE: leverage_test | |
| MARIADB_USER: leverage | |
| MARIADB_PASSWORD: test | |
| ports: ["3306:3306"] | |
| options: --health-cmd="healthcheck.sh --connect --innodb-buffer-pool-pages-free=0" --health-interval=10s --health-timeout=5s --health-retries=10 | |
| redis: | |
| image: redis:7-alpine | |
| ports: ["6379:6379"] | |
| options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=5 | |
| env: | |
| NODE_ENV: test | |
| PORT: 3000 | |
| SKIP_INIT: true | |
| # Database | |
| DB_HOST: 127.0.0.1 | |
| DB_PORT: 3306 | |
| DB_DATABASE: leverage_test | |
| DB_USERNAME: leverage | |
| DB_PASSWORD: test | |
| # Redis | |
| REDIS_HOST: 127.0.0.1 | |
| REDIS_PORT: 6379 | |
| # JWT | |
| JWT_ACCESS_SECRET: ${{ secrets.JWT_ACCESS_SECRET }} | |
| JWT_REFRESH_SECRET: ${{ secrets.JWT_REFRESH_SECRET }} | |
| JWT_ACCESS_EXPIRES_IN: 15m | |
| JWT_REFRESH_EXPIRES_IN: 7d | |
| # App | |
| BASE_URL: http://localhost:3000 | |
| MAX_SUBMISSION_PER_MINUTE: 10 | |
| # Heng Judge (mock in CI) | |
| HENG_BASE_URL: http://localhost:5000 | |
| HENG_AK: ci_access_key | |
| HENG_SK: ci_secret_key | |
| HENG_ALLOW_INSECURE_TLS: false | |
| # Init | |
| INIT_SA_USERNAME: admin | |
| INIT_SA_PASSWORD: Admin@123456 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v3 | |
| with: | |
| version: 9 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: pnpm | |
| - run: pnpm install | |
| - run: pnpm build | |
| - name: Unit tests | |
| run: pnpm test:unit --coverage | |
| - name: Integration tests | |
| run: pnpm test:integration | |
| env: | |
| DB_TYPE: sqlite | |
| - name: Upload coverage | |
| uses: codecov/codecov-action@v4 | |
| if: always() | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Lint | |
| run: pnpm lint | |
| e2e: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| env: | |
| NODE_ENV: test | |
| PORT: 3000 | |
| SKIP_INIT: true | |
| DB_HOST: 127.0.0.1 | |
| DB_PORT: 3306 | |
| DB_DATABASE: leverage_test | |
| DB_USERNAME: leverage | |
| DB_PASSWORD: test | |
| REDIS_HOST: 127.0.0.1 | |
| REDIS_PORT: 6379 | |
| JWT_ACCESS_SECRET: ${{ secrets.JWT_ACCESS_SECRET }} | |
| JWT_REFRESH_SECRET: ${{ secrets.JWT_REFRESH_SECRET }} | |
| JWT_ACCESS_EXPIRES_IN: 15m | |
| JWT_REFRESH_EXPIRES_IN: 7d | |
| BASE_URL: http://localhost:3000 | |
| MAX_SUBMISSION_PER_MINUTE: 10 | |
| HENG_BASE_URL: http://localhost:5000 | |
| HENG_AK: ci_access_key | |
| HENG_SK: ci_secret_key | |
| HENG_ALLOW_INSECURE_TLS: false | |
| INIT_SA_USERNAME: admin | |
| INIT_SA_PASSWORD: Admin@123456 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v3 | |
| with: | |
| version: 9 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: pnpm | |
| - run: pnpm install | |
| - name: E2E tests (testcontainers) | |
| run: pnpm test:e2e | |
| env: | |
| TESTCONTAINERS_RYUK_DISABLED: true |