-
Notifications
You must be signed in to change notification settings - Fork 436
320 lines (300 loc) · 12.3 KB
/
pr.yml
File metadata and controls
320 lines (300 loc) · 12.3 KB
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
name: PR CI
on:
pull_request:
branches:
- master
paths-ignore:
- '.github/workflows/scripts-android.yml'
- '.github/workflows/scripts-ios.yml'
- 'scripts/**'
- 'docs/**'
- '**/*.md'
- '.github/workflows/developer-guide-docs.yml'
- 'CodenameOneDesigner/**'
push:
branches:
- master
paths-ignore:
- '.github/workflows/scripts-android.yml'
- '.github/workflows/scripts-ios.yml'
- 'scripts/**'
- 'docs/**'
- '**/*.md'
- '.github/workflows/developer-guide-docs.yml'
- 'CodenameOneDesigner/**'
permissions:
contents: write
pull-requests: write
issues: write
jobs:
build-linux-jdk8-fx:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 1.8
java-package: jdk+fx
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2
- name: Run Unit Tests
run: |
cd maven
mvn clean verify -DunitTests=true -pl core-unittests -am -Dmaven.javadoc.skip=true -Plocal-dev-javase
cd ..
- name: Prepare Codename One binaries for Maven plugin tests
run: |
set -euo pipefail
rm -rf maven/target/cn1-binaries
git clone --depth=1 --filter=blob:none https://github.com/codenameone/cn1-binaries maven/target/cn1-binaries
- name: Run Maven plugin tests
working-directory: maven
env:
CN1_BINARIES: ${{ github.workspace }}/maven/target/cn1-binaries
run: |
mvn -B -Dmaven.javadoc.skip=true \
-DunitTests=true \
-Dcodename1.platform=javase \
-Dcn1.binaries="${CN1_BINARIES}" \
-pl codenameone-maven-plugin -am -Plocal-dev-javase test
- name: Generate static analysis HTML summaries
if: ${{ always() }}
env:
QUALITY_REPORT_TARGET_DIRS: maven/core-unittests/target
QUALITY_REPORT_SERVER_URL: ${{ github.server_url }}
QUALITY_REPORT_REPOSITORY: ${{ github.repository }}
QUALITY_REPORT_REF: ${{ github.event.pull_request.head.sha || github.sha }}
QUALITY_REPORT_GENERATE_HTML_ONLY: "1"
run: python3 .github/scripts/generate-quality-report.py
- name: Collect quality artifacts
if: ${{ always() }}
run: |
set -euo pipefail
mkdir -p quality-artifacts/static-analysis
mkdir -p quality-artifacts/coverage
shopt -s nullglob
for path in maven/core-unittests/target/spotbugsXml.xml maven/core-unittests/target/spotbugs.xml; do
if [ -f "$path" ]; then
cp "$path" quality-artifacts/static-analysis/
fi
done
if [ -f maven/core-unittests/target/pmd.xml ]; then
cp maven/core-unittests/target/pmd.xml quality-artifacts/static-analysis/
fi
if [ -f maven/core-unittests/target/checkstyle-result.xml ]; then
cp maven/core-unittests/target/checkstyle-result.xml quality-artifacts/static-analysis/
fi
if [ -d target/quality-report ]; then
mkdir -p quality-artifacts/static-analysis/html
cp -R target/quality-report/. quality-artifacts/static-analysis/html/
fi
if [ -d maven/core-unittests/target/site/jacoco ]; then
cp -R maven/core-unittests/target/site/jacoco quality-artifacts/coverage/
fi
if [ "$(find quality-artifacts -type f | wc -l)" -eq 0 ]; then
echo "No quality artifacts were generated." > quality-artifacts/README.txt
fi
- name: Upload quality artifacts
if: ${{ always() }}
id: upload-quality-artifacts
uses: actions/upload-artifact@v4
with:
name: quality-artifacts
path: quality-artifacts
- name: Publish quality report previews
if: ${{ always() && github.server_url == 'https://github.com' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
id: publish-quality-previews
env:
GITHUB_TOKEN: ${{ github.token }}
SERVER_URL: ${{ github.server_url }}
REPOSITORY: ${{ github.repository }}
RUN_ID: ${{ github.run_id }}
RUN_ATTEMPT: ${{ github.run_attempt }}
run: |
set -euo pipefail
if [ "${SERVER_URL}" != "https://github.com" ]; then
echo "HTML previews are only published for github.com instances."
exit 0
fi
run_dir="runs/${RUN_ID}-${RUN_ATTEMPT}"
tmp_dir=$(mktemp -d)
dest_dir="${tmp_dir}/${run_dir}"
mkdir -p "${dest_dir}"
has_content=0
if compgen -G "target/quality-report/*.html" > /dev/null; then
mkdir -p "${dest_dir}/static-analysis"
cp target/quality-report/*.html "${dest_dir}/static-analysis/"
has_content=1
fi
if [ -d maven/core-unittests/target/site/jacoco ] && [ -f maven/core-unittests/target/site/jacoco/index.html ]; then
mkdir -p "${dest_dir}/coverage"
cp -R maven/core-unittests/target/site/jacoco/. "${dest_dir}/coverage/"
has_content=1
fi
if [ "${has_content}" -eq 0 ]; then
echo "No HTML outputs detected; skipping preview publishing."
exit 0
fi
printf '%s\n%s\n%s\n' \
'# Quality report previews' \
'' \
'This branch is automatically managed by the PR CI workflow and may be force-pushed.' \
> "${tmp_dir}/README.md"
git -C "${tmp_dir}" init -b previews >/dev/null
git -C "${tmp_dir}" config user.name "github-actions[bot]"
git -C "${tmp_dir}" config user.email "github-actions[bot]@users.noreply.github.com"
git -C "${tmp_dir}" add .
git -C "${tmp_dir}" commit -m "Publish quality report previews for run ${RUN_ID} (attempt ${RUN_ATTEMPT})" >/dev/null
remote_url="${SERVER_URL}/${REPOSITORY}.git"
token_remote_url="${remote_url/https:\/\//https://x-access-token:${GITHUB_TOKEN}@}"
git -C "${tmp_dir}" push --force "${token_remote_url}" previews:quality-report-previews >/dev/null
commit_sha=$(git -C "${tmp_dir}" rev-parse HEAD)
raw_base="https://raw.githubusercontent.com/${REPOSITORY}/${commit_sha}/${run_dir}"
preview_base="https://htmlpreview.github.io/?${raw_base}"
{
echo "commit=${commit_sha}"
echo "run_path=${run_dir}"
} >> "$GITHUB_OUTPUT"
if [ -f "${dest_dir}/static-analysis/spotbugs.html" ]; then
echo "spotbugs_url=${preview_base}/static-analysis/spotbugs.html" >> "$GITHUB_OUTPUT"
fi
if [ -f "${dest_dir}/static-analysis/pmd.html" ]; then
echo "pmd_url=${preview_base}/static-analysis/pmd.html" >> "$GITHUB_OUTPUT"
fi
if [ -f "${dest_dir}/static-analysis/checkstyle.html" ]; then
echo "checkstyle_url=${preview_base}/static-analysis/checkstyle.html" >> "$GITHUB_OUTPUT"
fi
if [ -f "${dest_dir}/coverage/index.html" ]; then
echo "jacoco_url=${preview_base}/coverage/index.html" >> "$GITHUB_OUTPUT"
fi
- name: Generate quality report summary
if: ${{ always() }}
env:
QUALITY_REPORT_TARGET_DIRS: maven/core-unittests/target
QUALITY_REPORT_SERVER_URL: ${{ github.server_url }}
QUALITY_REPORT_REPOSITORY: ${{ github.repository }}
QUALITY_REPORT_REF: ${{ github.event.pull_request.head.sha || github.sha }}
SPOTBUGS_REPORT_URL: ${{ steps.upload-quality-artifacts.outputs.artifact-url }}
PMD_REPORT_URL: ${{ steps.upload-quality-artifacts.outputs.artifact-url }}
CHECKSTYLE_REPORT_URL: ${{ steps.upload-quality-artifacts.outputs.artifact-url }}
JACOCO_REPORT_URL: ${{ steps.upload-quality-artifacts.outputs.artifact-url }}
SPOTBUGS_HTML_URL: ${{ steps.publish-quality-previews.outputs.spotbugs_url }}
PMD_HTML_URL: ${{ steps.publish-quality-previews.outputs.pmd_url }}
CHECKSTYLE_HTML_URL: ${{ steps.publish-quality-previews.outputs.checkstyle_url }}
JACOCO_HTML_URL: ${{ steps.publish-quality-previews.outputs.jacoco_url }}
run: python3 .github/scripts/generate-quality-report.py
- name: Upload quality report summary
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: quality-report
path: quality-report.md
- name: Publish quality report comment
if: ${{ github.event_name == 'pull_request' }}
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const marker = '<!-- quality-report -->';
const reportPath = 'quality-report.md';
if (!fs.existsSync(reportPath)) {
core.warning('quality-report.md was not generated.');
return;
}
const body = `${marker}\n${fs.readFileSync(reportPath, 'utf8')}`;
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
const { data: comments } = await github.rest.issues.listComments({
owner,
repo,
issue_number,
per_page: 100,
});
const existing = comments.find(
(comment) => comment.user?.type === 'Bot' && comment.body?.includes(marker),
);
if (existing) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body,
});
}
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install xvfb
wget https://github.com/codenameone/cn1-binaries/archive/refs/heads/master.zip
unzip master.zip -d ..
mv ../cn1-binaries-master ../cn1-binaries
- name: Build with Ant
run: xvfb-run ant test-javase
- name: Build CLDC11 JAR
run: ant -noinput -buildfile Ports/CLDC11/build.xml jar
- name: Build Release
run: ant -noinput -buildfile CodenameOne/build.xml weeklyLibUpdate
- name: Build JavaDocs
run: |
cd CodenameOne
mkdir -p build
mkdir -p build/tempJavaSources
mkdir -p dist
mkdir -p dist/javadoc
# Skip JavaDocSourceEmbed due to gist access issues in CI
cp -r src/* build/tempJavaSources/
find build/tempJavaSources ../Ports/CLDC11/src -name "*.java" | /usr/bin/grep -v /impl/ | /usr/bin/xargs javadoc --allow-script-in-comments -protected -d dist/javadoc -windowtitle "Codename One API" || true
cd dist/javadoc
zip -r ../../javadocs.zip *
cd ..
- name: Build iOS Port
run: ant -noinput -buildfile Ports/iOSPort/build.xml jar
- name: Build iOS VM API
run: ant -noinput -buildfile vm/JavaAPI/build.xml jar
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
name: JavaAPI.jar
path: vm/JavaAPI/dist/JavaAPI.jar
- name: Build iOS VM
run: ant -noinput -buildfile vm/ByteCodeTranslator/build.xml jar
- name: Build CLDC 11 VM
run: ant -noinput -buildfile Ports/CLDC11/build.xml jar
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
name: ByteCodeTranslator.jar
path: vm/ByteCodeTranslator/dist/ByteCodeTranslator.jar
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
name: CLDC11.jar
path: Ports/CLDC11/dist/CLDC11.jar
- name: Build Android Port
run: ant -noinput -buildfile Ports/Android/build.xml jar
- name: Packaging Everything
run: zip -j result.zip CodenameOne/javadocs.zip CodenameOne/dist/CodenameOne.jar CodenameOne/updatedLibs.zip Ports/JavaSE/dist/JavaSE.jar build/CodenameOneDist/CodenameOne/demos/CodenameOne_SRC.zip
- name: Copying Files to Server
uses: marcodallasanta/ssh-scp-deploy@v1.0.5
with:
host: ${{ secrets.WP_HOST }}
user: ${{ secrets.WP_USER }}
password: ${{ secrets.WP_PASSWORD }}
local: result.zip
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
name: JavaSE.jar
path: Ports/JavaSE/dist/JavaSE.jar