Skip to content

Commit

Permalink
ICU-22324 Allow single Maven cache creation and multiple read-only usage
Browse files Browse the repository at this point in the history
  • Loading branch information
echeran committed Sep 21, 2023
1 parent 4fcf8d2 commit f14b24a
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 71 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/cache_retain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ on:
# this cron schedule is set to run every 6 days to ensure retention
- cron: '0 12 */6 * *'

env:
SHARED_MVN_ARGS: '--show-version --no-transfer-progress'

permissions:
contents: read

Expand All @@ -44,8 +47,15 @@ jobs:
with:
distribution: 'temurin'
java-version: '11'
cache: maven
- name: Restore read-only cache of local Maven repository
uses: actions/cache/restore@v3
id: cache
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Run Maven unit & integration tests
run: |
cd icu4j/maven-build;
mvn --batch-mode verify
cd icu4j;
mvn ${SHARED_MVN_ARGS} verify
125 changes: 66 additions & 59 deletions .github/workflows/icu_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow

env:
MAVEN_ARGS: '--show-version --no-transfer-progress'
SHARED_MVN_ARGS: '--show-version --no-transfer-progress'

permissions:
contents: read
Expand All @@ -39,12 +39,11 @@ jobs:
# Regex note: (?! ... ) is a negative lookahead. Succeed if the pattern is not present.
set +o pipefail && make doc 2>&1 | tee doxygen.log && ( ! grep -P 'warning:(?! .* file .?Doxyfile)' doxygen.log )
# ICU4J build and unit test using Maven
icu4j-mvn-build-and-test:
strategy:
fail-fast: false
matrix:
java-version: [ '8', '11', '17' ]
# Initialize the Maven artifact cache
#
# This job is created according to the cache strategy of reuse from a single job:
# https://github.com/actions/cache/blob/main/caching-strategies.md#make-cache-read-only--reuse-cache-from-centralized-job
icu4j-mvn-init-cache:
runs-on: ubuntu-latest
steps:
- name: Checkout and setup
Expand All @@ -53,83 +52,63 @@ jobs:
lfs: true
- name: Checkout lfs objects
run: git lfs pull
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
- name: ICU4J
java-version: '8'
# Download all of the artifacts needed for the code and build plugins, but
# exclude any needed by profiles depending on system artifacts
- name: Download all artifacts
run: |
cd icu4j;
mvn install
- name: List failures (if any)
run: |
cd icu4j && cat `find . -name surefire-reports -type d -exec grep -l -r --include="*.txt" FAILED {} \;`;
if: ${{ failure() }}

# ICU4J build and unit tests using Maven
mvn ${SHARED_MVN_ARGS} dependency:go-offline -P '!old_jdk_taglet'
# ICU4J build and unit test using Maven
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# Run `test` to execute unit tests and ensure it is possible for tests to run even without packaging submodule
# dependencies as jar files
icu4j-test-maven:
name: Run unit tests with Maven for Java version
runs-on: ubuntu-latest
# Make this unit test target job depend on a later phase target job to prevent race condition when
# trying to persist the Maven cache to the Github cache, knowing that artifacts needed for
# the later phase `verify` are a superset of the artifacts needed for the earlier phase `test`.
needs: icu4j-verify-maven
icu4j-mvn-build-and-test:
needs: icu4j-mvn-init-cache
strategy:
fail-fast: false
matrix:
java-version: [ '8', '11', '17' ]
steps:
- name: Checkout and setup
uses: actions/checkout@v3
with:
lfs: true
- name: Checkout lfs objects
run: git lfs pull
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
cache: maven
- name: Run Maven test
run: |
cd icu4j;
mvn --batch-mode test
# Run `verify` to ensure that `package` (creating .jar files) and `integration-test` (special setup for localespi tests) work
icu4j-verify-maven:
name: Run integration tests with Maven for Java version
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java-version: [ '8', '11', '17' ]
steps:
- name: Checkout and setup
uses: actions/checkout@v3
with:
lfs: true
- name: Checkout lfs objects
run: git lfs pull
- name: Restore read-only cache of local Maven repository
uses: actions/cache/restore@v3
id: cache
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
cache: maven
# The Maven `verify` phase causes the following to happen first, and in order:
# build/compile (`compile`), unit tests (`test`), Jar building (`package`),
# integration tests, if any (`integration-test`)
- name: Run Maven verify
- name: ICU4J
run: |
cd icu4j;
mvn --batch-mode verify
mvn ${SHARED_MVN_ARGS} verify
- name: List failures (if any)
run: |
cd icu4j && cat `find . -name surefire-reports -type d -exec grep -l -r --include="*.txt" FAILED {} \;`;
if: ${{ failure() }}

# ICU4J build and unit test under lstm
lstm-icu4j-build-and-test:
if: false # TODO(ICU-22505)
needs: icu4j-mvn-init-cache
runs-on: ubuntu-latest
steps:
- name: Checkout and setup
Expand All @@ -138,6 +117,15 @@ jobs:
lfs: true
- name: Checkout lfs objects
run: git lfs pull
- name: Restore read-only cache of local Maven repository
uses: actions/cache/restore@v3
id: cache
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
lookup-only: true
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
Expand All @@ -152,7 +140,7 @@ jobs:
- name: ICU4J
run: |
cd icu4j;
mvn install
mvn ${SHARED_MVN_ARGS} verify
- name: List failures (if any)
run: |
cd icu4j && cat `find . -name surefire-reports -type d -exec grep -l -r --include="*.txt" FAILED {} \;`;
Expand All @@ -161,6 +149,7 @@ jobs:
# ICU4J build and unit test under adaboost
adaboost-icu4j-build-and-test:
if: false # Temporary disable, until we disable the .jar creation from C and distribute the individual files
needs: icu4j-mvn-init-cache
runs-on: ubuntu-latest
steps:
- name: Checkout and setup
Expand All @@ -169,6 +158,15 @@ jobs:
lfs: true
- name: Checkout lfs objects
run: git lfs pull
- name: Restore read-only cache of local Maven repository
uses: actions/cache/restore@v3
id: cache
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
lookup-only: true
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
Expand All @@ -183,7 +181,7 @@ jobs:
- name: ICU4J
run: |
cd icu4j;
mvn -Dcom.ibm.icu.impl.breakiter.useMLPhraseBreaking=true install
mvn ${SHARED_MVN_ARGS} -Dcom.ibm.icu.impl.breakiter.useMLPhraseBreaking=true verify
- name: List failures (if any)
run: |
cd icu4j && cat `find . -name surefire-reports -type d -exec grep -l -r --include="*.txt" FAILED {} \;`;
Expand Down Expand Up @@ -499,10 +497,19 @@ jobs:

# Verify icu4c release tools buildability.
icu4c-release-tools:
needs: icu4j-mvn-init-cache
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: mvn -f tools/release/java/pom.xml package dependency:analyze
- name: Restore read-only cache of local Maven repository
uses: actions/cache/restore@v3
id: cache
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- run: mvn ${SHARED_MVN_ARGS} -f tools/release/java/pom.xml package dependency:analyze

# Run unit tests with UCONFIG_NO_XXX variations.
uconfig-unit-tests:
Expand Down
Loading

1 comment on commit f14b24a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: f14b24a Previous: 4fcf8d2 Ratio
TestCharsetDecoderICU 4.708575014661415 ns/iter 2.1359633856750917 ns/iter 2.20

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.