-
Notifications
You must be signed in to change notification settings - Fork 0
213 lines (194 loc) · 6.39 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#
#
## * * * * *
## | | | | |
## | | | | +---- Day of the week (0 - 7) (Sunday is both 0 and 7)
## | | | +------ Month (1 - 12)
## | | +-------- Day of the month (1 - 31)
## | +---------- Hour (0 - 23)
## +------------ Minute (0 - 59)
#
#
#
#
#name: Selenium TestNG CI
#
#on:
# push:
# branches:
# - main
# pull_request:
# branches:
# - main
# schedule:
# - cron: '30 23 * * *' # This will run every day at 5 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 (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: 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
# echo "Created temporary reports directory."
# fi
#
# # Step 6: Run UI-Automation tests with Chrome browser
## - name: Run UI-Automation tests with Chrome browser
## run: mvn test -Dthread=3 -Dlaunch=remote # Adjust as necessary for your project
#
#
# # Step 5: Run multiple UI-Automation tests with Chrome browser
# - name: Run UI-Automation tests
# run: |
# mvn test -DsuiteXmlFile=suite1.xml
# mvn test -DsuiteXmlFile=suite2.xml
# mvn test -DsuiteXmlFile=testng.xml
#
# # Step 7: Upload Extent Report from Temporary Directory
# - name: Upload Extent Report as Artifact
# if: always()
# uses: actions/upload-artifact@v3 # Updated to v3 to avoid deprecation
# with:
# name: extent-report
# path: /tmp/reports/*.html # Upload from the temporary directory
# if-no-files-found: warn
#
# # Step 8: Send email with Extent Reports
# - 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: "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 Extent Reports.
#
# Regards,
# CI System
# to: "[email protected], [email protected]"
# from: "CI System <${{ secrets.EMAIL_USERNAME }}>"
# attachments: /tmp/reports/*.html # Attach reports from the temporary directory
#
#
## * * * * *
## | | | | |
## | | | | +---- Day of the week (0 - 7) (Sunday is both 0 and 7)
## | | | +------ Month (1 - 12)
## | | +-------- Day of the month (1 - 31)
## | +---------- Hour (0 - 23)
## +------------ Minute (0 - 59)
#
#
#
#
name: Selenium TestNG CI
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule: # Trigger daily at 5 AM IST (23:00 UTC)
- cron: '0 23 * * *'
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
- 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: Create Reports Directories
- name: Create Reports Directories
run: |
mkdir -p /tmp/reports/suite1
mkdir -p /tmp/reports/suite2
mkdir -p /tmp/reports/testng
# Step 6: Run UI-Automation tests and save reports in separate directories
- name: Run UI-Automation tests
run: |
mvn test -DsuiteXmlFile=suite1.xml -Dtestng.output.dir=/tmp/reports/suite1
mvn test -DsuiteXmlFile=suite2.xml -Dtestng.output.dir=/tmp/reports/suite2
mvn test -DsuiteXmlFile=testng.xml -Dtestng.output.dir=/tmp/reports/testng
# Step 7: Upload all Extent Reports from the Temporary Directories
- name: Upload Extent Reports as Artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: extent-reports
path: /tmp/reports/**/*.html # Upload all HTML reports from all suite directories
if-no-files-found: warn
# Step 8: Send email with Extent Reports
- name: Send email with Extent Reports
if: always()
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{ secrets.EMAIL_USERNAME }}
password: ${{ secrets.EMAIL_PASSWORD }}
subject: "Extent Reports - 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 Extent Reports or view them at the deployed location.
Regards,
CI System
from: CI System <[email protected]>
attachments: /tmp/reports/**/*.html # Attach all generated HTML reports