test(egg-bin): prevent dependency install scripts #3059
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
| # CI workflow for egg monorepo | |
| name: CI | |
| on: | |
| push: | |
| paths-ignore: | |
| - '**/*.md' | |
| branches: [next] | |
| pull_request: | |
| types: [opened, synchronize] | |
| paths-ignore: | |
| - '**/*.md' | |
| branches: [next] | |
| merge_group: | |
| permissions: | |
| id-token: write | |
| actions: write | |
| jobs: | |
| typecheck: | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: typecheck-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }} | |
| cancel-in-progress: true | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 | |
| - name: Setup utoo | |
| uses: utooland/setup-utoo@e7aa4d726a17f79f68aed736476ea5bd68f8ba52 # main | |
| - name: Set up Node.js | |
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 | |
| with: | |
| node-version: '24' | |
| - name: Cache utoo package store | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| with: | |
| path: ${{ runner.temp }}/utoo-store | |
| key: pkgstore-${{ runner.os }}-${{ hashFiles('pnpm-workspace.yaml', '**/package.json') }} | |
| restore-keys: | | |
| pkgstore-${{ runner.os }}- | |
| - name: Install dependencies | |
| env: | |
| UTOO_CACHE_DIR: ${{ runner.temp }}/utoo-store | |
| run: ut install --from pnpm | |
| - name: Run lint | |
| run: ut run lint | |
| - name: Run typecheck | |
| run: ut run typecheck | |
| - name: Run format check | |
| run: ut run fmtcheck | |
| - name: Run build | |
| run: ut run build | |
| - name: Run site build | |
| run: ut run site:build | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] | |
| node: ['22', '24'] | |
| coverage: [false] | |
| # Replace (not duplicate) the ubuntu/24 leg with a coverage-enabled one. | |
| # `include` cannot overwrite an existing matrix dimension, so the base | |
| # coverage:false combo must be excluded first or ubuntu/24 would run twice. | |
| exclude: | |
| - os: 'ubuntu-latest' | |
| node: '24' | |
| coverage: false | |
| include: | |
| - os: 'ubuntu-latest' | |
| node: '24' | |
| coverage: true | |
| name: Test (${{ matrix.os }}, ${{ matrix.node }}) | |
| runs-on: ${{ matrix.os }} | |
| concurrency: | |
| group: test-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}-(${{ matrix.os }}, ${{ matrix.node }}) | |
| cancel-in-progress: true | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 | |
| - name: Start Redis (MacOS or Linux) | |
| if: ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' }} | |
| uses: shogo82148/actions-setup-redis@cff708d63a30aebc0bfaa7276fb709d173f36cb6 # v1 | |
| with: | |
| redis-version: '7' | |
| auto-start: 'true' | |
| - name: Start Redis (Windows via Memurai) | |
| if: ${{ matrix.os == 'windows-latest' }} | |
| shell: pwsh | |
| run: | | |
| # retry up to 3 times to handle Chocolatey feed flakiness | |
| for ($i = 1; $i -le 3; $i++) { | |
| choco install -y memurai-developer.install | |
| if ($LASTEXITCODE -eq 0) { break } | |
| if ($i -lt 3) { | |
| Write-Host "choco install failed (attempt $i/3), retrying in 15s..." | |
| Start-Sleep -Seconds 15 | |
| } else { | |
| Write-Error "choco install failed after 3 attempts" | |
| exit 1 | |
| } | |
| } | |
| # ensure service exists and running (avoid non-zero return code of net start) | |
| $svc = Get-Service -Name Memurai -ErrorAction SilentlyContinue | |
| if (-not $svc) { | |
| Write-Error "Memurai service not found after install" | |
| exit 1 | |
| } | |
| if ($svc.Status -ne 'Running') { | |
| Start-Service -Name Memurai -ErrorAction Stop | |
| # wait for 20s until Running | |
| $svc.WaitForStatus('Running', '00:00:20') | |
| } else { | |
| Write-Host "Memurai already running." | |
| } | |
| # wait for 6379 port ready (max ~60s) | |
| $deadline = (Get-Date).AddSeconds(60) | |
| $ready = $false | |
| while ((Get-Date) -lt $deadline -and -not $ready) { | |
| try { | |
| $client = New-Object System.Net.Sockets.TcpClient | |
| $async = $client.BeginConnect('127.0.0.1', 6379, $null, $null) | |
| $ok = $async.AsyncWaitHandle.WaitOne(2000) | |
| if ($ok -and $client.Connected) { $ready = $true } | |
| $client.Close() | |
| } catch { } | |
| } | |
| if (-not $ready) { | |
| Write-Error "Memurai (Redis) not ready on 127.0.0.1:6379" | |
| exit 1 | |
| } | |
| Write-Host "Memurai is ready on 127.0.0.1:6379" | |
| # install and start MySQL (will automatically start mysqld) | |
| - name: Start MySQL (macOS or Linux) | |
| if: ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' }} | |
| uses: shogo82148/actions-setup-mysql@27e74fac04c136a9f4c2dc2ed457df57331b3e0c # v1 | |
| with: | |
| mysql-version: '8' | |
| auto-start: 'true' | |
| - name: Init DB (macOS or Linux) | |
| if: ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' }} | |
| run: | | |
| mysql -uroot -e "CREATE DATABASE IF NOT EXISTS test;" | |
| - name: Start MySQL (Windows) | |
| if: ${{ matrix.os == 'windows-latest' }} | |
| shell: pwsh | |
| run: | | |
| # retry up to 3 times to handle Chocolatey feed flakiness | |
| for ($i = 1; $i -le 3; $i++) { | |
| choco install -y mysql | |
| if ($LASTEXITCODE -eq 0) { break } | |
| if ($i -lt 3) { | |
| Write-Host "choco install failed (attempt $i/3), retrying in 15s..." | |
| Start-Sleep -Seconds 15 | |
| } else { | |
| Write-Error "choco install failed after 3 attempts" | |
| exit 1 | |
| } | |
| } | |
| refreshenv | |
| # MySQL default root has no password, set a password and create database/user | |
| # & mysqladmin -u root password root | |
| & mysql -uroot -e "CREATE DATABASE IF NOT EXISTS test;" | |
| - name: Setup utoo | |
| uses: utooland/setup-utoo@e7aa4d726a17f79f68aed736476ea5bd68f8ba52 # main | |
| - name: Set up Node.js | |
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| - name: Cache Node compile cache | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| with: | |
| path: ${{ runner.temp }}/node-compile-cache | |
| key: node-compile-cache-${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('pnpm-workspace.yaml', '**/package.json') }} | |
| restore-keys: | | |
| node-compile-cache-${{ runner.os }}-node${{ matrix.node }}- | |
| node-compile-cache-${{ runner.os }}- | |
| - name: Enable Node compile cache | |
| # runner.* is not available in job-level env, so export NODE_COMPILE_CACHE | |
| # here (bash on every OS) — every later step and forked child inherits it. | |
| shell: bash | |
| run: echo "NODE_COMPILE_CACHE=${{ runner.temp }}/node-compile-cache" >> "$GITHUB_ENV" | |
| - name: Cache utoo package store | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| with: | |
| path: ${{ runner.temp }}/utoo-store | |
| key: pkgstore-${{ runner.os }}-${{ hashFiles('pnpm-workspace.yaml', '**/package.json') }} | |
| restore-keys: | | |
| pkgstore-${{ runner.os }}- | |
| - name: Install dependencies | |
| env: | |
| UTOO_CACHE_DIR: ${{ runner.temp }}/utoo-store | |
| run: ut install --from pnpm | |
| - name: Run tests (with coverage) | |
| if: ${{ matrix.coverage }} | |
| run: ut run ci | |
| - name: Run tests | |
| if: ${{ !matrix.coverage }} | |
| run: ut run test | |
| # Summarize how parallel the full-isolate-off suite actually ran. The gating | |
| # test run above (`ut run ci` on the coverage leg, `ut run test` on the rest) | |
| # emits Vitest JSON (vitest.config.ts, CI only); this step turns it into | |
| # avg/peak concurrency + efficiency metrics in the job summary. It is | |
| # informational only (always() so failures still surface metrics) and never | |
| # changes the gate — the test run above already set the job's pass/fail. | |
| - name: Report parallelism metrics | |
| if: always() | |
| # Call node directly: `ut run <script> -- ...` re-serializes forwarded args into | |
| # a shell string without re-quoting, so the parentheses in --name break it. | |
| run: node scripts/ci-test-benchmark.js --report-only --vitest-json benchmark/ci-test/ci-run/vitest-results.json --output-dir benchmark/ci-test/ci-run --name "Parallel test metrics (${{ matrix.os }}, Node ${{ matrix.node }}, isolate=off)" | |
| - name: Run example tests | |
| if: ${{ matrix.os != 'windows-latest' }} | |
| run: | | |
| ut run example:test:all | |
| - name: Code Coverage | |
| if: ${{ matrix.coverage }} | |
| uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5 | |
| with: | |
| use_oidc: true | |
| test-egg-bin: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ['ubuntu-latest', 'windows-latest'] | |
| node: ['24'] | |
| coverage: [false] | |
| exclude: | |
| - os: 'ubuntu-latest' | |
| node: '24' | |
| coverage: false | |
| include: | |
| - os: 'ubuntu-latest' | |
| node: '24' | |
| coverage: true | |
| name: Test bin (${{ matrix.os }}, ${{ matrix.node }}) | |
| runs-on: ${{ matrix.os }} | |
| concurrency: | |
| group: test-egg-bin-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}-(${{ matrix.os }}, ${{ matrix.node }}) | |
| cancel-in-progress: true | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 | |
| - name: Setup utoo | |
| uses: utooland/setup-utoo@e7aa4d726a17f79f68aed736476ea5bd68f8ba52 # main | |
| - name: Set up Node.js | |
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| - name: Cache Node compile cache | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| with: | |
| path: ${{ runner.temp }}/node-compile-cache | |
| key: node-compile-cache-${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('pnpm-workspace.yaml', '**/package.json') }} | |
| restore-keys: | | |
| node-compile-cache-${{ runner.os }}-node${{ matrix.node }}- | |
| node-compile-cache-${{ runner.os }}- | |
| - name: Enable Node compile cache | |
| # runner.* is not available in job-level env, so export NODE_COMPILE_CACHE | |
| # here (bash on every OS) — every later step and forked child inherits it. | |
| shell: bash | |
| run: echo "NODE_COMPILE_CACHE=${{ runner.temp }}/node-compile-cache" >> "$GITHUB_ENV" | |
| - name: Cache utoo package store | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| with: | |
| path: ${{ runner.temp }}/utoo-store | |
| key: pkgstore-${{ runner.os }}-${{ hashFiles('pnpm-workspace.yaml', '**/package.json') }} | |
| restore-keys: | | |
| pkgstore-${{ runner.os }}- | |
| - name: Install dependencies | |
| env: | |
| UTOO_CACHE_DIR: ${{ runner.temp }}/utoo-store | |
| run: ut install --from pnpm | |
| - name: Build egg-bin | |
| working-directory: tools/egg-bin | |
| run: ut run build | |
| - name: Run tests (with coverage) | |
| if: ${{ matrix.coverage }} | |
| run: ut run ci --workspace @eggjs/bin | |
| - name: Run tests | |
| if: ${{ !matrix.coverage }} | |
| run: ut run test --workspace @eggjs/bin | |
| - name: Code Coverage | |
| if: ${{ matrix.coverage }} | |
| uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5 | |
| with: | |
| use_oidc: true | |
| test-egg-scripts: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ['ubuntu-latest'] | |
| node: ['22', '24'] | |
| coverage: [false] | |
| exclude: | |
| - os: 'ubuntu-latest' | |
| node: '24' | |
| coverage: false | |
| include: | |
| - os: 'ubuntu-latest' | |
| node: '24' | |
| coverage: true | |
| name: Test scripts (${{ matrix.os }}, ${{ matrix.node }}) | |
| runs-on: ${{ matrix.os }} | |
| concurrency: | |
| group: test-egg-scripts-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}-(${{ matrix.os }}, ${{ matrix.node }}) | |
| cancel-in-progress: true | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 | |
| - name: Setup utoo | |
| uses: utooland/setup-utoo@e7aa4d726a17f79f68aed736476ea5bd68f8ba52 # main | |
| - name: Set up Node.js | |
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| - name: Cache Node compile cache | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| with: | |
| path: ${{ runner.temp }}/node-compile-cache | |
| key: node-compile-cache-${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('pnpm-workspace.yaml', '**/package.json') }} | |
| restore-keys: | | |
| node-compile-cache-${{ runner.os }}-node${{ matrix.node }}- | |
| node-compile-cache-${{ runner.os }}- | |
| - name: Enable Node compile cache | |
| # runner.* is not available in job-level env, so export NODE_COMPILE_CACHE | |
| # here (bash on every OS) — every later step and forked child inherits it. | |
| shell: bash | |
| run: echo "NODE_COMPILE_CACHE=${{ runner.temp }}/node-compile-cache" >> "$GITHUB_ENV" | |
| - name: Cache utoo package store | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| with: | |
| path: ${{ runner.temp }}/utoo-store | |
| key: pkgstore-${{ runner.os }}-${{ hashFiles('pnpm-workspace.yaml', '**/package.json') }} | |
| restore-keys: | | |
| pkgstore-${{ runner.os }}- | |
| - name: Install dependencies | |
| env: | |
| UTOO_CACHE_DIR: ${{ runner.temp }}/utoo-store | |
| run: ut install --from pnpm | |
| # own step for clear failure attribution; @eggjs/scripts has no build | |
| # script of its own, so build it through the root tsdown workspace | |
| # filter (path form is fine here, this job only runs on ubuntu) | |
| - name: Build egg-scripts | |
| run: ut run build -- --workspace ./tools/scripts | |
| - name: Run tests (with coverage) | |
| if: ${{ matrix.coverage }} | |
| run: ut run ci --workspace @eggjs/scripts | |
| - name: Run tests | |
| if: ${{ !matrix.coverage }} | |
| run: ut run test --workspace @eggjs/scripts | |
| - name: Code Coverage | |
| if: ${{ matrix.coverage }} | |
| uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5 | |
| with: | |
| use_oidc: true | |
| done: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - test | |
| - test-egg-bin | |
| - test-egg-scripts | |
| - typecheck | |
| steps: | |
| - run: exit 1 | |
| if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }} |