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

Commit 6e7f165

Browse files
feat: changed testPath to pomPath (#9)
1 parent 4c7c76d commit 6e7f165

File tree

5 files changed

+61
-74
lines changed

5 files changed

+61
-74
lines changed

.github/workflows/test.yaml

+8-40
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,18 @@ env:
99
BRANCH_NAME: main
1010

1111
jobs:
12-
# test-local-folder:
13-
# runs-on: ubuntu-latest
14-
# steps:
15-
# - uses: actions/checkout@v3
16-
17-
# # Doing this here to simulate already having the test suite within the repo
18-
# - name: Checkout repo locally
19-
# uses: actions/checkout@v3
20-
# with:
21-
# repository: liatrio/gatling-maven-showcase
22-
# ref: ${{ env.BRANCH_NAME }}
23-
# path: ./test
24-
25-
# - name: Run Gatling Test Suite from local folder
26-
# uses: ./
27-
28-
test-with-repo:
12+
test-local-folder:
2913
runs-on: ubuntu-latest
3014
steps:
3115
- uses: actions/checkout@v3
3216

33-
- name: Run Gatling Test Suite from repository
34-
uses: ./
17+
# Doing this here to simulate already having the test suite within the repo
18+
- name: Checkout repo locally
19+
uses: actions/checkout@v3
3520
with:
36-
repoName: liatrio/gatling-maven-showcase
37-
repoRef: ${{ env.BRANCH_NAME }}
21+
repository: liatrio/gatling-maven-showcase
22+
ref: ${{ env.BRANCH_NAME }}
23+
path: test
3824

39-
test-specific-simulation:
40-
runs-on: ubuntu-latest
41-
steps:
42-
- uses: actions/checkout@v3
43-
44-
- name: Run a specific simulation of the Gatling Test Suite
25+
- name: Run Gatling Test Suite from local folder
4526
uses: ./
46-
with:
47-
repoName: liatrio/gatling-maven-showcase
48-
repoRef: ${{ env.BRANCH_NAME }}
49-
simulationClass: "simulations.GoogleStressSimulation"
50-
51-
testing-remote-action:
52-
runs-on: ubuntu-latest
53-
steps:
54-
- uses: liatrio/run-gatling@main
55-
with:
56-
repoName: liatrio/gatling-maven-showcase
57-
repoRef: ${{ env.BRANCH_NAME }}
58-
simulationClass: "simulations.GoogleStressSimulation"

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ This action tries to solve that exact problem by enabling development teams to t
1818
# Default: 'microsoft'
1919
javaDistribution: ''
2020

21-
# Path to the Gatling Test Suite
21+
# Path to the Gatling Test Suite's pom.xml file
2222
# Default: './test'
23-
testPath: ''
23+
pomPath: ''
2424

2525
# Name of the repository to checkout ('org/repo')
2626
# Default: ''
@@ -47,14 +47,14 @@ This action tries to solve that exact problem by enabling development teams to t
4747
```yaml
4848
- uses: liatrio/[email protected]
4949
with:
50-
testPath: my_test_suite/path
50+
pomPath: my_test_suite/path
5151
```
5252
5353
## Execute a specific simulation
5454
```yaml
5555
- uses: liatrio/[email protected]
5656
with:
57-
testPath: my_test_suite/path
57+
pomPath: my_test_suite/path
5858
simulationClass: simulationsPkg.MySimulationClass
5959
```
6060

action.yaml

+43-24
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,67 @@ inputs:
99
description: "Java distribution to use"
1010
default: "microsoft"
1111
required: true
12-
testPath:
13-
description: "Path to the Gatling Test Suite"
12+
pomPath:
13+
description: "Path to the Gatling Test Suite's pom.xml file"
1414
default: "test"
1515
required: true
16-
repoName:
17-
description: "Name of the repository to checkout ('org/repo')"
18-
required: false
19-
repoRef:
20-
description: "Tag, Branch, or Commit SHA for the Test Suite repository"
21-
default: "main"
22-
required: false
2316
simulationClass:
2417
description: "Full classpath of the simulation to run"
2518
required: false
2619
runs:
2720
using: "composite"
2821
steps:
29-
- name: Checkout action code
30-
uses: actions/checkout@v3
31-
32-
- name: Checkout Test Suite if not local
33-
if: ${{ !hashFiles(inputs.testPath) }}
34-
uses: actions/checkout@v3
35-
with:
36-
repository: ${{ inputs.repoName }}
37-
ref: ${{ inputs.repoRef }}
38-
path: ${{ inputs.testPath }}
39-
4022
- name: Execute Gatling Test Suite
4123
uses: actions/setup-java@v3
4224
with:
4325
distribution: ${{ inputs.javaDistribution }}
4426
java-version: ${{ inputs.javaVersion }}
4527

46-
- run: mvn -f $GITHUB_WORKSPACE/${{ inputs.testPath }} gatling:test ${{ inputs.simulationClass != '' && '-Dgatling.simulationClass=' || '' }}${{ inputs.simulationClass }}
28+
- run: mvn -f $GITHUB_WORKSPACE/${{ inputs.pomPath }} gatling:test ${{ inputs.simulationClass != '' && '-Dgatling.simulationClass=' || '' }}${{ inputs.simulationClass }}
4729
shell: bash
4830

4931
- name: Generate Job Summary
5032
uses: actions/github-script@v6
5133
env:
52-
TEST_PATH: ${{ inputs.testPath }}
34+
TEST_PATH: ${{ inputs.pomPath }}
5335
with:
5436
script: |
55-
const script = require(`${process.env.GITHUB_WORKSPACE}/dist/index.js`)
56-
await script({github, context, core})
37+
const fs = require('fs')
38+
const pomPath = process.env.TEST_PATH
39+
const lastRuns = fs.readFileSync(`${pomPath}/target/gatling/lastRun.txt`).toString().trim().split('\n');
40+
41+
for(const run of lastRuns) {
42+
const results = JSON.parse(fs.readFileSync(`${pomPath}/target/gatling/${run}/js/stats.json`).toString());
43+
let tableContent = [
44+
[
45+
{data: 'Request', header: true},
46+
{data: 'Success ✅', header: true},
47+
{data: 'Errors ❌', header: true},
48+
{data: 'Min', header: true},
49+
{data: 'Max', header: true},
50+
{data: 'Avg.', header: true},
51+
{data: 'Std. Dev.', header: true},
52+
{data: 'RPS', header: true},
53+
]
54+
];
55+
56+
for(const result in results.contents) {
57+
const requestMetrics = results.contents[result].stats;
58+
tableContent.push([
59+
requestMetrics.name,
60+
requestMetrics.numberOfRequests.ok.toString(),
61+
requestMetrics.numberOfRequests.ko.toString(),
62+
requestMetrics.minResponseTime.total.toString(),
63+
requestMetrics.maxResponseTime.total.toString(),
64+
requestMetrics.meanResponseTime.total.toString(),
65+
requestMetrics.standardDeviation.total.toString(),
66+
requestMetrics.meanNumberOfRequestsPerSecond.total.toString(),
67+
]);
68+
}
69+
70+
await core.summary
71+
.addHeading(`Results for ${run}`)
72+
.addTable(tableContent)
73+
.addQuote('All times are in millisecond (ms). RPS means "Requests per Second"')
74+
.write()
75+
}

dist/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
const fs = __nccwpck_require__(147);
88

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

1313
for(const run of lastRuns) {
14-
const results = JSON.parse(fs.readFileSync(`${testPath}/target/gatling/${run}/js/stats.json`).toString());
14+
const results = JSON.parse(fs.readFileSync(`${pomPath}/target/gatling/${run}/js/stats.json`).toString());
1515
let tableContent = [
1616
[
1717
{data: 'Request', header: true},

index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
const fs = require('fs');
22

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

77
for(const run of lastRuns) {
8-
const results = JSON.parse(fs.readFileSync(`${testPath}/target/gatling/${run}/js/stats.json`).toString());
8+
const results = JSON.parse(fs.readFileSync(`${pomPath}/target/gatling/${run}/js/stats.json`).toString());
99
let tableContent = [
1010
[
1111
{data: 'Request', header: true},

0 commit comments

Comments
 (0)