Skip to content

ci(contract-test-utils): consolidating test websocket implementation #161

ci(contract-test-utils): consolidating test websocket implementation

ci(contract-test-utils): consolidating test websocket implementation #161

Workflow file for this run

name: sdk/react
on:
push:
branches: [main, 'feat/**']
paths-ignore:
- '**.md' #Do not need to run CI for markdown changes.
pull_request:
branches: [main, 'feat/**']
paths-ignore:
- '**.md'
jobs:
build-test-react:
runs-on: ubuntu-latest
strategy:
matrix:
# Node versions to run on.
version: [20, 22]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ matrix.version }}
registry-url: 'https://registry.npmjs.org'
- id: shared
name: Shared CI Steps
uses: ./actions/ci
with:
workspace_name: '@launchdarkly/react-sdk'
workspace_path: packages/sdk/react
# Contract Tests
- name: Install and build contract test dependencies
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: 'false'
# Skip Electron binary download to avoid flaky race condition during concurrent installs.
ELECTRON_SKIP_BINARY_DOWNLOAD: '1'
run: |
yarn workspaces foreach -pR --topological-dev --from '@launchdarkly/react-sdk-contract-tests' install
yarn workspaces foreach -pR --topological-dev --from '@launchdarkly/react-sdk-contract-tests' run build
- name: Install Playwright browsers
run: yarn workspace @launchdarkly/react-sdk-contract-tests install-playwright-browsers
- name: Run test adapter
run: |
yarn workspace @launchdarkly/react-sdk-contract-tests run start:adapter > /tmp/adapter.log 2>&1 &
echo $! > /tmp/adapter.pid
- name: Run test entity
run: |
yarn workspace @launchdarkly/react-sdk-contract-tests run start:entity > /tmp/entity.log 2>&1 &
echo $! > /tmp/entity.pid
- name: Run test browser
run: |
yarn workspace @launchdarkly/react-sdk-contract-tests run start:browser > /tmp/browser.log 2>&1 &
echo $! > /tmp/browser.pid
- name: Wait for services to be ready
run: |
echo "Waiting for entity on port 8000..."
for i in {1..30}; do
if curl -s http://localhost:8000 > /dev/null; then
echo "Entity ready"
break
fi
if [ $i -eq 30 ]; then
echo "Timeout waiting for entity"
cat /tmp/adapter.log /tmp/entity.log /tmp/browser.log
exit 1
fi
sleep 1
done
sleep 5
- name: Run contract tests
uses: launchdarkly/gh-actions/actions/contract-tests@d271978e893b5b9facb9f000414e9fcd62e1f78b
with:
test_service_port: 8000
token: ${{ secrets.GITHUB_TOKEN }}
extra_params: '--skip-from=${{ github.workspace }}/packages/sdk/react/contract-tests/suppressions.txt --stop-service-at-end'
- name: Cleanup contract test services
if: always()
run: |
[ -f /tmp/browser.pid ] && kill $(cat /tmp/browser.pid) || true
[ -f /tmp/entity.pid ] && kill $(cat /tmp/entity.pid) || true
[ -f /tmp/adapter.pid ] && kill $(cat /tmp/adapter.pid) || true
run-example:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 24
- uses: ./actions/run-example
with:
workspace_name: '@internal/react-sdk-example-hello-react'
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
before_test: 'yarn workspace @internal/react-sdk-example-hello-react playwright install --with-deps chromium'
run-server-only-example:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 24
- uses: ./actions/run-example
with:
workspace_name: '@internal/react-sdk-example-server-only'
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
before_test: 'yarn workspace @internal/react-sdk-example-server-only playwright install --with-deps chromium'