From: Elango Cheran Date: Sun, 4 Sep 2022 01:22:04 +0000 (+0000) Subject: ICU-22116 Update CI job for ICU4J to use Java 8 instead of Java 7 X-Git-Tag: cldr/2022-09-07~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e3a9230563b97cb925723a6d9e91888396f2035;p=icu ICU-22116 Update CI job for ICU4J to use Java 8 instead of Java 7 See #2173 --- diff --git a/.github/workflows/icu_ci.yml b/.github/workflows/icu_ci.yml index 76d77d98d58..90bce1ed542 100644 --- a/.github/workflows/icu_ci.yml +++ b/.github/workflows/icu_ci.yml @@ -30,8 +30,8 @@ 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 ) - # Java7 ICU4J build and unit test - java7-icu4j-build-and-test: + # Java8 ICU4J build and unit test + java8-icu4j-build-and-test: runs-on: ubuntu-latest steps: - name: Checkout and setup @@ -40,30 +40,10 @@ jobs: lfs: true - name: Checkout lfs objects run: git lfs pull - - uses: actions/setup-java@v1 + - uses: actions/setup-java@v3 with: + distribution: 'temurin' java-version: '8' - - name: Cache for Java 7 tarball - id: cache-java7 - uses: actions/cache@v2 - with: - path: java7-tarball - key: ${{ runner.os }}-java7-tarball - - name: Download Java 7 - if: steps.cache-java7.outputs.cache-hit != 'true' - run: | - mkdir -p java7-tarball - download_url="https://download.java.net/openjdk/jdk7u75/ri/openjdk-7u75-b13-linux-x64-18_dec_2014.tar.gz" - wget -O java7-tarball/java_package.tar.gz $download_url - pushd java7-tarball - gunzip java_package.tar.gz - tar xvf java_package.tar - popd - - name: Configure Ant build to use Java 7 JRE - run: | - echo "java7.bootclasspath" > $RUNNER_TEMP/draft - ls java7-tarball/java-se-7u75-ri/jre/lib/*.jar|paste -sd ":" - >> $RUNNER_TEMP/draft - paste -sd "=" < $RUNNER_TEMP/draft > icu4j/build-local.properties - name: ICU4J run: | cd icu4j; @@ -86,8 +66,9 @@ jobs: lfs: true - name: Checkout lfs objects run: git lfs pull - - uses: actions/setup-java@v1 + - uses: actions/setup-java@v3 with: + distribution: 'temurin' java-version: '11' - name: ICU4J run: | @@ -110,8 +91,9 @@ jobs: lfs: true - name: Checkout lfs objects run: git lfs pull - - uses: actions/setup-java@v1 + - uses: actions/setup-java@v3 with: + distribution: 'temurin' java-version: '16' - name: ICU4J run: | @@ -134,8 +116,9 @@ jobs: lfs: true - name: Checkout lfs objects run: git lfs pull - - uses: actions/setup-java@v1 + - uses: actions/setup-java@v3 with: + distribution: 'temurin' java-version: '11' - name: Config LSTM and Rebuild data jar run: | diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRulesTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRulesTest.java index a96071ec18e..3a86e1fa29a 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRulesTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRulesTest.java @@ -29,11 +29,14 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.junit.Test; import org.junit.runner.RunWith; @@ -429,15 +432,20 @@ public class PluralRulesTest extends TestFmwk { main: for (ULocale locale : factory.getAvailableULocales()) { PluralRules rules = factory.forLocale(locale); Map keywordToRule = new HashMap<>(); - Collection samples = new LinkedHashSet<>(); + // get the set of all rule samples from all of the keywords of the locale's rule + Set samples = + rules.getKeywords() + .stream() + .flatMap(keyword -> { + return Arrays.stream(SampleType.values()) + .map(sampleType -> rules.getDecimalSamples(keyword, sampleType)); + }) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + + // take the rule substring per keyword, and create a map keyed by keyword for a new rules object of that rule substring for (String keyword : rules.getKeywords()) { - for (SampleType sampleType : SampleType.values()) { - DecimalQuantitySamples samples2 = rules.getDecimalSamples(keyword, sampleType); - if (samples2 != null) { - samples.add(samples2); - } - } if (keyword.equals("other")) { continue; } @@ -452,32 +460,35 @@ public class PluralRulesTest extends TestFmwk { } Map collisionTest = new LinkedHashMap(); - for (DecimalQuantitySamples sample3 : samples) { - Set samples2 = sample3.getSamples(); - if (samples2 == null) { - continue; - } - for (DecimalQuantitySamplesRange sample : samples2) { - for (int i = 0; i < 1; ++i) { - DecimalQuantity item = i == 0 ? sample.start : sample.end; - collisionTest.clear(); - for (Entry entry : keywordToRule.entrySet()) { - PluralRules rule = entry.getValue(); - String foundKeyword = rule.select(item); - if (foundKeyword.equals("other")) { - continue; - } - String old = collisionTest.get(item); - if (old != null) { - errln(locale + "\tNon-unique rules: " + item + " => " + old + " & " + foundKeyword); - rule.select(item); - } else { - collisionTest.put(item, foundKeyword); - } - } + + // get all of the sample ranges from all of the samples + Stream ranges = samples.stream() + .map(DecimalQuantitySamples::getSamples) + .filter(Objects::nonNull) + .flatMap(Set::stream); + + // get all of the sample values at the endpoints of each sample range + Stream items = ranges.flatMap(range -> { + return Arrays.stream(new DecimalQuantity[] {range.start, range.end}); + }); + + items.forEach(item -> { + collisionTest.clear(); + for (Entry entry : keywordToRule.entrySet()) { + PluralRules rule = entry.getValue(); + String foundKeyword = rule.select(item); + if (foundKeyword.equals("other")) { + continue; + } + String old = collisionTest.get(item); + if (old != null) { + errln(locale + "\tNon-unique rules: " + item + " => " + old + " & " + foundKeyword); + rule.select(item); + } else { + collisionTest.put(item, foundKeyword); } } - } + }); } }