Skip to content

Cucumber-JUnit CI

Cucumber-JUnit CI #72

Workflow file for this run

name: Cucumber-JUnit CI
on:
push:
branches:
- main
schedule:
# Schedule to run every day at 5 AM Indian time (IST)
- cron: '30 23 * * *' # 5:00 AM IST = 11:30 PM UTC
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the code
- name: Checkout repository
uses: actions/checkout@v2
# Step 2: Set up JDK 16
- name: Set up JDK 16
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '16'
# Step 3: Cache Maven dependencies for faster builds
- name: Cache Maven dependencies
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Step 4: Install Maven dependencies
- name: Install dependencies
run: mvn install -DskipTests
# Step 5: Clean Temporary Reports Directory
- name: Clean Temp Reports Directory
run: |
if [ -d "/tmp/reports" ]; then
rm -rf /tmp/reports/*
echo "Old temporary reports cleaned."
else
mkdir -p /tmp/reports/cucumber
echo "Created temporary cucumber reports directory."
fi
# Step 6: Set up Chrome for headless testing
- name: Set up Chrome
uses: browser-actions/setup-chrome@v1
# Step 7: Run Cucumber tests
- name: Run Cucumber tests with JUnit
run: mvn test
# Step 8: Generate Extent Reports
- name: Generate Extent Reports
run: mvn site -DreportOutputDirectory=/tmp/reports/cucumber/
# Step 9: Upload Extent Reports as artifacts
- name: Upload Extent Report
if: always()
uses: actions/upload-artifact@v3
with:
name: cucumber-extent-report
path: /tmp/reports/cucumber/*.html
# Step 10: Send email with Extent Reports attached
- name: Send email with Extent Reports
if: always() # Ensure this step runs whether the build succeeds or fails
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{ secrets.EMAIL_USERNAME }}
password: ${{ secrets.EMAIL_PASSWORD }}
subject: "Cucumber Extent Report - Build ${{ github.run_number }}: ${{ job.status }}"
body: |
Hello,
The UI Automation build ${{ github.run_number }} has completed with status: **${{ job.status }}**.
Please find the attached Cucumber Extent Reports or view them at the deployed location.
to: [email protected], [email protected], [email protected]
from: CI System <[email protected]>
attachments: |
/tmp/reports/cucumber/*.html