Playwright Test Framework #127
This file contains 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: Playwright Test Framework | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- master | |
- issue-* | |
- fb_* | |
push: | |
branches: | |
- master | |
- issue-* | |
- fb_* | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
build_and_test: | |
name: Build and Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Java and Maven | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
cache: maven | |
- name: Install Browsers | |
uses: browser-actions/setup-chrome@latest | |
- uses: browser-actions/setup-firefox@latest | |
- uses: browser-actions/setup-edge@latest | |
- name: Build Project | |
run: mvn clean install -DskipTests | |
- name: Run Unit Tests and Generate Coverage Report | |
run: mvn clean verify -Drunmode=headless -Dbrowser=chrome -Dgroups=SWAG_LABS_UNIT -Dtestng.parallel=methods -DthreadPoolSize=3 -Ddataproviderthreadcount=3 jacoco:report | |
- name: Upload Coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
slug: ${{ secrets.CODECOV_SLUG }} | |
verbose: true | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: target | |
path: | | |
${{ github.workspace }}/target | |
${{ github.workspace }}/reports | |
smoke_tests: | |
name: Run Smoke Tests | |
runs-on: ubuntu-latest | |
needs: build_and_test | |
strategy: | |
matrix: | |
browser: [ chrome, firefox, msedge ] | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Java and Maven | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
cache: maven | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: target | |
- name: Run Tests for ${{ matrix.browser }} | |
run: | | |
mvn clean test -Drunmode=headless -Dbrowser=${{ matrix.browser }} \ | |
-Dgroups=SWAG_LABS_SMOKE \ | |
-Dtestng.parallel=methods -DthreadPoolSize=3 -Ddataproviderthreadcount=3 | |
- name: Verify Report Directory | |
run: ls target/surefire-reports || echo "Report directory not found" | |
- name: Generate Test Summary | |
uses: test-summary/action@v2 | |
id: summary | |
with: | |
paths: "target/surefire-reports/TEST-*.xml" | |
if: always() | |
- name: Send Results to Discord | |
env: | |
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
run: | | |
# Gather metrics from test-summary output | |
passed="${{ steps.summary.outputs.passed }}" | |
failed="${{ steps.summary.outputs.failed }}" | |
skipped="${{ steps.summary.outputs.skipped }}" | |
total="${{ steps.summary.outputs.total }}" | |
pass_percentage=$(awk "BEGIN {print ($passed/$total)*100}") | |
fail_percentage=$(awk "BEGIN {print ($failed/$total)*100}") | |
content="-----------------------------------\n\n" | |
content+="🛠️ **Job: ${{ github.job }}**\n" | |
content+="👤 **User: ${{ github.actor }}**\n" | |
content+="🌎 **Browser: ${{ matrix.browser }}**\n" | |
content+="🎉 **Passed**: ${passed}\n" | |
content+="❌ **Failed**: ${failed}\n" | |
content+="⚠️ **Skipped**: ${skipped}\n" | |
content+="📊 **Total**: ${total}\n\n" | |
content+="✅ **Pass %**: ${pass_percentage}%\n" | |
content+="❌ **Fail %**: ${fail_percentage}%\n\n" | |
content+="-----------------------------------\n\n" | |
curl --location "$DISCORD_WEBHOOK_URL" \ | |
--header 'Content-Type: application/json' \ | |
--data-raw "{ | |
\"content\": \"$content\", | |
\"username\": \"TestBot\" | |
}" | |
regression_tests: | |
name: Run Regression Tests | |
runs-on: ubuntu-latest | |
needs: build_and_test | |
strategy: | |
matrix: | |
browser: [ chrome, firefox, msedge ] | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Java and Maven | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
cache: maven | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: target | |
- name: Run Tests for ${{ matrix.browser }} | |
run: | | |
mvn clean test -Drunmode=headless -Dbrowser=${{ matrix.browser }} \ | |
-Dgroups=SWAG_LABS_REGRESSION \ | |
-Dtestng.parallel=methods -DthreadPoolSize=3 -Ddataproviderthreadcount=3 | |
- name: Verify Report Directory | |
run: ls target/surefire-reports || echo "Report directory not found" | |
- name: Generate Test Summary | |
uses: test-summary/action@v2 | |
id: summary | |
with: | |
paths: "target/surefire-reports/TEST-*.xml" | |
if: always() | |
- name: Send Results to Discord | |
env: | |
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
run: | | |
# Gather metrics from test-summary output | |
passed="${{ steps.summary.outputs.passed }}" | |
failed="${{ steps.summary.outputs.failed }}" | |
skipped="${{ steps.summary.outputs.skipped }}" | |
total="${{ steps.summary.outputs.total }}" | |
pass_percentage=$(awk "BEGIN {print ($passed/$total)*100}") | |
fail_percentage=$(awk "BEGIN {print ($failed/$total)*100}") | |
content="-----------------------------------\n\n" | |
content+="🛠️ **Job: ${{ github.job }}**\n" | |
content+="👤 **User: ${{ github.actor }}**\n" | |
content+="🌎 **Browser: ${{ matrix.browser }}**\n" | |
content+="🎉 **Passed**: ${passed}\n" | |
content+="❌ **Failed**: ${failed}\n" | |
content+="⚠️ **Skipped**: ${skipped}\n" | |
content+="📊 **Total**: ${total}\n\n" | |
content+="✅ **Pass %**: ${pass_percentage}%\n" | |
content+="❌ **Fail %**: ${fail_percentage}%\n\n" | |
content+="-----------------------------------\n\n" | |
curl --location "$DISCORD_WEBHOOK_URL" \ | |
--header 'Content-Type: application/json' \ | |
--data-raw "{ | |
\"content\": \"$content\", | |
\"username\": \"TestBot\" | |
}" | |
e2e_tests: | |
name: E2E Tests | |
runs-on: ubuntu-latest | |
needs: | |
- build_and_test | |
- smoke_tests | |
- regression_tests | |
strategy: | |
matrix: | |
browser: [ chrome, firefox, msedge ] | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Java and Maven | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
cache: maven | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: target | |
- name: Run E2E Tests for ${{ matrix.browser }} | |
run: | | |
mvn clean test -Drunmode=headless -Dbrowser=${{ matrix.browser }} \ | |
-Dgroups=SWAG_LABS_E2E \ | |
-Dtestng.parallel=methods -DthreadPoolSize=3 -Ddataproviderthreadcount=3 | |
- name: Verify Report Directory | |
run: ls target/surefire-reports || echo "Report directory not found" | |
- name: Generate Test Summary | |
uses: test-summary/action@v2 | |
id: summary | |
with: | |
paths: "target/surefire-reports/TEST-*.xml" | |
if: always() | |
- name: Send Results to Discord | |
env: | |
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
run: | | |
# Gather metrics from test-summary output | |
passed="${{ steps.summary.outputs.passed }}" | |
failed="${{ steps.summary.outputs.failed }}" | |
skipped="${{ steps.summary.outputs.skipped }}" | |
total="${{ steps.summary.outputs.total }}" | |
pass_percentage=$(awk "BEGIN {print ($passed/$total)*100}") | |
fail_percentage=$(awk "BEGIN {print ($failed/$total)*100}") | |
content="-----------------------------------\n\n" | |
content+="🛠️ **Job: ${{ github.job }}**\n" | |
content+="👤 **User: ${{ github.actor }}**\n" | |
content+="🌎 **Browser: ${{ matrix.browser }}**\n" | |
content+="🎉 **Passed**: ${passed}\n" | |
content+="❌ **Failed**: ${failed}\n" | |
content+="⚠️ **Skipped**: ${skipped}\n" | |
content+="📊 **Total**: ${total}\n\n" | |
content+="✅ **Pass %**: ${pass_percentage}%\n" | |
content+="❌ **Fail %**: ${fail_percentage}%\n\n" | |
content+="-----------------------------------\n\n" | |
curl --location "$DISCORD_WEBHOOK_URL" \ | |
--header 'Content-Type: application/json' \ | |
--data-raw "{ | |
\"content\": \"$content\", | |
\"username\": \"TestBot\" | |
}" |