mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 17:17:38 +00:00
160 lines
5.2 KiB
YAML
160 lines
5.2 KiB
YAML
name: Unit tests
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
node_versions:
|
|
description: JSON array of Node.js major versions to test.
|
|
required: true
|
|
type: string
|
|
|
|
runner:
|
|
description: Hosted runner for the unit shards; relay integration keeps its x86 host.
|
|
required: false
|
|
default: ubuntu-latest
|
|
type: string
|
|
|
|
browser_contract:
|
|
description: Include the PR external Chromium browser contract in relay integration.
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
|
|
run_shards:
|
|
description: Run the planned root unit shards.
|
|
required: false
|
|
default: true
|
|
type: boolean
|
|
|
|
shards:
|
|
description: JSON array of shard assignments, produced by unit-plan.yml.
|
|
required: true
|
|
type: string
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
test:
|
|
if: inputs.run_shards
|
|
name: tests node ${{ matrix.node }} ${{ matrix.shard.index }}/${{ matrix.shard.count }}
|
|
runs-on: ${{ inputs.runner }}
|
|
timeout-minutes: 60
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
node: ${{ fromJSON(inputs.node_versions) }}
|
|
shard: ${{ fromJSON(inputs.shards) }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- uses: ./.github/actions/install-node-dependencies
|
|
with:
|
|
native-runtime: node
|
|
node-version: ${{ matrix.node }}
|
|
cache-electron-package: 'true'
|
|
|
|
- name: Install Electron package binary for tests
|
|
run: node config/scripts/install-electron-package-binary.mjs
|
|
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
|
with:
|
|
bun-version-file: config/.bun-version
|
|
|
|
- uses: actions/download-artifact@v8
|
|
continue-on-error: true
|
|
with:
|
|
name: unit-selection-attempt-${{ github.run_attempt }}
|
|
path: ci-shards/
|
|
|
|
- name: Test shard
|
|
env:
|
|
ORCA_BALANCE_UNIT_SHARDS: '1'
|
|
ORCA_BACKGROUND_LAUNCH: '1'
|
|
run: |
|
|
ORCA_SHARD_SOURCE_SHA="$(git rev-parse HEAD)"
|
|
export ORCA_SHARD_SOURCE_SHA
|
|
node config/scripts/run-vitest.mjs run --config config/vitest.config.ts \
|
|
--shard=${{ matrix.shard.index }}/${{ matrix.shard.count }} \
|
|
${{ inputs.runner == 'ubuntu-24.04-arm' && '--maxWorkers=4' || '' }}
|
|
|
|
- name: Upload unit shard assignment
|
|
if: always()
|
|
# Diagnostic upload outages must not change the test verdict.
|
|
continue-on-error: true
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: unit-shard-node-${{ matrix.node }}-${{ matrix.shard.index }}-attempt-${{ github.run_attempt }}
|
|
path: ci-shards/
|
|
retention-days: 14
|
|
if-no-files-found: warn
|
|
|
|
relay_integration:
|
|
name: relay integration node ${{ matrix.node }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
node: ${{ fromJSON(inputs.node_versions) }}
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 60
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- uses: ./.github/actions/install-node-dependencies
|
|
id: root_dependencies
|
|
with:
|
|
native-runtime: none
|
|
node-version: ${{ matrix.node }}
|
|
cache-dependency-path: |
|
|
pnpm-lock.yaml
|
|
cloud/pnpm-lock.yaml
|
|
|
|
- name: Resolve Chrome for the browser provider
|
|
id: browser_executable
|
|
if: inputs.browser_contract && success()
|
|
run: |
|
|
set -euo pipefail
|
|
chrome="$(command -v google-chrome || command -v google-chrome-stable || true)"
|
|
if [ -z "$chrome" ]; then
|
|
echo "::error::No Google Chrome on the runner; the browser provider test would silently skip."
|
|
exit 1
|
|
fi
|
|
"$chrome" --version
|
|
echo "executable=$chrome" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Test external Chromium browser provider
|
|
if: inputs.browser_contract && success()
|
|
env:
|
|
ORCA_BACKGROUND_LAUNCH: '1'
|
|
ORCA_BROWSER_EXECUTABLE: ${{ steps.browser_executable.outputs.executable }}
|
|
run: |
|
|
pnpm exec vitest run --config config/vitest.config.ts \
|
|
src/main/orcad/external-chromium-browser-process.integration.test.ts
|
|
|
|
# These two tests import the cloud relay workspace directly. Keeping them in one job
|
|
# avoids installing and building the same workspace once per unit-test shard.
|
|
- name: Install relay integration dependencies
|
|
id: relay_dependencies
|
|
if: ${{ !cancelled() && steps.root_dependencies.outcome == 'success' }}
|
|
working-directory: cloud
|
|
run: |
|
|
npx --yes pnpm@10.34.6 --filter '@orca-cloud/relay...' install --frozen-lockfile --ignore-scripts
|
|
npx --yes pnpm@10.34.6 --filter '@orca-cloud/relay^...' build
|
|
|
|
- name: Test relay integration contracts
|
|
if: ${{ !cancelled() && steps.relay_dependencies.outcome == 'success' }}
|
|
env:
|
|
ORCA_BACKGROUND_LAUNCH: '1'
|
|
run: >-
|
|
pnpm exec vitest run --config config/vitest.config.ts
|
|
tests/e2e/relay-region-compatibility.unit.test.ts
|
|
tests/e2e/relay-region-correction.unit.test.ts
|