Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

Commit

Permalink
feat: added generateReport.js, added steps in action.yaml for reporti…
Browse files Browse the repository at this point in the history
…ng (#3)

* feat: added generateReport.js, added steps in action.yaml for reporting

* fix: modified job summary step

* chore: fixed indent

* fix: modified download-gatling-report step

* fix: modified Generate CSV report step, added env var

* fix: changed url for gatling-report

* fix: removed trailing )

* fix: downloading v6.0

* refactor: removed gatling-report, using gatling json files

* fix: added @actions/core in package.json

* feat: added compiled index.js

* feat: looping through results

* fix: indent

* fix: added condition to avoid empty newlines in file

* fix: removed package-lock.json, added yarn.lock, added tunnel to dependencies

* feat: attempt at writing summary

* fix: added async keyword before generateTestResults

* feat: added metrics to table

* refactor: added checkmark and 'x' for success/errors

* refactor: using core.getInput for testPath

* fix: assigning testPath in script block rather than index.js

* fix: using env var instead of core.getInput
  • Loading branch information
anthonygauthier committed May 19, 2022
1 parent 768b071 commit 9b60857
Show file tree
Hide file tree
Showing 6 changed files with 3,378 additions and 10,284 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
node_modules/
dist/
17 changes: 16 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ inputs:
required: true
testPath:
description: "Path to the Gatling Test Suite"
default: "./test/"
default: "./test"
required: true
repoName:
description: "Name of the repository to checkout ('org/repo')"
Expand All @@ -38,3 +38,18 @@ runs:
java-version: ${{ inputs.javaVersion }}
- run: mvn -f ${{ inputs.testPath }} gatling:test ${{ inputs.simulationClass != '' && '-Dgatling.simulationClass=' || '' }}${{ inputs.simulationClass }}
shell: bash

- uses: actions/setup-node@v3
with:
node-version: '16'
- run: yarn install && yarn run build
shell: bash

- name: Generate Job Summary
uses: actions/github-script@v6
env:
TEST_PATH: ${{ inputs.testPath }}
with:
script: |
const script = require('./dist/index.js')
await script({github, context, core})
42 changes: 42 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const fs = require('fs');

module.exports = async ({github, context, core}) => {
const testPath = process.env.TEST_PATH
const lastRuns = fs.readFileSync(`${testPath}/target/gatling/lastRun.txt`).toString().trim().split('\n');

for(const run of lastRuns) {
const results = JSON.parse(fs.readFileSync(`${testPath}/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()
}
}
Loading

0 comments on commit 9b60857

Please sign in to comment.