-
Notifications
You must be signed in to change notification settings - Fork 1
113 lines (93 loc) · 3.54 KB
/
Copy pathchainwright.yaml
File metadata and controls
113 lines (93 loc) · 3.54 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
name: Continous Integration
on:
workflow_dispatch:
pull_request:
branches: ["main", "dev"]
paths:
- "tests/e2e/**/*.spec.ts"
- "src/wallets/**/actions/**/*.ts"
permissions:
contents: read
jobs:
test:
if: github.repository == 'amaify/chainwright'
runs-on: ubuntu-22.04
timeout-minutes: 60
strategy:
matrix:
node-version: [24]
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
submodules: "recursive"
fetch-depth: 0
- name: Determine changed test files
if: github.event_name != 'workflow_dispatch'
id: changed-tests
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE=${{ github.event.pull_request.base.sha }}
else
BASE=${{ github.event.before }}
fi
CHANGED=$(git diff --name-only "$BASE"...HEAD)
TEST_FILES=""
SPEC_FILES=$(echo "$CHANGED" | grep '^tests/e2e/.*\.spec\.ts$' || true)
if [ -n "$SPEC_FILES" ]; then
TEST_FILES="$SPEC_FILES"
fi
ACTION_FILES=$(echo "$CHANGED" | grep '^src/wallets/.*/actions/.*\.ts$' || true)
for action in $ACTION_FILES; do
wallet=$(echo "$action" | cut -d'/' -f3)
action_name=$(basename "$action" | sed "s/\.$wallet\.ts$//")
matched=$(find tests/e2e/"$wallet" -name "*${action_name}*${wallet}.spec.ts" 2>/dev/null || true)
if [ -n "$matched" ]; then
TEST_FILES=$(printf '%s\n%s' "$TEST_FILES" "$matched")
fi
done
TEST_FILES=$(echo "$TEST_FILES" | sort -u | sed '/^$/d')
echo "test_files<<EOF" >> "$GITHUB_OUTPUT"
echo "$TEST_FILES" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Install pnpm
uses: pnpm/setup@v2
with:
runtime: node@${{ matrix.node-version }}
version: 11
install: false
cache: true
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
- name: Install XVFB
run: sudo apt-get install -y xvfb
- name: Install Playwright browsers
run: pnpm exec playwright install chromium
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Initialize wallets
run: xvfb-run pnpm run setup-wallets
- name: Run all e2e tests (manual dispatch)
if: github.event_name == 'workflow_dispatch'
run: |
echo "Manual trigger - running full e2e suite"
xvfb-run pnpm playwright test --config=tests/playwright.config.ts
- name: Run changed e2e tests
if: github.event_name != 'workflow_dispatch' && steps.changed-tests.outputs.test_files != ''
run: |
echo "Running changed test files only:"
echo "${{ steps.changed-tests.outputs.test_files }}"
echo "${{ steps.changed-tests.outputs.test_files }}" | xargs xvfb-run pnpm playwright test --config=tests/playwright.config.ts
- name: Skip e2e tests (no relevant file changes)
if: github.event_name != 'workflow_dispatch' && steps.changed-tests.outputs.test_files == ''
run: echo "No relevant test files changed - skipping tests"
- name: Upload Playwright artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v7
with:
name: playwright-test-results
path: |
test-results/
tests/test-results/
retention-days: 4
if-no-files-found: ignore