Skip to content

Selenium Test Framework #55

Selenium Test Framework

Selenium Test Framework #55

Workflow file for this run

name: Selenium Test Framework
on:
workflow_dispatch:
pull_request:
branches:
- master
- fb_*
push:
branches:
- master
- fb_*
schedule:
- cron: '0 0 * * *'
jobs:
build_and_test:
name: Build and Test
runs-on: ubuntu-latest
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: Cache Maven
uses: actions/cache@v4
with:
path: |
~/.m2/repository
target
key: maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-
- name: Build Project
run: |
mvn -B install -DskipTests --no-transfer-progress -T 4C
- name: Install Chrome
uses: browser-actions/setup-chrome@latest
- name: Install Firefox
uses: browser-actions/setup-firefox@latest
- name: Install Edge
uses: browser-actions/setup-edge@v1
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: target-${{ matrix.browser }} # Unique artifact name
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-${{ matrix.browser }} # Match the unique artifact name
- name: Run Tests for ${{ matrix.browser }}
run: |
mvn clean test -Drunmode=headless -Dbrowser=${{ matrix.browser }} \
-Dgroups=SAUCE_LABS_SMOKE \
-Dthreads=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-${{ matrix.browser }} # Match the unique artifact name
- name: Run Tests for ${{ matrix.browser }}
run: |
mvn clean test -Drunmode=headless -Dbrowser=${{ matrix.browser }} \
-Dgroups=SAUCE_LABS_REGRESSION \
-Dthreads=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\"
}"