-
Notifications
You must be signed in to change notification settings - Fork 9
122 lines (101 loc) Β· 3.76 KB
/
tests-e2e.yml
File metadata and controls
122 lines (101 loc) Β· 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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