-
Notifications
You must be signed in to change notification settings - Fork 10
200 lines (185 loc) · 7.94 KB
/
e2e-tests.yml
File metadata and controls
200 lines (185 loc) · 7.94 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: e2e tests
on:
# Scheduled workflow
# 13:00 UTC ~= 8:00 AM ET (EST)
# 01:00 UTC ~= 8:00 PM ET (EST)
schedule:
- cron: '0 13 * * *'
- cron: '0 1 * * *'
# Manual trigger - Support workflow_dispatch for on-demand runs
workflow_dispatch:
inputs:
test_realm:
description: 'Test realm to use (optional, defaults to var)'
required: false
type: string
sfcc_client_id:
description: 'SFCC Client ID (optional, defaults to var)'
required: false
type: string
sfcc_client_secret:
description: 'SFCC Client Secret (optional, defaults to secret)'
required: false
type: string
sfcc_account_manager_host:
description: 'SFCC Account Manager Host (optional, defaults to var)'
required: false
type: string
sfcc_sandbox_api_host:
description: 'SFCC Sandbox API Host (optional, defaults to var)'
required: false
type: string
env:
SFCC_DISABLE_TELEMETRY: ${{ vars.SFCC_DISABLE_TELEMETRY }}
jobs:
e2e-tests:
# E2E tests run only on the current LTS Node version for stability and speed.
strategy:
matrix:
node-version: [22.x]
runs-on: ubuntu-latest
environment: e2e-dev
timeout-minutes: 40
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- name: Check for required secrets and vars
id: check-secrets
env:
SFCC_CLIENT_ID: ${{ vars.SFCC_CLIENT_ID }}
SFCC_CLIENT_SECRET: ${{ secrets.SFCC_CLIENT_SECRET }}
TEST_REALM: ${{ vars.TEST_REALM }}
SFCC_ACCOUNT_MANAGER_HOST: ${{ vars.SFCC_ACCOUNT_MANAGER_HOST }}
SFCC_SANDBOX_API_HOST: ${{ vars.SFCC_SANDBOX_API_HOST }}
SFCC_SHORTCODE: ${{ vars.SFCC_SHORTCODE }}
SFCC_EXTRA_HEADERS: ${{ secrets.SFCC_EXTRA_HEADERS }}
SFCC_MRT_CLOUD_ORIGIN: ${{ vars.SFCC_MRT_CLOUD_ORIGIN }}
SFCC_MRT_API_KEY: ${{ secrets.SFCC_MRT_API_KEY }}
run: |
if [ -n "$SFCC_CLIENT_ID" ] && [ -n "$SFCC_CLIENT_SECRET" ] && [ -n "$TEST_REALM" ] && [ -n "$SFCC_ACCOUNT_MANAGER_HOST" ] && [ -n "$SFCC_SANDBOX_API_HOST" ] && [ -n "$SFCC_SHORTCODE" ]; then
echo "has-secrets=true" >> $GITHUB_OUTPUT
else
echo "has-secrets=false" >> $GITHUB_OUTPUT
echo " E2E tests skipped - missing required variables:" >> $GITHUB_STEP_SUMMARY
echo " - SFCC_CLIENT_ID (var): ${SFCC_CLIENT_ID:+✓}" >> $GITHUB_STEP_SUMMARY
echo " - TEST_REALM (var): ${TEST_REALM:+✓}" >> $GITHUB_STEP_SUMMARY
echo " - SFCC_ACCOUNT_MANAGER_HOST (var): ${SFCC_ACCOUNT_MANAGER_HOST:+✓}" >> $GITHUB_STEP_SUMMARY
echo " - SFCC_SANDBOX_API_HOST (var): ${SFCC_SANDBOX_API_HOST:+✓}" >> $GITHUB_STEP_SUMMARY
echo " - SFCC_SHORTCODE (var): ${SFCC_SHORTCODE:+✓}" >> $GITHUB_STEP_SUMMARY
echo " - SFCC_MRT_CLOUD_ORIGIN (var): ${SFCC_MRT_CLOUD_ORIGIN:+✓}" >> $GITHUB_STEP_SUMMARY
fi
- name: Setup pnpm
uses: pnpm/action-setup@v5
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v5
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
if: steps.check-secrets.outputs.has-secrets == 'true'
run: pnpm install --frozen-lockfile
- name: Build package
if: steps.check-secrets.outputs.has-secrets == 'true'
run: pnpm -r run build
- name: Run E2E Tests
if: steps.check-secrets.outputs.has-secrets == 'true'
id: e2e-test
working-directory: packages/b2c-cli
env:
# Required environment variables
SFCC_CLIENT_ID: ${{ inputs.sfcc_client_id || vars.SFCC_CLIENT_ID }}
SFCC_CLIENT_SECRET: ${{ inputs.sfcc_client_secret || secrets.SFCC_CLIENT_SECRET }}
SFCC_ACCOUNT_MANAGER_HOST: ${{ inputs.sfcc_account_manager_host || vars.SFCC_ACCOUNT_MANAGER_HOST }}
SFCC_SANDBOX_API_HOST: ${{ inputs.sfcc_sandbox_api_host || vars.SFCC_SANDBOX_API_HOST }}
TEST_REALM: ${{ inputs.test_realm || vars.TEST_REALM }}
SFCC_SHORTCODE: ${{ vars.SFCC_SHORTCODE }}
SFCC_EXTRA_HEADERS: ${{ secrets.SFCC_EXTRA_HEADERS }}
SFCC_MRT_CLOUD_ORIGIN: ${{ vars.SFCC_MRT_CLOUD_ORIGIN }}
SFCC_MRT_API_KEY: ${{ secrets.SFCC_MRT_API_KEY }}
# Test configuration
NODE_ENV: test
SFCC_LOG_LEVEL: silent
run: |
echo "Running E2E tests with realm: ${TEST_REALM}"
echo "Node version: $(node --version)"
# Run E2E tests with CI reporter (outputs test-results.json)
pnpm run test:e2e:ci && pnpm run lint
- name: E2E Test Report
uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0
if: always() && steps.e2e-test.conclusion != 'cancelled' && steps.check-secrets.outputs.has-secrets == 'true'
with:
name: E2E Test Results (Node ${{ matrix.node-version }})
path: 'packages/b2c-cli/test-results.json'
reporter: mocha-json
- name: Upload E2E Test Results
if: always() && steps.e2e-test.conclusion != 'cancelled' && steps.check-secrets.outputs.has-secrets == 'true'
uses: actions/upload-artifact@v7
with:
name: e2e-test-results-node-${{ matrix.node-version }}-${{ github.run_number }}
path: packages/b2c-cli/test-results.json
retention-days: 30
- name: Notify on Failure
if: failure() && github.event_name == 'schedule' && steps.check-secrets.outputs.has-secrets == 'true'
uses: actions/github-script@v8
with:
script: |
const issue = {
owner: context.repo.owner,
repo: context.repo.repo,
title: `CLI E2E Tests Failed - ${new Date().toISOString().split('T')[0]}`,
body: `## CLI E2E Test Failure
The CLI E2E tests have failed. Please investigate.
**Workflow:** ${context.workflow}
**Run:** ${context.runNumber}
**Commit:** ${context.sha}
**Event:** ${context.eventName}
**Node Version:** ${{ matrix.node-version }}
[View workflow run](${context.payload.repository.html_url}/actions/runs/${context.runId})
`,
labels: ['bug', 'e2e-failure', 'cli', 'needs-investigation']
};
// Only create issue for scheduled runs to avoid spam
if (context.eventName === 'schedule') {
github.rest.issues.create(issue);
}
mcp-e2e-tests:
name: MCP E2E
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '22.x'
- name: Setup pnpm
uses: pnpm/action-setup@v5
- name: Get pnpm store directory
id: pnpm-store
shell: bash
run: |
echo "store_path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v5
with:
path: ${{ steps.pnpm-store.outputs.store_path }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build packages
run: pnpm -r run build
- name: Run MCP E2E tests
working-directory: packages/b2c-dx-mcp
env:
SFCC_DISABLE_TELEMETRY: 'true'
NODE_ENV: test
run: pnpm run test:e2e:ci