-
Notifications
You must be signed in to change notification settings - Fork 280
340 lines (281 loc) · 12.7 KB
/
build-and-run-example-project.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
name: Build and Run Example Project
on:
pull_request:
branches:
- master
paths:
- 'src/**' # Trigger workflow only if files in src directory change
- 'pom.xml' # Trigger workflow only if pom.xml file changes
env:
smart-doc-version: ${{ github.run_id }} # Use the current GitHub workflow run ID as a temporary version number
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
- name: Create Logs Directory
run: mkdir -p logs
- name: Update Version in pom.xml
run: mvn versions:set -DnewVersion="${{ env.smart-doc-version }}" -DgenerateBackupPoms=false
- name: Build and Install Plugin
run: |
mvn install 2>&1 | tee logs/build.log
if grep -E "\[ERROR\]" logs/build.log; then
cat logs/build.log
exit 1
fi
- name: Upload Plugin Artifact
id: upload-artifact
uses: actions/upload-artifact@v4
with:
name: smart-doc-maven-jar
path: ~/.m2/repository/com/ly/smart-doc
if-no-files-found: error
- name: Upload Build Log
if: failure() # Only run if previous steps fail
uses: actions/upload-artifact@v4
with:
name: error-log-smart-doc-build
path: logs/build.log
maven-plugin-build:
needs: build
runs-on: ubuntu-latest
concurrency:
group: maven-plugin-build-${{ github.event.pull_request.number }}
cancel-in-progress: true
steps:
- name: Checkout Maven Plugin Repository
uses: actions/checkout@v4
with:
repository: TongchengOpenSource/smart-doc-maven-plugin
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
- name: Create Logs Directory
run: mkdir -p logs
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: smart-doc-maven-jar
path: ./artifacts
- name: Move Files to Local Maven Repository
run: |
mkdir -p ~/.m2/repository/com/ly/smart-doc
echo "Overwriting target directory with new artifacts:"
rsync -av --delete ./artifacts/ ~/.m2/repository/com/ly/smart-doc/
echo "Listing files in target directory:"
ls -lh ~/.m2/repository/com/ly/smart-doc
- name: Update Version in pom.xml
run: |
mvn versions:set-property -Dproperty="smart-doc.version" -DnewVersion="${{ env.smart-doc-version }}" -DgenerateBackupPoms=false
- name: Build and Install
run: |
mvn -DskipTests=true install 2>&1 | tee logs/install-plugin.log
if grep -E "\[ERROR\]" logs/install-plugin.log; then
cat logs/install-plugin.log
exit 1
fi
- name: Upload Plugin Artifact
id: upload-artifact
uses: actions/upload-artifact@v4
with:
name: smart-doc-maven-plugin-jar
path: ~/.m2/repository/com/ly/smart-doc
if-no-files-found: error
- name: Upload Plugin Build Log
if: failure() # Only run if previous steps fail
uses: actions/upload-artifact@v4
with:
name: error-log-maven-plugin-build
path: logs/install-plugin.log
generate-api-docs:
needs: maven-plugin-build
runs-on: ubuntu-latest
strategy:
matrix:
doc_type: [ rest, dubbo, javadoc, websocket ]
concurrency:
group: generate-${{ matrix.doc_type }}-api-doc-${{ github.event.pull_request.number }}
cancel-in-progress: true
steps:
- name: Checkout Example Project
uses: actions/checkout@v4
with:
repository: smart-doc-group/smart-doc-example-cn
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Create Logs Directory
run: mkdir -p logs
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: smart-doc-maven-plugin-jar
path: ./artifacts
- name: Move Files to Local Maven Repository
run: |
mkdir -p ~/.m2/repository/com/ly/smart-doc
echo "Overwriting target directory with new artifacts:"
rsync -av --delete ./artifacts/ ~/.m2/repository/com/ly/smart-doc/
echo "Listing files in target directory:"
ls -lh ~/.m2/repository/com/ly/smart-doc
- name: Update Smart-Doc Version in pom.xml
run: |
mvn versions:set-property -Dproperty="smart-doc.version" -DnewVersion="${{ env.smart-doc-version }}" -DgenerateBackupPoms=false
- name: Build and Install Example Project
run: |
mvn -DskipTests=true install 2>&1 | tee logs/build-example-project.log
if grep -E "\[ERROR\]" logs/build-example-project.log; then
cat logs/build-example-project.log
exit 1
fi
- name: Generate ${{ matrix.doc_type }} API Documentation
run: |
case ${{ matrix.doc_type }} in
rest)
mvn -DskipTests=true smart-doc:adoc 2>&1 | tee logs/rest-adoc.log
if grep -E "\[ERROR\]" logs/rest-adoc.log; then cat logs/rest-adoc.log; exit 1; fi
mvn -DskipTests=true smart-doc:html 2>&1 | tee logs/rest-html.log
if grep -E "\[ERROR\]" logs/rest-html.log; then cat logs/rest-html.log; exit 1; fi
mvn -DskipTests=true smart-doc:jmeter 2>&1 | tee logs/rest-jmeter.log
if grep -E "\[ERROR\]" logs/rest-jmeter.log; then cat logs/rest-jmeter.log; exit 1; fi
mvn -DskipTests=true smart-doc:markdown 2>&1 | tee logs/rest-markdown.log
if grep -E "\[ERROR\]" logs/rest-markdown.log; then cat logs/rest-markdown.log; exit 1; fi
mvn -DskipTests=true smart-doc:openapi 2>&1 | tee logs/rest-openapi.log
if grep -E "\[ERROR\]" logs/rest-openapi.log; then cat logs/rest-openapi.log; exit 1; fi
mvn -DskipTests=true smart-doc:postman 2>&1 | tee logs/rest-postman.log
if grep -E "\[ERROR\]" logs/rest-postman.log; then cat logs/rest-postman.log; exit 1; fi
mvn -DskipTests=true smart-doc:swagger 2>&1 | tee logs/rest-swagger.log
if grep -E "\[ERROR\]" logs/rest-swagger.log; then cat logs/rest-swagger.log; exit 1; fi
mvn -DskipTests=true smart-doc:word 2>&1 | tee logs/rest-word.log
if grep -E "\[ERROR\]" logs/rest-word.log; then cat logs/rest-word.log; exit 1; fi
mvn test -Dtest=com.power.doc.torna.TornaApiTest 2>&1 | tee logs/rest-TornaApiTest.log
if grep -E "\[ERROR\]" logs/rest-TornaApiTest.log; then cat logs/rest-TornaApiTest.log; exit 1; fi
;;
dubbo)
mvn -DskipTests=true smart-doc:rpc-adoc 2>&1 | tee logs/rpc-adoc.log
if grep -E "\[ERROR\]" logs/rpc-adoc.log; then cat logs/rpc-adoc.log; exit 1; fi
mvn -DskipTests=true smart-doc:rpc-html 2>&1 | tee logs/rpc-html.log
if grep -E "\[ERROR\]" logs/rpc-html.log; then cat logs/rpc-html.log; exit 1; fi
mvn -DskipTests=true smart-doc:rpc-markdown 2>&1 | tee logs/rpc-markdown.log
if grep -E "\[ERROR\]" logs/rpc-markdown.log; then cat logs/rpc-markdown.log; exit 1; fi
;;
javadoc)
mvn -DskipTests=true smart-doc:javadoc-adoc 2>&1 | tee logs/javadoc-adoc.log
if grep -E "\[ERROR\]" logs/javadoc-adoc.log; then cat logs/javadoc-adoc.log; exit 1; fi
mvn -DskipTests=true smart-doc:javadoc-html 2>&1 | tee logs/javadoc-html.log
if grep -E "\[ERROR\]" logs/javadoc-html.log; then cat logs/javadoc-html.log; exit 1; fi
mvn -DskipTests=true smart-doc:javadoc-markdown 2>&1 | tee logs/javadoc-markdown.log
if grep -E "\[ERROR\]" logs/javadoc-markdown.log; then cat logs/javadoc-markdown.log; exit 1; fi
;;
websocket)
mvn -DskipTests=true smart-doc:websocket-adoc 2>&1 | tee logs/websocket-adoc.log
if grep -E "\[ERROR\]" logs/websocket-adoc.log; then cat logs/websocket-adoc.log; exit 1; fi
mvn -DskipTests=true smart-doc:websocket-html 2>&1 | tee logs/websocket-html.log
if grep -E "\[ERROR\]" logs/websocket-html.log; then cat logs/websocket-html.log; exit 1; fi
mvn -DskipTests=true smart-doc:websocket-markdown 2>&1 | tee logs/websocket-markdown.log
if grep -E "\[ERROR\]" logs/websocket-markdown.log; then cat logs/websocket-markdown.log; exit 1; fi
;;
esac
- name: Upload ${{ matrix.doc_type }} API Documentation
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.doc_type }}-api-doc
path: ${{ github.workspace }}/target/doc/
if-no-files-found: error
- name: Upload ${{ matrix.doc_type }} API Documentation Logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: error-log-${{ matrix.doc_type }}-api-docs
path: logs
generate-grpc-api-doc:
needs: maven-plugin-build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
concurrency:
group: generate-grpc-api-doc-${{ matrix.os }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
steps:
- name: Checkout Example Project
uses: actions/checkout@v4
with:
repository: smart-doc-group/smart-doc-example-cn
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Create Logs Directory
run: mkdir -p logs
shell: bash
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: smart-doc-maven-plugin-jar
path: ./artifacts
- name: Move Files to Local Maven Repository
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" || "${{ matrix.os }}" == "macos-latest" ]]; then
TARGET_DIR=~/.m2/repository/com/ly/smart-doc/
mkdir -p "$TARGET_DIR" || echo "Directory already exists"
rsync -av --delete ./artifacts/ "$TARGET_DIR"
elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then
TARGET_DIR="$USERPROFILE\\.m2\\repository\\com\\ly\\smart-doc\\"
mkdir -p "$TARGET_DIR" || echo "Directory already exists"
cp -r ./artifacts/* "$TARGET_DIR"
fi
shell: bash
- name: Update Smart-Doc Version in pom.xml
run: |
mvn versions:set-property -Dproperty="smart-doc.version" -DnewVersion="${{ env.smart-doc-version }}" -DgenerateBackupPoms=false
- name: Build and Install Example Project
run: |
mvn -DskipTests=true install 2>&1 | tee logs/build-example-project.log
if grep -E "\[ERROR\]" logs/build-example-project.log; then
cat logs/build-example-project.log
exit 1
fi
shell: bash
- name: Generate gRPC AsciiDoc Documentation
run: |
mvn -DskipTests=true smart-doc:grpc-adoc 2>&1 | tee logs/grpc-adoc.log
if grep -E "\[ERROR\]" logs/grpc-adoc.log; then cat logs/grpc-adoc.log; exit 1; fi
shell: bash
- name: Generate gRPC HTML Documentation
run: |
mvn -DskipTests=true smart-doc:grpc-html 2>&1 | tee logs/grpc-html.log
if grep -E "\[ERROR\]" logs/grpc-html.log; then cat logs/grpc-html.log; exit 1; fi
shell: bash
- name: Generate gRPC Markdown Documentation
run: |
mvn -DskipTests=true smart-doc:grpc-markdown 2>&1 | tee logs/grpc-markdown.log
if grep -E "\[ERROR\]" logs/grpc-markdown.log; then cat logs/grpc-markdown.log; exit 1; fi
shell: bash
- name: Upload gRPC API Documentation
uses: actions/upload-artifact@v4
with:
name: gRPC-api-doc-${{ runner.os }}
path: ${{ github.workspace }}/target/doc/
if-no-files-found: error
- name: Upload ${{ runner.os }} gRPC API Documentation Log
if: failure()
uses: actions/upload-artifact@v4
with:
name: error-log-${{ runner.os }}-grpc-api-doc
path: logs