Skip to content

Commit e3f2979

Browse files
committed
fix: wip change html layout
1 parent 2ec161c commit e3f2979

File tree

2 files changed

+54
-11
lines changed

2 files changed

+54
-11
lines changed

.github/scripts/extract_and_generate_html.sh

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,40 @@ copy_js_and_css() {
1313

1414
# Function to perform replacements in HTML files
1515
replace_in_html_files() {
16-
search=$1
17-
replace=$2
18-
find "${destination_dir}/${3}" -type f -name "*.html" -exec sed -i "" -e "s|$search|$replace|g" {} \;
16+
search="$1"
17+
replace="$2"
18+
directory="$3"
19+
find "${destination_dir}/${directory}" -type f -name "*.html" -exec sed -i -e "s|$search|$replace|g" {} \;
20+
}
21+
22+
# Fonction pour extraire et formater les résultats
23+
generate_html_table() {
24+
run="$1"
25+
stats_file="./loading/target/gatling/$run/js/stats.json"
26+
27+
# Extraire les données nécessaires du fichier JSON avec jq
28+
tableContent=$(jq -r '
29+
(.contents[] | "
30+
<tr>
31+
<th>" + .stats.name + "</th>
32+
<th>" + (.stats.numberOfRequests.ok | tostring) + "</th>
33+
<th>" + (.stats.numberOfRequests.ko | tostring) + "</th>
34+
<th>" + (.stats.minResponseTime.total | tostring) + "</th>
35+
<th>" + (.stats.maxResponseTime.total | tostring) + "</th>
36+
<th>" + (.stats.meanResponseTime.total | tostring) + "</th>
37+
<th>" + (.stats.standardDeviation.total | tostring) + "</th>
38+
<th>" + (.stats.meanNumberOfRequestsPerSecond.total | tostring) + "</th>
39+
</tr>"
40+
)' "$stats_file")
41+
42+
# Créer le tableau HTML
43+
htmlTable="<table>
44+
<tr><th>Request</th><th>Success ✅</th><th>Errors ❌</th><th>Min</th><th>Max</th><th>Avg.</th><th>Std. Dev.</th><th>RPS</th></tr>
45+
$tableContent
46+
</table>"
47+
48+
# Imprimer le contenu HTML
49+
echo "$htmlTable"
1950
}
2051

2152
# Read the contents of lastRun.txt and sort it
@@ -49,6 +80,11 @@ for run in "${last_runs[@]}"; do
4980
# Construct the desired output
5081
content+=" <li><h2>Results for <a href='./$run/index.html'>$report_name</a> at $formatted_date</h2></li>"
5182

83+
html_output=$(generate_html_table ${run})
84+
85+
# Append le contenu de la table à la variable content
86+
content+="$html_output"
87+
5288
# Copy .html and .log files to the destination directory
5389
mkdir -p "${destination_dir}/$run"
5490
cp -rf "./loading/target/gatling/$run"/* "${destination_dir}/$run"
@@ -66,7 +102,9 @@ for run in "${last_runs[@]}"; do
66102
done
67103

68104
# Replace {{CONTENT}} in the template with the generated content
69-
sed -i "s|{{CONTENT}}|$content|g" "$output_file"
105+
# sed -i "s|{{CONTENT}}|$content|g" "$output_file"
106+
sed -i -e "/{{CONTENT}}/r /dev/stdin" "$output_file" <<< "$content"
107+
70108

71109
# Close the HTML tags (if necessary)
72110
# No changes needed

.github/workflows/build-feature.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ jobs:
123123
# Create a "doc" directory and move karate reports to it
124124
- name: Get report
125125
run: |
126-
mkdir -p doc
127-
mv ./nrt/target/karate-reports/* ./doc
126+
mkdir -p doc/karate
127+
mv ./nrt/target/karate-reports/* ./doc/karate
128128
129129
- uses: actions/upload-artifact@master
130130
with:
131-
name: karate
131+
name: karate-reports
132132
path: doc/karate
133133
# - name: Upload artifact
134134
# uses: actions/upload-pages-artifact@v1
@@ -157,6 +157,12 @@ jobs:
157157
run: |
158158
mvn clean gatling:test --f loading/pom.xml
159159
160+
- name: Install jq
161+
run: |
162+
sudo apt-get update -y
163+
sudo apt-get install jq -y
164+
shell: bash
165+
160166
# New step to generate gatling-summary.html
161167
- name: Generate gatling-summary HTML
162168
run: |
@@ -165,7 +171,7 @@ jobs:
165171

166172
- uses: actions/upload-artifact@master
167173
with:
168-
name: gatling
174+
name: gatling-reports
169175
path: doc/gatling
170176

171177
# - name: Upload artifact
@@ -220,7 +226,6 @@ jobs:
220226
.addQuote('All times are in millisecond (ms). RPS means "Requests per Second"')
221227
.write()
222228
}
223-
224229
225230
deploy_reports:
226231
name: Deploy Reports
@@ -235,13 +240,13 @@ jobs:
235240
- name: Retrieve saved Non Regression Test
236241
uses: actions/download-artifact@v3
237242
with:
238-
name: karate
243+
name: karate-reports
239244
path: doc/karate
240245

241246
- name: Retrieve saved Loading Test
242247
uses: actions/download-artifact@v3
243248
with:
244-
name: gatling
249+
name: gatling-reports
245250
path: doc/gatling
246251

247252
- name: Upload artifact

0 commit comments

Comments
 (0)