GitHub Actions Workflow

Tests on Every Pull Request

Example

The ubuntu runner already has Chrome installed; Selenium Manager downloads the matching driver.

.github/workflows/ui-tests.yml

name: UI Tests

on:
  pull_request:
    branches: [main]
  workflow_dispatch:
    inputs:
      suite:
        description: "TestNG suite file"
        default: "testng-smoke.xml"

jobs:
  ui-tests:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: "21"
          cache: maven

      - name: Run tests
        run: >
          mvn -B clean test
          -DsuiteXml=${{ github.event.inputs.suite || 'testng-smoke.xml' }}
          -Denv=qa -Dheadless=true
        env:
          SHOPEASE_ADMIN_PASSWORD: ${{ secrets.SHOPEASE_ADMIN_PASSWORD }}

      - name: Upload reports
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: test-reports
          path: |
            target/extent/
            target/screenshots/
            target/surefire-reports/

What the Log Shows

Example

Run tests (GitHub Actions log)

Example output

Run mvn -B clean test -DsuiteXml=testng-smoke.xml -Denv=qa -Dheadless=true
[INFO] Scanning for projects...
[INFO] Building shopease-ui-tests 1.0.0
[INFO] --- surefire:3.5.1:test (default-test) @ shopease-ui-tests ---
[INFO] Running TestSuite
[INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 52.07 s
[INFO] BUILD SUCCESS
[INFO] Total time:  01:21 min
Upload reports: Artifact test-reports has been successfully uploaded! Final size is 1.4 MB

Tip: if: always() uploads the report even when tests failed, which is exactly when you need it.