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
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 : |
0 commit comments