Skip to content

Commit bfd77fd

Browse files
committed
fix: wip change html layout
1 parent b7e2425 commit bfd77fd

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

.github/scripts/extract_and_generate_html.sh

Lines changed: 41 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,10 @@ 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"
5287

5388
# Copy .html and .log files to the destination directory
5489
mkdir -p "${destination_dir}/$run"
@@ -67,7 +102,9 @@ for run in "${last_runs[@]}"; do
67102
done
68103

69104
# Replace {{CONTENT}} in the template with the generated content
70-
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+
71108

72109
# Close the HTML tags (if necessary)
73110
# No changes needed

.github/workflows/build-feature.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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: |

0 commit comments

Comments
 (0)