This repository has been archived by the owner on Jan 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaction.yaml
75 lines (70 loc) · 2.9 KB
/
action.yaml
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
name: run-gatling
description: Runs a Gatling test suite
inputs:
javaVersion:
description: "Java version to use"
default: "17"
required: true
javaDistribution:
description: "Java distribution to use"
default: "microsoft"
required: true
pomPath:
description: "Path to the Gatling Test Suite's pom.xml file"
default: "test"
required: true
simulationClass:
description: "Full classpath of the simulation to run"
required: false
runs:
using: "composite"
steps:
- name: Execute Gatling Test Suite
uses: actions/setup-java@v3
with:
distribution: ${{ inputs.javaDistribution }}
java-version: ${{ inputs.javaVersion }}
- run: mvn -f $GITHUB_WORKSPACE/${{ inputs.pomPath }} gatling:test ${{ inputs.simulationClass != '' && '-Dgatling.simulationClass=' || '' }}${{ inputs.simulationClass }}
shell: bash
- name: Generate Job Summary
uses: actions/github-script@v6
env:
TEST_PATH: ${{ inputs.pomPath }}
with:
script: |
const fs = require('fs')
const pomPath = process.env.TEST_PATH
const lastRuns = fs.readFileSync(`${pomPath}/target/gatling/lastRun.txt`).toString().trim().split('\n');
for(const run of lastRuns) {
const results = JSON.parse(fs.readFileSync(`${pomPath}/target/gatling/${run}/js/stats.json`).toString());
let tableContent = [
[
{data: 'Request', header: true},
{data: 'Success ✅', header: true},
{data: 'Errors ❌', header: true},
{data: 'Min', header: true},
{data: 'Max', header: true},
{data: 'Avg.', header: true},
{data: 'Std. Dev.', header: true},
{data: 'RPS', header: true},
]
];
for(const result in results.contents) {
const requestMetrics = results.contents[result].stats;
tableContent.push([
requestMetrics.name,
requestMetrics.numberOfRequests.ok.toString(),
requestMetrics.numberOfRequests.ko.toString(),
requestMetrics.minResponseTime.total.toString(),
requestMetrics.maxResponseTime.total.toString(),
requestMetrics.meanResponseTime.total.toString(),
requestMetrics.standardDeviation.total.toString(),
requestMetrics.meanNumberOfRequestsPerSecond.total.toString(),
]);
}
await core.summary
.addHeading(`Results for ${run}`)
.addTable(tableContent)
.addQuote('All times are in millisecond (ms). RPS means "Requests per Second"')
.write()
}