]> granicus.if.org Git - icu/commitdiff
ICU-22116 Update CI job for ICU4J to use Java 8 instead of Java 7
authorElango Cheran <elango@unicode.org>
Sun, 4 Sep 2022 01:22:04 +0000 (01:22 +0000)
committerElango <elango@unicode.org>
Tue, 6 Sep 2022 16:09:22 +0000 (09:09 -0700)
See #2173

.github/workflows/icu_ci.yml
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRulesTest.java

index 76d77d98d58726f923150d9d0775602e6978c921..90bce1ed542c07b3b3a03582f381d175a27d98b5 100644 (file)
@@ -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: |
index a96071ec18ee9ebfef5b704c8fefff61621d06ba..3a86e1fa29ac83694502f75e4a96150bd72f3e40 100644 (file)
@@ -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<String, PluralRules> keywordToRule = new HashMap<>();
-            Collection<DecimalQuantitySamples> samples = new LinkedHashSet<>();
 
+            // get the set of all rule samples from all of the keywords of the locale's rule
+            Set<DecimalQuantitySamples> 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<DecimalQuantity, String> collisionTest = new LinkedHashMap();
-            for (DecimalQuantitySamples sample3 : samples) {
-                Set<DecimalQuantitySamplesRange> 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<String, PluralRules> 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<DecimalQuantitySamplesRange> 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<DecimalQuantity> items = ranges.flatMap(range -> {
+                return Arrays.stream(new DecimalQuantity[] {range.start, range.end});
+            });
+
+            items.forEach(item -> {
+                collisionTest.clear();
+                for (Entry<String, PluralRules> 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);
                     }
                 }
-            }
+            });
         }
     }