e2e tests #7
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: e2e tests | |
| on: | |
| # Nightly workflow - Run E2E tests on a schedule | |
| schedule: | |
| - cron: '0 2 * * *' # Run at 2 AM UTC daily | |
| # Post-merge - Run after changes are merged to main | |
| push: | |
| branches: [main] | |
| # 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 | |
| node_version: | |
| description: 'Node.js version to test with' | |
| required: false | |
| default: 'lts/*' | |
| type: choice | |
| options: | |
| - 'lts/-1' | |
| - 'lts/*' | |
| - 'latest' | |
| os: | |
| description: 'Operating system to test on' | |
| required: false | |
| default: 'ubuntu-latest' | |
| type: choice | |
| options: | |
| - 'ubuntu-latest' | |
| - 'windows-latest' | |
| jobs: | |
| e2e-tests: | |
| strategy: | |
| matrix: | |
| node_version: [22.x, 24.x] | |
| runs-on: ubuntu-latest | |
| environment: e2e-dev | |
| timeout-minutes: 10 # E2E tests can take longer | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| 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 }} | |
| run: | | |
| if [ -n "$SFCC_CLIENT_ID" ] && [ -n "$SFCC_CLIENT_SECRET" ] && [ -n "$TEST_REALM" ] && [ -n "SFCC_ACCOUNT_MANAGER_HOST" ] && [ -n "SFCC_SANDBOX_API_HOST" ]; 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 | |
| fi | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10.17.1 | |
| - 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 | |
| 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 | |
| env: | |
| # Required environment variables for Commerce Cloud integration | |
| 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 }} | |
| # Test configuration | |
| NODE_ENV: test | |
| SFCC_LOG_LEVEL: silent | |
| run: | | |
| echo "Running E2E tests with realm: ${TEST_REALM}" | |
| # Run E2E tests with JSON output for parsing | |
| pnpm --filter @salesforce/b2c-cli run test:e2e |