Skip to content

tests:e2e

tests:e2e #47

Workflow file for this run

name: tests:e2e
on:
workflow_run:
workflows: ["πŸ‘·β€β™‚οΈ Build Release"]
branches: [master]
types: [completed]
workflow_dispatch:
inputs:
xyd_version:
description: 'xyd-js version to install (e.g. "canary", "0.1.0-alpha.6", "latest")'
required: false
default: ''
branch:
description: 'Branch to checkout tests from'
required: false
default: ''
jobs:
test:
name: πŸ§ͺ E2E Tests
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
strategy:
matrix:
node-version: [22.12.0]
steps:
- name: πŸ“₯ Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch || github.ref }}
- name: 🟒 Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.10.0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 'latest'
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm i
- name: Install Playwright browsers
run: pnpm exec playwright install
- name: πŸ”§ Install xyd-js CLI
run: |
# Check if a custom version was provided via workflow_dispatch
CUSTOM_VERSION="${{ github.event.inputs.xyd_version }}"
if [ -n "$CUSTOM_VERSION" ]; then
echo "πŸ“¦ Installing xyd-js@${CUSTOM_VERSION} (manual)"
npm i -g xyd-js@${CUSTOM_VERSION}
else
# Auto-detect from workflow_run (snapshot build)
BUILD_VERSION="${{ github.event.workflow_run.outputs.BUILD_VERSION }}"
if [ -z "$BUILD_VERSION" ]; then
SHA=$(git rev-parse HEAD)
SHORT_SHA=${SHA::7}
BUILD_VERSION=build-${SHORT_SHA}
fi
SHORT_SHA=${BUILD_VERSION#build-}
LATEST_BUILD_VERSION=$(npm view @xyd-js/cli versions --json | jq -r '.[] | select(test("^0\\.0\\.0-build-'${SHORT_SHA}'-[0-9]+$")) | .' | sort -V | tail -n1)
if [ -z "$LATEST_BUILD_VERSION" ]; then
echo "❌ No build version found for SHA: ${SHORT_SHA}"
exit 1
fi
echo "πŸ“¦ Installing @xyd-js/cli@${LATEST_BUILD_VERSION}"
pnpm add -g @xyd-js/cli@${LATEST_BUILD_VERSION} --registry=https://registry.npmjs.org
fi
echo "βœ… Installed version:"
xyd --version || echo "(version command not available)"
- name: πŸ“¦ Start Verdaccio (local registry for e2e tests)
run: |
npm install -g verdaccio
verdaccio --config __tests__/e2e/verdaccio-ci-config.yaml &
# Wait for Verdaccio to be ready
for i in $(seq 1 30); do
curl -sf http://localhost:4873 > /dev/null 2>&1 && break
sleep 1
done
# Create user and save auth token for publishing
TOKEN=$(curl -s -XPUT -H "Content-Type: application/json" \
-d '{"name":"test","password":"test"}' \
http://localhost:4873/-/user/org.couchdb.user:test | jq -r '.token')
echo "//localhost:4873/:_authToken=\"${TOKEN}\"" >> ~/.npmrc
echo "βœ… Verdaccio is running on http://localhost:4873"
- name: πŸ§ͺ Run E2E tests
run: pnpm run test:e2e
env:
XYD_E2E_VERDACCIO_URL: http://localhost:4873