|
| 1 | +name: Automation Test Workflow execution in Prod for Backcountry |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, develop] |
| 6 | + # Allows the workflow to be manually triggered from the GitHub Actions UI with user-defined input parameters. |
| 7 | + # The 'build_name' input is required, has a description for user guidance, and a default value of "Backcountry Prod Suite". |
| 8 | + workflow_dispatch: # Allows manual triggering of the workflow |
| 9 | + inputs: |
| 10 | + build_name: |
| 11 | + description: "Backcountry Prod Suite" |
| 12 | + required: true |
| 13 | + default: "Backcountry Prod Suite" |
| 14 | + |
| 15 | +jobs: |
| 16 | + test: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + env: |
| 19 | + LOCAL_IDENTIFIER: github-actions-tunnel |
| 20 | + |
| 21 | + steps: |
| 22 | + # Step 1: Checkout the repository |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + # Step 2: Set up Node.js |
| 27 | + - name: Set up Node.js |
| 28 | + uses: actions/setup-node@v4 |
| 29 | + with: |
| 30 | + node-version: "20" |
| 31 | + cache: "npm" |
| 32 | + |
| 33 | + # Step 3: Install dependencies |
| 34 | + - name: Install dependencies |
| 35 | + run: npm ci |
| 36 | + |
| 37 | + # Step 4: Install Playwright browsers |
| 38 | + - name: Install Playwright Browsers |
| 39 | + run: npx playwright install --with-deps chromium |
| 40 | + |
| 41 | + - name: "BrowserStack Env Setup" # Invokes the setup-env action |
| 42 | + uses: browserstack/[email protected] |
| 43 | + with: |
| 44 | + username: ${{ secrets.BROWSERSTACK_USERNAME }} |
| 45 | + access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} |
| 46 | + |
| 47 | + - name: "BrowserStack Local Tunnel Setup" # Invokes the setup-local action |
| 48 | + uses: browserstack/github-actions/setup-local@master |
| 49 | + with: |
| 50 | + local-testing: start |
| 51 | + local-logging-level: all-logs |
| 52 | + local-identifier: ${{ env.LOCAL_IDENTIFIER }} |
| 53 | + |
| 54 | + - name: Wait for tunnel |
| 55 | + run: sleep 10 |
| 56 | + |
| 57 | + # Step 5: Run Playwright tests with Cucumber |
| 58 | + - name: Run Playwright tests |
| 59 | + run: npx cucumber-js --tags "@BC_STAGE_01" |
| 60 | + env: |
| 61 | + BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} |
| 62 | + BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} |
| 63 | + BROWSERSTACK_LOCAL: "true" |
| 64 | + BROWSERSTACK_LOCAL_IDENTIFIER: ${{ env.LOCAL_IDENTIFIER }} |
| 65 | + BUILD_NAME: ${{ github.event.inputs.build_name || 'Backcountry Prod Suite - Scheduled' }} |
| 66 | + PROJECT_NAME: "BC Automation" |
| 67 | + BROWSER_NAME: chrome |
| 68 | + BROWSER_VERSION: latest |
| 69 | + OS_NAME: Windows |
| 70 | + OS_VERSION: "11" |
| 71 | + |
| 72 | + - name: Generate HTML Report |
| 73 | + if: always() |
| 74 | + run: npm run report |
| 75 | + |
| 76 | + - name: Upload Test Results |
| 77 | + if: always() |
| 78 | + uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: test-results-cc-prod-${{ github.run_number }} |
| 81 | + path: | |
| 82 | + test-results/ |
| 83 | + cucumber-report.html |
| 84 | + retention-days: 30 |
| 85 | + |
| 86 | + - name: Upload Screenshots |
| 87 | + if: failure() |
| 88 | + uses: actions/upload-artifact@v4 |
| 89 | + with: |
| 90 | + name: failed-screenshots-cc-prod-${{ github.run_number }} |
| 91 | + path: test-results/screenshots/ |
| 92 | + retention-days: 30 |
| 93 | + |
| 94 | + - name: Upload Videos |
| 95 | + if: failure() |
| 96 | + uses: actions/upload-artifact@v4 |
| 97 | + with: |
| 98 | + name: failed-videos-cc-prod-${{ github.run_number }} |
| 99 | + path: test-results/videos/ |
| 100 | + retention-days: 30 |
| 101 | + |
| 102 | + - name: "BrowserStackLocal Stop" # Terminating the BrowserStackLocal tunnel connection |
| 103 | + if: always() |
| 104 | + uses: browserstack/github-actions/setup-local@master |
| 105 | + with: |
| 106 | + local-testing: stop |
| 107 | + local-identifier: ${{ env.LOCAL_IDENTIFIER }} |
0 commit comments