@@ -107,78 +107,82 @@ jobs:
107107 - name : Check Maven version
108108 run : mvn -v
109109
110- # 构建带插桩的 Native Image
111- - name : Build Instrumented Native Image
110+ # # 构建带插桩的 Native Image
111+ # - name: Build Instrumented Native Image
112+ # run: |
113+ # mvn clean package -Pnative -Daot.build.mode=${{ inputs.aot_build_mode }} -DskipTests -Dnative-image.jvmArgs="-Xmx32g" -Dnative-image.addArgs="--pgo-instrument -o target/jmalcloud-instrumented"
114+ #
115+ # # 运行插桩程序以生成 Profile 文件
116+ # - name: Run Instrumented App to Generate Profile
117+ # env:
118+ # MONGODB_URI: ${{ secrets.MONGODB_URI }}
119+ # HOME_DIR: ${{ env.HOME }}
120+ # run: |
121+ # chmod +x target/jmalcloud-instrumented
122+ #
123+ # rm -rf ${HOME}/jmalcloud
124+ # rm -f jmalcloud.iprof
125+ #
126+ # mkdir -p ${HOME}/jmalcloud
127+ #
128+ # echo "Starting instrumented application in the background..."
129+ # # 在后台运行程序,并将 profile 文件名指定为 jmalcloud.iprof
130+ # # 使用 & 将其放入后台
131+ # ./target/jmalcloud-instrumented --spring.profiles.active=${{ inputs.profiles_active }} -XX:ProfilesDumpFile='jmalcloud.iprof' --spring.data.mongodb.uri=${{secrets.MONGODB_URI}} --file.rootDir=${HOME}/jmalcloud > "${HOME}/app.log" 2>&1 &
132+ #
133+ # # 获取后台进程的 PID (Process ID)
134+ # APP_PID=$!
135+ # echo "应用程序已启动,进程ID为: $APP_PID"
136+ #
137+ # # 等待应用启动
138+ # for i in {1..30}; do
139+ # if curl -s http://localhost:8088/public/health | grep -q '^UP'; then
140+ # echo "App is up"
141+ # break
142+ # fi
143+ # sleep 2
144+ # done
145+ #
146+ # # 创建管理员
147+ # curl --location --request POST 'http://localhost:8088/api/public/initialization?password=123456&id=&username=admin&showName=%E7%AE%A1%E7%90%86%E5%91%981&avatar=https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif&slogan=&introduction=&webpDisabled=&roles="a=10'
148+ # # 上传文件
149+ # cp -r target/test-classes ${HOME}/jmalcloud/admin/
150+ #
151+ # # 等待应用程序运行一段时间以收集性能数据
152+ # echo "等待应用程序运行 120 秒以收集性能数据..."
153+ # sleep 120
154+ #
155+ # # 打印日志文件的最后 100 行
156+ # tail -n 100 "${HOME}/app.log"
157+ #
158+ # echo "发送 SIGINT 信号来优雅地终止进程,这会触发 profile 文件的写入"
159+ # kill -15 $APP_PID
160+ #
161+ # echo "等待几秒钟,让进程优雅地终止..."
162+ # sleep 5
163+ #
164+ # ls -lh 'jmalcloud.iprof'
165+ #
166+ # ls -lh 'jmalcloud.iprof'
167+ #
168+ # # 验证 Profile 文件是否已创建
169+ # - name: Verify Profile File Creation
170+ # run: |
171+ # echo "Checking if profile file was created..."
172+ # ls -l jmalcloud.iprof
173+ # if [ ! -f "jmalcloud.iprof" ]; then
174+ # echo "Error: Profile file jmalcloud.iprof was not created."
175+ # exit 1
176+ # fi
177+
178+ # # 使用传入参数构建最终优化的 Native Image
179+ # - name: Build final PGO-Optimized Native Image
180+ # run: |
181+ # mvn clean package -Pnative -Daot.build.mode=${{ inputs.aot_build_mode }} -DskipTests -Dnative-image.jvmArgs="-Xmx15g" -Dnative-image.addArgs="--enable-monitoring=heapdump --pgo=jmalcloud.iprof"
182+
183+ - name : Build Native Image
112184 run : |
113- mvn clean package -Pnative -Daot.build.mode=${{ inputs.aot_build_mode }} -DskipTests -Dnative-image.jvmArgs="-Xmx23g" -Dnative-image.addArgs="--pgo-instrument -o target/jmalcloud-instrumented"
114-
115- # 运行插桩程序以生成 Profile 文件
116- - name : Run Instrumented App to Generate Profile
117- env :
118- MONGODB_URI : ${{ secrets.MONGODB_URI }}
119- HOME_DIR : ${{ env.HOME }}
120- run : |
121- chmod +x target/jmalcloud-instrumented
122-
123- rm -rf ${HOME}/jmalcloud
124- rm -f jmalcloud.iprof
125-
126- mkdir -p ${HOME}/jmalcloud
127-
128- echo "Starting instrumented application in the background..."
129- # 在后台运行程序,并将 profile 文件名指定为 jmalcloud.iprof
130- # 使用 & 将其放入后台
131- ./target/jmalcloud-instrumented --spring.profiles.active=${{ inputs.profiles_active }} -XX:ProfilesDumpFile='jmalcloud.iprof' --spring.data.mongodb.uri=${{secrets.MONGODB_URI}} --file.rootDir=${HOME}/jmalcloud > "${HOME}/app.log" 2>&1 &
132-
133- # 获取后台进程的 PID (Process ID)
134- APP_PID=$!
135- echo "应用程序已启动,进程ID为: $APP_PID"
136-
137- # 等待应用启动
138- for i in {1..30}; do
139- if curl -s http://localhost:8088/public/health | grep -q '^UP'; then
140- echo "App is up"
141- break
142- fi
143- sleep 2
144- done
145-
146- # 创建管理员
147- curl --location --request POST 'http://localhost:8088/api/public/initialization?password=123456&id=&username=admin&showName=%E7%AE%A1%E7%90%86%E5%91%981&avatar=https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif&slogan=&introduction=&webpDisabled=&roles="a=10'
148- # 上传文件
149- cp -r target/test-classes ${HOME}/jmalcloud/admin/
150-
151- # 等待应用程序运行一段时间以收集性能数据
152- echo "等待应用程序运行 120 秒以收集性能数据..."
153- sleep 120
154-
155- # 打印日志文件的最后 100 行
156- tail -n 100 "${HOME}/app.log"
157-
158- echo "发送 SIGINT 信号来优雅地终止进程,这会触发 profile 文件的写入"
159- kill -15 $APP_PID
160-
161- echo "等待几秒钟,让进程优雅地终止..."
162- sleep 5
163-
164- ls -lh 'jmalcloud.iprof'
165-
166- ls -lh 'jmalcloud.iprof'
167-
168- # 验证 Profile 文件是否已创建
169- - name : Verify Profile File Creation
170- run : |
171- echo "Checking if profile file was created..."
172- ls -l jmalcloud.iprof
173- if [ ! -f "jmalcloud.iprof" ]; then
174- echo "Error: Profile file jmalcloud.iprof was not created."
175- exit 1
176- fi
177-
178- # 使用传入参数构建最终优化的 Native Image
179- - name : Build final PGO-Optimized Native Image
180- run : |
181- mvn clean package -Pnative -Daot.build.mode=${{ inputs.aot_build_mode }} -DskipTests -Dnative-image.jvmArgs="-Xmx15g" -Dnative-image.addArgs="--enable-monitoring=heapdump --pgo=jmalcloud.iprof"
185+ mvn clean package -Pnative -Daot.build.mode=${{ inputs.aot_build_mode }} -DskipTests
182186
183187 # 保存构建产物到本地共享目录
184188 - name : Save build artifacts to local cache
0 commit comments