Changes in LoginTest #28
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: Selenium TestNG CI | |
# | |
#on: | |
# push: | |
# branches: | |
# - main | |
# pull_request: | |
# branches: | |
# - main | |
# | |
#jobs: | |
# build: | |
# runs-on: ubuntu-latest | |
# | |
# steps: | |
# # Step 1: Checkout the code | |
# - name: Checkout repository | |
# uses: actions/checkout@v2 | |
# | |
# # Step 2: Set up Java environment | |
# - name: Set up JDK 11 | |
# uses: actions/setup-java@v2 | |
# with: | |
# distribution: 'adopt' | |
# java-version: '11' | |
# | |
# # 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: Run TestNG tests | |
# - name: Run TestNG tests | |
# run: mvn test | |
# | |
# # Step 6: Generate Extent Reports (optional) | |
# - name: Upload TestNG Extent Reports | |
# uses: actions/upload-artifact@v2 | |
# with: | |
# name: extent-reports | |
# path: target/extent-reports/ # Adjust this path to your reports folder | |
#name: Selenium TestNG CI | |
# | |
#on: | |
# push: | |
# branches: | |
# - main | |
# pull_request: | |
# branches: | |
# - main | |
# | |
#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 (Ensure you are using Java 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: Run TestNG tests | |
# - name: Run TestNG tests | |
# run: mvn test | |
# | |
# # Step 6: Upload Extent Reports | |
# - name: Upload TestNG Extent Reports | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: extent-reports | |
# path: Reports | |
name: Selenium TestNG CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
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 (Ensure you are using Java 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: Run TestNG tests | |
- name: Run TestNG tests | |
run: mvn test | |
# Step 6: Create a zip file of the reports | |
- name: Zip Reports | |
run: zip -r reports.zip Reports/ | |
# Step: Commit logs and reports | |
- name: Commit logs and reports | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add logs/ reports/ | |
git commit -m "Update logs and reports" || echo "No changes to commit" | |
git push origin main | |
# Step 7: Send email with TestNG Extent Reports (Runs on both success and failure) | |
- name: Send email with TestNG 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 }} # Set up as a secret in GitHub | |
password: ${{ secrets.EMAIL_PASSWORD }} # Set up as a secret in GitHub | |
subject: "TestNG Automation Report - Build ${{ github.run_number }}: ${{ job.status }}" | |
body: | | |
Hello, | |
The TestNG Automation build ${{ github.run_number }} has completed with status: **${{ job.status }}**. | |
Please find the attached Extent Reports. | |
Regards, | |
CI System | |
to: "[email protected], [email protected], [email protected]" # Replace with actual recipient emails | |
from: CI System <[email protected]> | |
attachments: reports.zip # Attach the zip file | |
# # Step 6: Upload TestNG Extent Reports | |
# - name: Upload TestNG Extent Reports | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: extent-reports | |
# path: Reports | |
# | |
# # Step 7: Set up report file paths | |
# - name: Prepare report file paths | |
# id: report-files | |
# run: | | |
# echo "REPORT_FILES<<EOF" >> $GITHUB_ENV | |
# for file in Reports/*; do | |
# echo "$file" >> $GITHUB_ENV | |
# done | |
# echo "EOF" >> $GITHUB_ENV | |
# | |
# # Step 8: Send email with TestNG Extent Reports (Runs on both success and failure) | |
# - name: Send email with TestNG 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 }} # Set up as a secret in GitHub | |
# password: ${{ secrets.EMAIL_PASSWORD }} # Set up as a secret in GitHub | |
# subject: "TestNG Automation Report - Build ${{ github.run_number }}: ${{ job.status }}" | |
# body: | | |
# Hello, | |
# | |
# The TestNG Automation build ${{ github.run_number }} has completed with status: **${{ job.status }}**. | |
# | |
# Please find the attached Extent Reports. | |
# | |
# Regards, | |
# CI System | |
# to: "[email protected], [email protected], [email protected]" # Replace with actual recipient emails | |
# from: CI System <[email protected]> | |
# attachments: ${{ env.REPORT_FILES }} # Attach individual report files | |
# | |
# | |
# # Step 6: Upload TestNG Extent Reports | |
# - name: Upload TestNG Extent Reports | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: extent-reports | |
# path: Reports/** # Ensure this path matches the actual path of the Extent Report | |
# | |
# # Step 7: Send email with TestNG Extent Reports (Runs on both success and failure) | |
# - name: Send email with TestNG 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 }} # Set up as a secret in GitHub | |
# password: ${{ secrets.EMAIL_PASSWORD }} # Set up as a secret in GitHub | |
# subject: "TestNG Automation Report - Build ${{ github.run_number }}: ${{ job.status }}" | |
# body: | | |
# Hello, | |
# | |
# The Automation build ${{ github.run_number }} has completed with status: **${{ job.status }}**. | |
# | |
# Please find the attached Extent Reports. | |
# | |
# Regards, | |
# Amol K | |
# to: [email protected], [email protected] # Replace with actual recipient email | |
# from: CI System <[email protected]> | |
# attachments: Reports/TestSuite.html # Ensure this is the correct path to the report file | |