Skip to content

Commit 85f491c

Browse files
committed
ICU-23320 CI Jobs to generate Java errorprone and coverage reports
1 parent a803578 commit 85f491c

File tree

5 files changed

+262
-86
lines changed

5 files changed

+262
-86
lines changed

.github/workflows/jekyll-gh-pages.yml

Lines changed: 0 additions & 79 deletions
This file was deleted.
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
# Copyright (C) 2023 and later: Unicode, Inc. and others.
2+
# License & terms of use: http://www.unicode.org/copyright.html
3+
#
4+
# Note: the workflow here is based on the Github Actions workflow used
5+
# by the Jekyll theme we are using:
6+
# https://github.com/just-the-docs/just-the-docs/blob/main/.github/workflows/deploy.yml
7+
#
8+
# The Jekyll theme (just-the-docs) configured its Github CI to manually run the Jekyll
9+
# build instead of relying on the default behavior from
10+
# https://github.com/actions/jekyll-build-pages . The default behavior of
11+
# actions/jekyll-build-pages seems to be causing errors with this theme.
12+
#
13+
# Also, since the deployment to GitHub Pages is atomic, anything else that touches
14+
# them should be here. The pattern is: run several jobs, each publishing an artifact,
15+
# and then the artifacts get merged into one before deploying.
16+
17+
name: Deploy GitHub Pages
18+
19+
on:
20+
# Runs on pushes targeting the default branch and only if in the `docs/` directory
21+
push:
22+
branches: ["main"]
23+
paths: ["docs/**"]
24+
25+
schedule:
26+
- cron: '0 2 * * 6' # every Saturday at 2 a.m.
27+
28+
# Allows you to run this workflow manually from the Actions tab
29+
workflow_dispatch:
30+
31+
env:
32+
# The _ROOT will become the root of the artifact zip file
33+
REPORT_ROOT_DIR: '${{ github.workspace }}/artifacts_reports_root'
34+
# The report folder includes the relative path, matching path we want to see on the generated website.
35+
# We will generate the reports in the relative folder, so that when we merge the Jekyll generated
36+
# artifact with the ones from the reports, they all come together where they should.
37+
REPORT_SITE_RELATIVE_DIR: 'userguide/dev/reports'
38+
39+
permissions:
40+
contents: read
41+
42+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
43+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
44+
concurrency:
45+
group: "pages"
46+
cancel-in-progress: false
47+
48+
jobs:
49+
# Jekyll build job
50+
# Keep in sync with docs test workflow in `icu_docs.yml`
51+
buildsite:
52+
runs-on: ubuntu-22.04 # Updated in BRS
53+
steps:
54+
- name: Checkout
55+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
56+
- name: Setup Ruby
57+
uses: ruby/setup-ruby@09a7688d3b55cf0e976497ff046b70949eeaccfd # v1.288.0
58+
with:
59+
ruby-version: '2.7.4' # Not needed with a .ruby-version file
60+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
61+
cache-version: 0 # Increment this number if you need to re-download cached gems
62+
- name: Setup Pages
63+
id: pages
64+
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
65+
with:
66+
generator_config_file: docs/_config.yml
67+
- name: Build with Jekyll
68+
# Outputs to the './_site' directory by default
69+
run: |
70+
cd docs # root directory of markdown, also contains Jekyll configs, etc.
71+
bundle install
72+
# The baseurl arg is parsed from the `baseurl` field of _config.yml.
73+
bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
74+
env:
75+
JEKYLL_ENV: production
76+
- name: Upload artifact
77+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
78+
with:
79+
name: site-artifact
80+
path: docs/_site
81+
retention-days: 3
82+
83+
# Generate a complete Errorprone report, with all checks enabled, without failing
84+
errorprone:
85+
runs-on: ubuntu-22.04 # Updated in BRS
86+
steps:
87+
- name: Checkout repo files
88+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
89+
- name: Set up JDK
90+
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
91+
with:
92+
java-version: '21'
93+
distribution: 'temurin'
94+
- name: Run tests with errorprone enabled
95+
run: mvn clean test -DskipTests -DskipITs -l /tmp/errorprone_all.log -P errorprone-all
96+
- name: Generate html pages from the errorprone report
97+
env:
98+
REPORT_FOLDER_ERRORPRONE: ${{ env.REPORT_ROOT_DIR }}/${{ env.REPORT_SITE_RELATIVE_DIR }}/icu4j_errorprone
99+
run: |
100+
mkdir -p ${REPORT_FOLDER_ERRORPRONE}
101+
mvn exec:java \
102+
-f icu4j/tools/build/ \
103+
-P errorprone_report \
104+
-DlogFile=/tmp/errorprone_all.log \
105+
-DoutDir=${REPORT_FOLDER_ERRORPRONE}
106+
- name: Upload artifact
107+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
108+
with:
109+
name: errorprone-artifact
110+
path: ${{ env.REPORT_ROOT_DIR }}
111+
retention-days: 3
112+
113+
# Generate a JaCoCo coverage report
114+
coverage:
115+
runs-on: ubuntu-22.04 # Updated in BRS
116+
steps:
117+
- name: Checkout repo files
118+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
119+
- name: Set up JDK
120+
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
121+
with:
122+
java-version: '21'
123+
distribution: 'temurin'
124+
- name: Run tests with coverage enabled
125+
run: mvn clean install site site:stage -P coverage
126+
- name: Setup JaCoCo CLI
127+
run: |
128+
rm -fr target/jacoco
129+
# Download jacoco CLI
130+
mvn dependency:copy \
131+
-Dartifact=org.jacoco:jacoco:LATEST:zip \
132+
-DoutputDirectory=target/jacoco \
133+
-Dmdep.stripVersion=true \
134+
-q -ntp
135+
unzip -q target/jacoco/jacoco.zip -d target/jacoco
136+
- name: Generate JaCoCo report merged from all modules
137+
env:
138+
REPORT_FOLDER_COVERAGE: ${{ env.REPORT_ROOT_DIR }}/${{ env.REPORT_SITE_RELATIVE_DIR }}/icu4j_coverage
139+
run: |
140+
artifact_version="`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`"
141+
mkdir -p ${REPORT_FOLDER_COVERAGE}
142+
java -jar target/jacoco/lib/jacococli.jar report \
143+
icu4j/main/core/target/jacoco.exec \
144+
icu4j/main/collate/target/jacoco.exec \
145+
icu4j/main/common_tests/target/jacoco.exec \
146+
icu4j/main/framework/target/jacoco.exec \
147+
icu4j/main/translit/target/jacoco.exec \
148+
icu4j/main/charset/target/jacoco.exec \
149+
--classfiles icu4j/main/core/target/core-${artifact_version}.jar \
150+
--classfiles icu4j/main/collate/target/collate-${artifact_version}.jar \
151+
--classfiles icu4j/main/currdata/target/currdata-${artifact_version}.jar \
152+
--classfiles icu4j/main/langdata/target/langdata-${artifact_version}.jar \
153+
--classfiles icu4j/main/regiondata/target/regiondata-${artifact_version}.jar \
154+
--classfiles icu4j/main/translit/target/translit-${artifact_version}.jar \
155+
--classfiles icu4j/main/charset/target/icu4j-charset-${artifact_version}.jar \
156+
--sourcefiles icu4j/main/core/src/main/java \
157+
--sourcefiles icu4j/main/collate/src/main/java \
158+
--sourcefiles icu4j/main/currdata/src/main/java \
159+
--sourcefiles icu4j/main/langdata/src/main/java \
160+
--sourcefiles icu4j/main/regiondata/src/main/java \
161+
--sourcefiles icu4j/main/translit/src/main/java \
162+
--sourcefiles icu4j/main/charset/src/main/java \
163+
--encoding utf-8 \
164+
--csv ${REPORT_FOLDER_COVERAGE}/jacoco.csv \
165+
--xml ${REPORT_FOLDER_COVERAGE}/jacoco.xml \
166+
--html ${REPORT_FOLDER_COVERAGE}/html
167+
- name: Upload artifact
168+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
169+
with:
170+
name: coverage-artifact
171+
path: ${{ env.REPORT_ROOT_DIR }}
172+
retention-days: 3
173+
174+
# Merge the artifacts from several jobs into one, for deployment
175+
merge_artifacts:
176+
permissions:
177+
pages: write # to deploy to Pages
178+
id-token: write # to verify the deployment originates from an appropriate source
179+
runs-on: ubuntu-22.04 # Updated in BRS
180+
needs: [buildsite, errorprone, coverage]
181+
steps:
182+
- name: Download artifacts
183+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
184+
with: # not using a name, so than all artifacts of the run are downloaded, then merged
185+
path: docs/_site
186+
merge-multiple: true
187+
- name: Upload artifact
188+
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
189+
with:
190+
path: docs/_site
191+
retention-days: 3
192+
193+
# Deployment job
194+
deploy:
195+
permissions:
196+
pages: write # to deploy to Pages
197+
id-token: write # to verify the deployment originates from an appropriate source
198+
environment:
199+
name: github-pages
200+
url: ${{ steps.deployment.outputs.page_url }}
201+
runs-on: ubuntu-22.04 # Updated in BRS
202+
needs: merge_artifacts
203+
steps:
204+
- name: Deploy to GitHub Pages
205+
id: deployment
206+
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5

docs/userguide/dev/reports.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
layout: default
3+
title: CI Reports
4+
parent: Contributors
5+
---
6+
7+
# CI Reports
8+
{: .no_toc }
9+
10+
## Contents
11+
{: .no_toc .text-delta }
12+
13+
1. TOC
14+
{:toc}
15+
16+
---
17+
18+
<!--
19+
© 2026 and later: Unicode, Inc. and others.
20+
License & terms of use: http://www.unicode.org/copyright.html
21+
-->
22+
23+
ICU is tested thoroughly through a variety of tests
24+
(code coverage, quality control, etc.). \
25+
Some of these produce reports that can be accessed here.
26+
27+
* ICU4J
28+
* Errorprone
29+
* [HTML report, all issues together in one big table](reports/icu4j_errorprone/errorprone1.html)
30+
* [HTML report, issues grouped by severity and then by type](reports/icu4j_errorprone/errorprone2.html)
31+
* [Markdown report](reports/icu4j_errorprone/errorprone.md)
32+
* [TSV report, for tooling or importing into a spreadsheet application](reports/icu4j_errorprone/errorprone.tsv)
33+
* Code Coverage using JaCoCo
34+
* [HTML report](reports/icu4j_coverage/html)
35+
* [XML report, for tooling](reports/icu4j_coverage/jacoco.xml) \
36+
WARNING, this is big, and will take a long time if opened in browser.
37+
* [CSV report, for tooling or importing into a spreadsheet application](reports/icu4j_coverage/jacoco.csv)

icu4j/tools/build/pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<properties>
1717
<!-- Arguments for the errorprone report generation -->
1818
<logFile>/tmp/errorprone.log</logFile>
19+
<outDir>${project.build.directory}/errorprone_report</outDir>
1920
<srcBaseUrl>https://github.com/unicode-org/icu/blob/main/</srcBaseUrl>
2021
</properties>
2122

@@ -66,6 +67,8 @@
6667
<argument>${logFile}</argument>
6768
<argument>--srcBaseUrl</argument>
6869
<argument>${srcBaseUrl}</argument>
70+
<argument>--outDir</argument>
71+
<argument>${outDir}</argument>
6972
</arguments>
7073
</configuration>
7174
</plugin>

pom.xml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,9 @@
821821
822822
rm -fr target/jacoco
823823
824+
# If somehow the latest version of jacoco becomes incompatible,
825+
# use the value of the `jacoco-maven-plugin.version` property.
826+
# And consider updating to the latest version.
824827
mvn dependency:copy \
825828
-Dartifact=org.jacoco:jacoco:LATEST:zip \
826829
-DoutputDirectory=target/jacoco \
@@ -829,20 +832,26 @@
829832
830833
unzip -q target/jacoco/jacoco.zip -d target/jacoco
831834
835+
rm -fr target/jacocoreport
836+
mkdir -p target/jacocoreport
837+
838+
artifact_version="`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`"
839+
840+
# Sorry, it's hard to copy paste from here, but xml does not allow double-minus in comments
832841
java -jar target/jacoco/lib/jacococli.jar report \
833842
icu4j/main/core/target/jacoco.exec \
834843
icu4j/main/collate/target/jacoco.exec \
835844
icu4j/main/common_tests/target/jacoco.exec \
836845
icu4j/main/framework/target/jacoco.exec \
837846
icu4j/main/translit/target/jacoco.exec \
838847
icu4j/main/charset/target/jacoco.exec \
839-
\-\-classfiles icu4j/main/core/target/core-79.0.1-SNAPSHOT.jar \
840-
\-\-classfiles icu4j/main/collate/target/collate-79.0.1-SNAPSHOT.jar \
841-
\-\-classfiles icu4j/main/currdata/target/currdata-79.0.1-SNAPSHOT.jar \
842-
\-\-classfiles icu4j/main/langdata/target/langdata-79.0.1-SNAPSHOT.jar \
843-
\-\-classfiles icu4j/main/regiondata/target/regiondata-79.0.1-SNAPSHOT.jar \
844-
\-\-classfiles icu4j/main/translit/target/translit-79.0.1-SNAPSHOT.jar \
845-
\-\-classfiles icu4j/main/charset/target/icu4j-charset-79.0.1-SNAPSHOT.jar \
848+
\-\-classfiles icu4j/main/core/target/core-${artifact_version}.jar \
849+
\-\-classfiles icu4j/main/collate/target/collate-${artifact_version}.jar \
850+
\-\-classfiles icu4j/main/currdata/target/currdata-${artifact_version}.jar \
851+
\-\-classfiles icu4j/main/langdata/target/langdata-${artifact_version}.jar \
852+
\-\-classfiles icu4j/main/regiondata/target/regiondata-${artifact_version}.jar \
853+
\-\-classfiles icu4j/main/translit/target/translit-${artifact_version}.jar \
854+
\-\-classfiles icu4j/main/charset/target/icu4j-charset-${artifact_version}.jar \
846855
\-\-sourcefiles icu4j/main/core/src/main/java \
847856
\-\-sourcefiles icu4j/main/collate/src/main/java \
848857
\-\-sourcefiles icu4j/main/currdata/src/main/java \

0 commit comments

Comments
 (0)