tests:e2e #29
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
| 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: π§ͺ Run E2E tests | |
| run: pnpm run test:e2e |