Skip to content

Commit f14b24a

Browse files
committed
ICU-22324 Allow single Maven cache creation and multiple read-only usage
1 parent 4fcf8d2 commit f14b24a

File tree

3 files changed

+181
-71
lines changed

3 files changed

+181
-71
lines changed

.github/workflows/cache_retain.yml

+13-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ on:
2626
# this cron schedule is set to run every 6 days to ensure retention
2727
- cron: '0 12 */6 * *'
2828

29+
env:
30+
SHARED_MVN_ARGS: '--show-version --no-transfer-progress'
31+
2932
permissions:
3033
contents: read
3134

@@ -44,8 +47,15 @@ jobs:
4447
with:
4548
distribution: 'temurin'
4649
java-version: '11'
47-
cache: maven
50+
- name: Restore read-only cache of local Maven repository
51+
uses: actions/cache/restore@v3
52+
id: cache
53+
with:
54+
path: ~/.m2/repository
55+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
56+
restore-keys: |
57+
${{ runner.os }}-maven-
4858
- name: Run Maven unit & integration tests
4959
run: |
50-
cd icu4j/maven-build;
51-
mvn --batch-mode verify
60+
cd icu4j;
61+
mvn ${SHARED_MVN_ARGS} verify

.github/workflows/icu_ci.yml

+66-59
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
1818

1919
env:
20-
MAVEN_ARGS: '--show-version --no-transfer-progress'
20+
SHARED_MVN_ARGS: '--show-version --no-transfer-progress'
2121

2222
permissions:
2323
contents: read
@@ -39,12 +39,11 @@ jobs:
3939
# Regex note: (?! ... ) is a negative lookahead. Succeed if the pattern is not present.
4040
set +o pipefail && make doc 2>&1 | tee doxygen.log && ( ! grep -P 'warning:(?! .* file .?Doxyfile)' doxygen.log )
4141
42-
# ICU4J build and unit test using Maven
43-
icu4j-mvn-build-and-test:
44-
strategy:
45-
fail-fast: false
46-
matrix:
47-
java-version: [ '8', '11', '17' ]
42+
# Initialize the Maven artifact cache
43+
#
44+
# This job is created according to the cache strategy of reuse from a single job:
45+
# https://github.com/actions/cache/blob/main/caching-strategies.md#make-cache-read-only--reuse-cache-from-centralized-job
46+
icu4j-mvn-init-cache:
4847
runs-on: ubuntu-latest
4948
steps:
5049
- name: Checkout and setup
@@ -53,83 +52,63 @@ jobs:
5352
lfs: true
5453
- name: Checkout lfs objects
5554
run: git lfs pull
55+
- name: Cache local Maven repository
56+
uses: actions/cache@v3
57+
with:
58+
path: ~/.m2/repository
59+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
5660
- uses: actions/setup-java@v3
5761
with:
5862
distribution: 'temurin'
59-
java-version: ${{ matrix.java-version }}
60-
- name: ICU4J
63+
java-version: '8'
64+
# Download all of the artifacts needed for the code and build plugins, but
65+
# exclude any needed by profiles depending on system artifacts
66+
- name: Download all artifacts
6167
run: |
6268
cd icu4j;
63-
mvn install
64-
- name: List failures (if any)
65-
run: |
66-
cd icu4j && cat `find . -name surefire-reports -type d -exec grep -l -r --include="*.txt" FAILED {} \;`;
67-
if: ${{ failure() }}
68-
69-
# ICU4J build and unit tests using Maven
69+
mvn ${SHARED_MVN_ARGS} dependency:go-offline -P '!old_jdk_taglet'
70+
71+
# ICU4J build and unit test using Maven
7072
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
71-
72-
# Run `test` to execute unit tests and ensure it is possible for tests to run even without packaging submodule
73-
# dependencies as jar files
74-
icu4j-test-maven:
75-
name: Run unit tests with Maven for Java version
76-
runs-on: ubuntu-latest
77-
# Make this unit test target job depend on a later phase target job to prevent race condition when
78-
# trying to persist the Maven cache to the Github cache, knowing that artifacts needed for
79-
# the later phase `verify` are a superset of the artifacts needed for the earlier phase `test`.
80-
needs: icu4j-verify-maven
73+
icu4j-mvn-build-and-test:
74+
needs: icu4j-mvn-init-cache
8175
strategy:
8276
fail-fast: false
8377
matrix:
8478
java-version: [ '8', '11', '17' ]
85-
steps:
86-
- name: Checkout and setup
87-
uses: actions/checkout@v3
88-
with:
89-
lfs: true
90-
- name: Checkout lfs objects
91-
run: git lfs pull
92-
- uses: actions/setup-java@v3
93-
with:
94-
distribution: 'temurin'
95-
java-version: ${{ matrix.java-version }}
96-
cache: maven
97-
- name: Run Maven test
98-
run: |
99-
cd icu4j;
100-
mvn --batch-mode test
101-
102-
# Run `verify` to ensure that `package` (creating .jar files) and `integration-test` (special setup for localespi tests) work
103-
icu4j-verify-maven:
104-
name: Run integration tests with Maven for Java version
10579
runs-on: ubuntu-latest
106-
strategy:
107-
fail-fast: false
108-
matrix:
109-
java-version: [ '8', '11', '17' ]
11080
steps:
11181
- name: Checkout and setup
11282
uses: actions/checkout@v3
11383
with:
11484
lfs: true
11585
- name: Checkout lfs objects
11686
run: git lfs pull
87+
- name: Restore read-only cache of local Maven repository
88+
uses: actions/cache/restore@v3
89+
id: cache
90+
with:
91+
path: ~/.m2/repository
92+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
93+
restore-keys: |
94+
${{ runner.os }}-maven-
11795
- uses: actions/setup-java@v3
11896
with:
11997
distribution: 'temurin'
12098
java-version: ${{ matrix.java-version }}
121-
cache: maven
122-
# The Maven `verify` phase causes the following to happen first, and in order:
123-
# build/compile (`compile`), unit tests (`test`), Jar building (`package`),
124-
# integration tests, if any (`integration-test`)
125-
- name: Run Maven verify
99+
- name: ICU4J
126100
run: |
127101
cd icu4j;
128-
mvn --batch-mode verify
102+
mvn ${SHARED_MVN_ARGS} verify
103+
- name: List failures (if any)
104+
run: |
105+
cd icu4j && cat `find . -name surefire-reports -type d -exec grep -l -r --include="*.txt" FAILED {} \;`;
106+
if: ${{ failure() }}
129107

130108
# ICU4J build and unit test under lstm
131109
lstm-icu4j-build-and-test:
132110
if: false # TODO(ICU-22505)
111+
needs: icu4j-mvn-init-cache
133112
runs-on: ubuntu-latest
134113
steps:
135114
- name: Checkout and setup
@@ -138,6 +117,15 @@ jobs:
138117
lfs: true
139118
- name: Checkout lfs objects
140119
run: git lfs pull
120+
- name: Restore read-only cache of local Maven repository
121+
uses: actions/cache/restore@v3
122+
id: cache
123+
with:
124+
path: ~/.m2/repository
125+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
126+
restore-keys: |
127+
${{ runner.os }}-maven-
128+
lookup-only: true
141129
- uses: actions/setup-java@v3
142130
with:
143131
distribution: 'temurin'
@@ -152,7 +140,7 @@ jobs:
152140
- name: ICU4J
153141
run: |
154142
cd icu4j;
155-
mvn install
143+
mvn ${SHARED_MVN_ARGS} verify
156144
- name: List failures (if any)
157145
run: |
158146
cd icu4j && cat `find . -name surefire-reports -type d -exec grep -l -r --include="*.txt" FAILED {} \;`;
@@ -161,6 +149,7 @@ jobs:
161149
# ICU4J build and unit test under adaboost
162150
adaboost-icu4j-build-and-test:
163151
if: false # Temporary disable, until we disable the .jar creation from C and distribute the individual files
152+
needs: icu4j-mvn-init-cache
164153
runs-on: ubuntu-latest
165154
steps:
166155
- name: Checkout and setup
@@ -169,6 +158,15 @@ jobs:
169158
lfs: true
170159
- name: Checkout lfs objects
171160
run: git lfs pull
161+
- name: Restore read-only cache of local Maven repository
162+
uses: actions/cache/restore@v3
163+
id: cache
164+
with:
165+
path: ~/.m2/repository
166+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
167+
restore-keys: |
168+
${{ runner.os }}-maven-
169+
lookup-only: true
172170
- uses: actions/setup-java@v3
173171
with:
174172
distribution: 'temurin'
@@ -183,7 +181,7 @@ jobs:
183181
- name: ICU4J
184182
run: |
185183
cd icu4j;
186-
mvn -Dcom.ibm.icu.impl.breakiter.useMLPhraseBreaking=true install
184+
mvn ${SHARED_MVN_ARGS} -Dcom.ibm.icu.impl.breakiter.useMLPhraseBreaking=true verify
187185
- name: List failures (if any)
188186
run: |
189187
cd icu4j && cat `find . -name surefire-reports -type d -exec grep -l -r --include="*.txt" FAILED {} \;`;
@@ -499,10 +497,19 @@ jobs:
499497

500498
# Verify icu4c release tools buildability.
501499
icu4c-release-tools:
500+
needs: icu4j-mvn-init-cache
502501
runs-on: ubuntu-latest
503502
steps:
504503
- uses: actions/checkout@v3
505-
- run: mvn -f tools/release/java/pom.xml package dependency:analyze
504+
- name: Restore read-only cache of local Maven repository
505+
uses: actions/cache/restore@v3
506+
id: cache
507+
with:
508+
path: ~/.m2/repository
509+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
510+
restore-keys: |
511+
${{ runner.os }}-maven-
512+
- run: mvn ${SHARED_MVN_ARGS} -f tools/release/java/pom.xml package dependency:analyze
506513

507514
# Run unit tests with UCONFIG_NO_XXX variations.
508515
uconfig-unit-tests:

0 commit comments

Comments
 (0)