Skip to content

Commit

Permalink
ICU-22116 Update CI job for ICU4J to use Java 8 instead of Java 7
Browse files Browse the repository at this point in the history
See #2173
  • Loading branch information
echeran committed Sep 6, 2022
1 parent baa104b commit 6e3a923
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 58 deletions.
37 changes: 10 additions & 27 deletions .github/workflows/icu_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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: |
Expand All @@ -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: |
Expand All @@ -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: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@
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;
Expand Down Expand Up @@ -429,15 +432,20 @@ public void testUniqueRules() {
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;
}
Expand All @@ -452,32 +460,35 @@ public void testUniqueRules() {
}

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);
}
}
}
});
}
}

Expand Down

0 comments on commit 6e3a923

Please sign in to comment.