Skip to content

Commit 2f25f57

Browse files
committed
fiw workflow loading test
fiw workflow loading test
1 parent 350d1b1 commit 2f25f57

File tree

7 files changed

+158
-148
lines changed

7 files changed

+158
-148
lines changed

.github/scripts/extract_and_generate_html.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ replace_in_html_files() {
2222
}
2323

2424
# Read the contents of lastRun.txt and sort it
25+
pwd
26+
tree .
2527
last_runs=($(sort -n < loading/target/gatling/lastRun.txt))
2628

2729
# Create the HTML template

.github/workflows/build-feature.yml

Lines changed: 88 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
steps:
3535
# Checkout the code from the repository
3636
- name: Checkout
37-
uses: actions/checkout@v3
37+
uses: actions/checkout@v4
3838
with:
3939
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
4040

@@ -47,15 +47,15 @@ jobs:
4747

4848
# Cache Sonar packages to speed up the build process
4949
- name: Cache SonarCloud packages
50-
uses: actions/cache@v3
50+
uses: actions/cache@v4
5151
with:
5252
path: ~/.sonar/cache
5353
key: ${{ runner.os }}-sonar
5454
restore-keys: ${{ runner.os }}-sonar
5555

5656
# Cache Maven packages to speed up the build process
5757
- name: Cache Maven packages
58-
uses: actions/cache@v3
58+
uses: actions/cache@v4
5959
with:
6060
path: ~/.m2/repository
6161
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
@@ -73,17 +73,38 @@ jobs:
7373
mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=Raouf25_spring-boot-asynchronous-api
7474
fi
7575
76+
docker:
77+
name: Build & push to Docker Hub
78+
needs: analyze_code
79+
runs-on: ubuntu-latest
80+
steps:
81+
- name: Checkout
82+
uses: actions/checkout@v4
83+
- name: Build Docker image
84+
run: docker build -t raouf25/spring-boot-asynchronous-api .
85+
- name: Push to Docker Hub
86+
uses: docker/login-action@v3
87+
with:
88+
username: ${{ secrets.DOCKERHUB_USERNAME }}
89+
password: ${{ secrets.DOCKERHUB_TOKEN }}
90+
- name: Docker push
91+
run: |
92+
docker push raouf25/spring-boot-asynchronous-api:latest
93+
docker tag raouf25/spring-boot-asynchronous-api registry.fly.io/spring-boot-asynchronous-api
94+
docker images | grep "spring-boot-asynchronous"
95+
7696
deploy:
7797
environment:
7898
name: dev-swagger-ui
7999
url: https://spring-boot-asynchronous-api.fly.dev/swagger-ui/index.html
80100
name: Deploy app
81-
needs: analyze_code
101+
needs: docker
82102
runs-on: ubuntu-latest
83103
steps:
84-
- uses: actions/checkout@v3
104+
- uses: actions/checkout@v4
85105
- uses: superfly/flyctl-actions/setup-flyctl@master
86-
- run: flyctl deploy --remote-only
106+
- run: |
107+
flyctl deploy -i registry.fly.io/spring-boot-asynchronous-api
87108
88109
non_regression_test:
89110
name: Non Regression Test
@@ -95,7 +116,7 @@ jobs:
95116
steps:
96117
# Checkout the code from the repository
97118
- name: Checkout
98-
uses: actions/checkout@v3
119+
uses: actions/checkout@v4
99120
with:
100121
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
101122

@@ -108,7 +129,7 @@ jobs:
108129

109130
# Cache Maven packages to speed up the build process
110131
- name: Cache Maven packages
111-
uses: actions/cache@v3
132+
uses: actions/cache@v4
112133
with:
113134
path: ~/.m2/repository
114135
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
@@ -123,13 +144,13 @@ jobs:
123144
# Create a "doc" directory and move karate reports to it
124145
- name: Get report
125146
run: |
126-
mkdir -p doc
127-
mv ./nrt/target/karate-reports/* ./doc
147+
mkdir -p doc/karate
148+
mv ./nrt/target/karate-reports/* ./doc/karate
128149
129-
- uses: actions/upload-artifact@master
150+
- uses: actions/upload-artifact@v4
130151
with:
131152
name: karate
132-
path: doc/karate
153+
path: ./doc/karate/
133154
# - name: Upload artifact
134155
# uses: actions/upload-pages-artifact@v1
135156
# with:
@@ -149,12 +170,20 @@ jobs:
149170
steps:
150171
# Checkout the code from the repository
151172
- name: Checkout
152-
uses: actions/checkout@v3
173+
uses: actions/checkout@v4
174+
175+
- name: Set up JDK 21
176+
uses: actions/setup-java@v4
177+
with:
178+
distribution: 'temurin'
179+
java-version: '21'
153180

154181
# Execute Gatling Test Suite
155182
- name: Execute Gatling Test Suite
156183
continue-on-error: true
157184
run: |
185+
mvn --version
186+
java --version
158187
mvn clean gatling:test --f loading/pom.xml
159188
160189
# New step to generate gatling-summary.html
@@ -163,65 +192,51 @@ jobs:
163192
.github/scripts/extract_and_generate_html.sh
164193
shell: bash
165194

166-
- uses: actions/upload-artifact@master
195+
- uses: actions/upload-artifact@v4
167196
with:
168197
name: gatling
169198
path: doc/gatling
170199

171-
# - name: Upload artifact
172-
# uses: actions/upload-pages-artifact@v1
173-
# with:
174-
# # Upload entire repository
175-
# path: './doc'
176-
# - name: Deploy to GitHub Pages
177-
# id: deployment
178-
# uses: actions/deploy-pages@v1
179-
180-
# - name: Generate Job Summary
181-
# uses: actions/github-script@v6
182-
# with:
183-
# script: |
184-
# const fs = require('fs')
185-
# const lastRuns = fs.readFileSync(`loading/target/gatling/lastRun.txt`).toString().trim().split('\n');
186-
#
187-
# for(const run of lastRuns) {
188-
# const formattedLine = run.replace(/(.*)-(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/, ' $1 at $2-$3-$4 $5:$6:$7');
189-
# const results = JSON.parse(fs.readFileSync(`loading/target/gatling/${run}/js/stats.json`).toString());
190-
# let tableContent = [
191-
# [
192-
# {data: 'Request', header: true},
193-
# {data: 'Success ✅', header: true},
194-
# {data: 'Errors ❌', header: true},
195-
# {data: 'Min', header: true},
196-
# {data: 'Max', header: true},
197-
# {data: 'Avg.', header: true},
198-
# {data: 'Std. Dev.', header: true},
199-
# {data: 'RPS', header: true},
200-
# ]
201-
# ];
202-
#
203-
# for(const result in results.contents) {
204-
# const requestMetrics = results.contents[result].stats;
205-
# tableContent.push([
206-
# requestMetrics.name,
207-
# requestMetrics.numberOfRequests.ok.toString(),
208-
# requestMetrics.numberOfRequests.ko.toString(),
209-
# requestMetrics.minResponseTime.total.toString(),
210-
# requestMetrics.maxResponseTime.total.toString(),
211-
# requestMetrics.meanResponseTime.total.toString(),
212-
# requestMetrics.standardDeviation.total.toString(),
213-
# requestMetrics.meanNumberOfRequestsPerSecond.total.toString(),
214-
# ]);
215-
# }
216-
#
217-
# await core.summary
218-
# .addHeading(`Results for ${formattedLine}`)
219-
# .addTable(tableContent)
220-
# .addQuote('All times are in millisecond (ms). RPS means "Requests per Second"')
221-
# .write()
222-
# }
223-
#
224-
200+
- name: Generate Job Summary
201+
uses: actions/github-script@v7
202+
with:
203+
script: |
204+
const fs = require('fs')
205+
const lastRuns = fs.readFileSync(`loading/target/gatling/lastRun.txt`).toString().trim().split('\n');
206+
for(const run of lastRuns) {
207+
const formattedLine = run.replace(/(.*)-(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/, ' $1 at $2-$3-$4 $5:$6:$7');
208+
const results = JSON.parse(fs.readFileSync(`loading/target/gatling/${run}/js/stats.json`).toString());
209+
let tableContent = [
210+
[
211+
{data: 'Request', header: true},
212+
{data: 'Success ✅', header: true},
213+
{data: 'Errors ❌', header: true},
214+
{data: 'Min', header: true},
215+
{data: 'Max', header: true},
216+
{data: 'Avg.', header: true},
217+
{data: 'Std. Dev.', header: true},
218+
{data: 'RPS', header: true},
219+
]
220+
];
221+
for(const result in results.contents) {
222+
const requestMetrics = results.contents[result].stats;
223+
tableContent.push([
224+
requestMetrics.name,
225+
requestMetrics.numberOfRequests.ok.toString(),
226+
requestMetrics.numberOfRequests.ko.toString(),
227+
requestMetrics.minResponseTime.total.toString(),
228+
requestMetrics.maxResponseTime.total.toString(),
229+
requestMetrics.meanResponseTime.total.toString(),
230+
requestMetrics.standardDeviation.total.toString(),
231+
requestMetrics.meanNumberOfRequestsPerSecond.total.toString(),
232+
]);
233+
}
234+
await core.summary
235+
.addHeading(`Results for ${formattedLine}`)
236+
.addTable(tableContent)
237+
.addQuote('All times are in millisecond (ms). RPS means "Requests per Second"')
238+
.write()
239+
}
225240
deploy_reports:
226241
name: Deploy Reports
227242
needs:
@@ -230,16 +245,16 @@ jobs:
230245
runs-on: ubuntu-latest
231246
steps:
232247
- name: Checkout
233-
uses: actions/checkout@v3
248+
uses: actions/checkout@v4
234249

235250
- name: Retrieve saved Non Regression Test
236-
uses: actions/download-artifact@v3
251+
uses: actions/download-artifact@v4
237252
with:
238253
name: karate
239-
path: doc/karate
254+
path: ./doc/karate
240255

241256
- name: Retrieve saved Loading Test
242-
uses: actions/download-artifact@v3
257+
uses: actions/download-artifact@v4
243258
with:
244259
name: gatling
245260
path: doc/gatling
@@ -251,7 +266,7 @@ jobs:
251266
path: './doc'
252267
- name: Deploy to GitHub Pages
253268
id: deployment
254-
uses: actions/deploy-pages@v1
269+
uses: actions/deploy-pages@v4
255270

256271
- name: Echo URL Reports
257272
run: |

Dockerfile

Lines changed: 14 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,21 @@
1-
#
2-
# Build stage
3-
#
4-
FROM maven:3.9.5-eclipse-temurin-21-alpine AS MAVEN_BUILD
5-
COPY pom.xml /build/
6-
COPY app /build/app/
7-
WORKDIR /build/
8-
RUN mvn -f /build/app/pom.xml clean package
1+
# ----------------
2+
# Using Oracle GraalVM for JDK 21
3+
FROM container-registry.oracle.com/graalvm/native-image:21-ol8 AS builder
94

10-
#
11-
# Package stage
12-
#
13-
# base image to build a JRE
14-
FROM eclipse-temurin:21-alpine AS deps
5+
# Set the working directory to /home/app
6+
WORKDIR /build
157

16-
# Identify dependencies
17-
COPY --from=MAVEN_BUILD ./build/app/target/*-SNAPSHOT.jar /app/app.jar
18-
RUN mkdir /app/unpacked && \
19-
cd /app/unpacked && \
20-
unzip ../app.jar && \
21-
cd .. && \
22-
$JAVA_HOME/bin/jdeps \
23-
--ignore-missing-deps \
24-
--print-module-deps \
25-
-q \
26-
--recursive \
27-
--multi-release 17 \
28-
--class-path="./unpacked/BOOT-INF/lib/*" \
29-
--module-path="./unpacked/BOOT-INF/lib/*" \
30-
./app.jar > /deps.info
8+
# Copy the source code into the image for building
9+
COPY . /build
3110

32-
# base image to build a JRE
33-
FROM eclipse-temurin:21-alpine AS custome-jre-step
11+
# Build
12+
RUN ./mvnw --no-transfer-progress native:compile -Pnative -DskipTests -f ./app/pom.xml
3413

35-
# required for strip-debug to work
36-
RUN apk add --no-cache binutils
14+
# The deployment Image
15+
FROM container-registry.oracle.com/os/oraclelinux:8-slim
3716

38-
# copy module dependencies info
39-
COPY --from=deps /deps.info /deps.info
40-
41-
# Build small JRE image
42-
RUN $JAVA_HOME/bin/jlink \
43-
--verbose \
44-
--add-modules $(cat /deps.info) \
45-
--strip-debug \
46-
--no-man-pages \
47-
--no-header-files \
48-
--compress=2 \
49-
--output /customjre
50-
51-
# main app image
52-
FROM alpine:latest
53-
ENV JAVA_HOME=/jre
54-
ENV PATH="${JAVA_HOME}/bin:${PATH}"
55-
56-
# copy JRE from the base image
57-
COPY --from=custome-jre-step /customjre $JAVA_HOME
58-
59-
# Add app user
60-
ARG APPLICATION_USER=appuser
61-
RUN adduser --no-create-home -u 1000 -D $APPLICATION_USER
62-
63-
# Configure working directory
64-
RUN mkdir /app && \
65-
chown -R $APPLICATION_USER /app
66-
67-
# Set the working directory
68-
WORKDIR /app
69-
70-
# Copy the built JAR file from the build stage
71-
COPY --chown=1000:1000 --from=MAVEN_BUILD /build/app/target/spring-boot-asynchronous-api-app-*.jar /app/app.jar
72-
73-
# Expose port 8080
7417
EXPOSE 8080
7518

76-
# Run the JAR file as the entrypoint
77-
ENTRYPOINT [ "/jre/bin/java", "-XX:+UseSerialGC","-Xss512k", "-jar", "/app/app.jar" ]
19+
# Copy the native executable into the containers
20+
COPY --from=builder /build/app/target/spring-boot-asynchronous-api-app app
21+
ENTRYPOINT ["/app"]

app/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313
<artifactId>spring-boot-asynchronous-api-app</artifactId>
1414

1515
<properties>
16-
16+
<java.version>21</java.version>
1717
<!-- SonarCloud -->
1818
<sonar.organization>raouf25-github</sonar.organization>
1919
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
2020
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
2121
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
2222
<sonar.coverage.jacoco.xmlReportPaths> ${project.basedir}/report-aggregate/target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
23-
2423
</properties>
2524

2625
<dependencies>

loading/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<dependency>
2323
<groupId>io.gatling.highcharts</groupId>
2424
<artifactId>gatling-charts-highcharts</artifactId>
25-
<version>3.10.4</version>
25+
<version>3.10.5</version>
2626
<scope>test</scope>
2727
</dependency>
2828
</dependencies>

0 commit comments

Comments
 (0)