Skip to content

Commit 40dbcce

Browse files
authored
Testing the workflow added for end to end tests (#28)
1 parent 40c0441 commit 40dbcce

3 files changed

Lines changed: 68 additions & 30 deletions

File tree

.github/workflows/e2e-tests.yml

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: e2e tests
22

33
on:
4-
# Nightly workflow - Run E2E tests on a schedule
4+
# Nightly workflow - Run at 2 AM UTC daily
55
schedule:
6-
- cron: '0 2 * * *' # Run at 2 AM UTC daily
6+
- cron: '0 2 * * *'
77
# Post-merge - Run after changes are merged to main
88
push:
99
branches: [main]
@@ -30,31 +30,14 @@ on:
3030
description: 'SFCC Sandbox API Host (optional, defaults to var)'
3131
required: false
3232
type: string
33-
node_version:
34-
description: 'Node.js version to test with'
35-
required: false
36-
default: 'lts/*'
37-
type: choice
38-
options:
39-
- 'lts/-1'
40-
- 'lts/*'
41-
- 'latest'
42-
os:
43-
description: 'Operating system to test on'
44-
required: false
45-
default: 'ubuntu-latest'
46-
type: choice
47-
options:
48-
- 'ubuntu-latest'
49-
- 'windows-latest'
5033
jobs:
5134
e2e-tests:
5235
strategy:
5336
matrix:
54-
node_version: [22.x, 24.x]
37+
node-version: [22.x, 24.x]
5538
runs-on: ubuntu-latest
5639
environment: e2e-dev
57-
timeout-minutes: 10 # E2E tests can take longer
40+
timeout-minutes: 25
5841
steps:
5942
- uses: actions/checkout@v4
6043
- uses: actions/setup-node@v4
@@ -69,11 +52,11 @@ jobs:
6952
SFCC_ACCOUNT_MANAGER_HOST: ${{ vars.SFCC_ACCOUNT_MANAGER_HOST }}
7053
SFCC_SANDBOX_API_HOST: ${{ vars.SFCC_SANDBOX_API_HOST }}
7154
run: |
72-
if [ -n "$SFCC_CLIENT_ID" ] && [ -n "$SFCC_CLIENT_SECRET" ] && [ -n "$TEST_REALM" ] && [ -n "SFCC_ACCOUNT_MANAGER_HOST" ] && [ -n "SFCC_SANDBOX_API_HOST" ]; then
55+
if [ -n "$SFCC_CLIENT_ID" ] && [ -n "$SFCC_CLIENT_SECRET" ] && [ -n "$TEST_REALM" ] && [ -n "$SFCC_ACCOUNT_MANAGER_HOST" ] && [ -n "$SFCC_SANDBOX_API_HOST" ]; then
7356
echo "has-secrets=true" >> $GITHUB_OUTPUT
7457
else
7558
echo "has-secrets=false" >> $GITHUB_OUTPUT
76-
echo "E2E tests skipped - missing required variables:" >> $GITHUB_STEP_SUMMARY
59+
echo " E2E tests skipped - missing required variables:" >> $GITHUB_STEP_SUMMARY
7760
echo " - SFCC_CLIENT_ID (var): ${SFCC_CLIENT_ID:+✓}" >> $GITHUB_STEP_SUMMARY
7861
echo " - TEST_REALM (var): ${TEST_REALM:+✓}" >> $GITHUB_STEP_SUMMARY
7962
echo " - SFCC_ACCOUNT_MANAGER_HOST (var): ${SFCC_ACCOUNT_MANAGER_HOST:+✓}" >> $GITHUB_STEP_SUMMARY
@@ -106,8 +89,9 @@ jobs:
10689
- name: Run E2E Tests
10790
if: steps.check-secrets.outputs.has-secrets == 'true'
10891
id: e2e-test
92+
working-directory: packages/b2c-cli
10993
env:
110-
# Required environment variables for Commerce Cloud integration
94+
# Required environment variables
11195
SFCC_CLIENT_ID: ${{ inputs.sfcc_client_id || vars.SFCC_CLIENT_ID }}
11296
SFCC_CLIENT_SECRET: ${{ inputs.sfcc_client_secret || secrets.SFCC_CLIENT_SECRET }}
11397
SFCC_ACCOUNT_MANAGER_HOST: ${{ inputs.sfcc_account_manager_host || vars.SFCC_ACCOUNT_MANAGER_HOST }}
@@ -118,6 +102,52 @@ jobs:
118102
SFCC_LOG_LEVEL: silent
119103
run: |
120104
echo "Running E2E tests with realm: ${TEST_REALM}"
105+
echo "Node version: $(node --version)"
121106
122-
# Run E2E tests with JSON output for parsing
123-
pnpm --filter @salesforce/b2c-cli run test:e2e
107+
# Run E2E tests with JSON reporter for test results
108+
pnpm run test:e2e && pnpm run lint
109+
110+
- name: E2E Test Report
111+
uses: dorny/test-reporter@fe45e9537387dac839af0d33ba56eed8e24189e8 # v2.3.0
112+
if: always() && steps.e2e-test.conclusion != 'cancelled' && steps.check-secrets.outputs.has-secrets == 'true'
113+
with:
114+
name: E2E Test Results (Node ${{ matrix.node-version }})
115+
path: 'packages/b2c-cli/test-results.json'
116+
reporter: mocha-json
117+
118+
- name: Upload E2E Test Results
119+
if: always() && steps.e2e-test.conclusion != 'cancelled' && steps.check-secrets.outputs.has-secrets == 'true'
120+
uses: actions/upload-artifact@v4
121+
with:
122+
name: e2e-test-results-node-${{ matrix.node-version }}-${{ github.run_number }}
123+
path: packages/b2c-cli/test-results.json
124+
retention-days: 30
125+
126+
- name: Notify on Failure
127+
if: failure() && (github.event_name == 'schedule' || github.event_name == 'push') && steps.check-secrets.outputs.has-secrets == 'true'
128+
uses: actions/github-script@v7
129+
with:
130+
script: |
131+
const issue = {
132+
owner: context.repo.owner,
133+
repo: context.repo.repo,
134+
title: `CLI E2E Tests Failed - ${new Date().toISOString().split('T')[0]}`,
135+
body: `## CLI E2E Test Failure
136+
137+
The CLI E2E tests have failed. Please investigate.
138+
139+
**Workflow:** ${context.workflow}
140+
**Run:** ${context.runNumber}
141+
**Commit:** ${context.sha}
142+
**Event:** ${context.eventName}
143+
**Node Version:** ${{ matrix.node-version }}
144+
145+
[View workflow run](${context.payload.repository.html_url}/actions/runs/${context.runId})
146+
`,
147+
labels: ['bug', 'e2e-failure', 'cli', 'needs-investigation']
148+
};
149+
150+
// Only create issue for scheduled runs to avoid spam
151+
if (context.eventName === 'schedule') {
152+
github.rest.issues.create(issue);
153+
}

packages/b2c-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
"test": "c8 env OCLIF_TEST_ROOT=. mocha --forbid-only --exclude \"test/functional/e2e/**\" \"test/**/*.test.ts\"",
132132
"test:ci": "c8 env OCLIF_TEST_ROOT=. mocha --forbid-only --exclude \"test/functional/e2e/**\" --reporter json --reporter-option output=test-results.json \"test/**/*.test.ts\"",
133133
"test:unit": "env OCLIF_TEST_ROOT=. mocha --forbid-only --exclude \"test/functional/e2e/**\" \"test/**/*.test.ts\"",
134-
"test:e2e": "env OCLIF_TEST_ROOT=. mocha --forbid-only \"test/functional/e2e/**/*.test.ts\"",
134+
"test:e2e": "env OCLIF_TEST_ROOT=. mocha --forbid-only --reporter json --reporter-option output=test-results.json \"test/functional/e2e/**/*.test.ts\"",
135135
"coverage": "c8 report",
136136
"version": "oclif readme && git add README.md",
137137
"dev": "node ./bin/dev.js"

packages/b2c-cli/test/functional/e2e/ods-lifecycle.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ const __dirname = path.dirname(__filename);
2727
*/
2828
describe('ODS Lifecycle E2E Tests', function () {
2929
// Timeout for entire test suite
30-
this.timeout(360_000); // 6 minutes
30+
this.timeout(900_000); // 15 minutes
31+
32+
// Retry transient failures up to 2 times
33+
this.retries(2);
3134

3235
// Test configuration (paths)
3336
const CLI_BIN = path.resolve(__dirname, '../../../bin/run.js');
@@ -74,8 +77,10 @@ describe('ODS Lifecycle E2E Tests', function () {
7477

7578
describe('Step 1: Create Sandbox', function () {
7679
it('should create a new sandbox with permissions and wait for readiness', async function () {
77-
// --wait can take 5-10 minutes, so increase timeout for this test
78-
this.timeout(600_000); // 6 minutes
80+
this.timeout(720_000); // 12 minutes
81+
82+
// Retry up to 3 times for transient failures (API timing issues, rate limits, etc.)
83+
this.retries(3);
7984

8085
const result = await runCLI([
8186
'ods',
@@ -136,6 +141,9 @@ describe('ODS Lifecycle E2E Tests', function () {
136141

137142
describe('Step 3: Deploy Code', function () {
138143
it('should deploy test cartridge to the sandbox', async function () {
144+
// Retry for transient network/deployment issues
145+
this.retries(2);
146+
139147
// Skip deploy if we don't have a valid sandbox
140148
if (!sandboxId || !serverHostname) {
141149
this.skip();

0 commit comments

Comments
 (0)