feat(trading): unify the route surface, and fix what validating it surfaced #2362
Workflow file for this run
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
| # This is a basic workflow that is manually triggered | |
| name: ci | |
| # Controls when the action will run. Workflow runs when manually triggered using the UI | |
| # or API. | |
| on: | |
| push: | |
| branches: [main, development, 'refactor/unit_tests**', 'epic/**'] | |
| pull_request: | |
| branches: [main, development, 'refactor/unit_tests**', 'epic/**'] | |
| types: [ready_for_review, opened, synchronize, reopened] | |
| jobs: | |
| run_gateway: | |
| name: Check if gateway files changed | |
| outputs: | |
| is_set: ${{ steps.check_files.outputs.is_set }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4.1.1 | |
| - uses: technote-space/get-diff-action@v6 | |
| with: | |
| PATTERNS: | | |
| **/*.+(ts|js|yml) | |
| !Dockerfile | |
| !*.sh | |
| - name: Check if gateway files are modified | |
| id: check_files | |
| if: env.GIT_DIFF | |
| run: | | |
| echo ${{ env.GIT_DIFF }} | |
| echo "is_set=true" >> $GITHUB_OUTPUT | |
| build_gateway: | |
| name: Gateway build + unit tests | |
| needs: run_gateway | |
| if: github.event.pull_request.draft == false && needs.run_gateway.outputs.is_set == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout commit | |
| uses: actions/checkout@v4.1.1 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v2 | |
| with: | |
| version: 10 | |
| - name: Get pnpm store directory | |
| id: pnpm-cache | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
| - uses: actions/cache@v4 | |
| name: Setup pnpm cache | |
| with: | |
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install Dependencies | |
| run: pnpm install --no-frozen-lockfile | |
| - name: Build project | |
| run: pnpm build | |
| - name: Setup configuration for CI | |
| run: | | |
| mkdir -p conf/ | |
| # Copy template configurations | |
| cp -rf src/templates/* conf/ | |
| # The committed spec is what consumers generate their clients from, and the tests | |
| # that check it read the committed copy — so a route change with no regeneration | |
| # leaves them passing against a stale document. Only regenerating and comparing | |
| # catches that. The generator writes the template port and placeholder wallets, so | |
| # this produces the same bytes here as on any developer's machine. | |
| - name: Check openapi.json is regenerated | |
| shell: bash | |
| run: | | |
| pnpm generate:openapi | |
| if ! git diff --quiet -- openapi.json; then | |
| echo "::error::openapi.json does not match the routes. Run 'pnpm generate:openapi' and commit the result." | |
| git --no-pager diff -- openapi.json | |
| exit 1 | |
| fi | |
| - name: Run unit test coverage | |
| if: github.event_name == 'pull_request' | |
| shell: bash | |
| run: | | |
| GATEWAY_TEST_MODE=dev NODE_OPTIONS=--trace-warnings pnpm test || { | |
| echo "Tests failed with exit code $?" | |
| cat $(find ./.jest-coverage -name "*.log" 2>/dev/null) 2>/dev/null || true | |
| exit 1 | |
| } | |
| # Docker build and push is handled by the separate docker_buildx_workflow.yml | |