Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into casemap-graduate
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Aug 8, 2023
2 parents 834dcd5 + 7dd1460 commit 6f94526
Show file tree
Hide file tree
Showing 125 changed files with 33,060 additions and 93 deletions.
21 changes: 9 additions & 12 deletions .github/workflows/artifacts-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,12 @@ jobs:
- name: Upload wasm-demo bundle to Google Cloud Storage
run: |
# gsutil cors set ffi/diplomat/js/examples/wasm-demo/cors-config-file.json gs://${{ env.GCP_PR_BUCKET_ID }}
gsutil -m cp -r ffi/diplomat/js/examples/wasm-demo/dist/ gs://${{ env.GCP_PR_BUCKET_ID }}/gha/${{ github.sha }}/wasm-demo
gsutil -m cp -r ffi/diplomat/js/examples/wasm-demo/dist/ gs://${{ env.GCP_MAIN_BUCKET_ID }}/gha/wasm-demo
- name: "⭐⭐⭐ Links to Uploaded Artifacts ⭐⭐⭐"
run: |
echo "::group::Wasm Demo Preview"
echo "https://storage.googleapis.com/icu4x-pr-artifacts/gha/${{ github.sha }}/wasm-demo/index.html"
echo "https://storage.googleapis.com/${{ env.GCP_MAIN_BUCKET_ID }}/gha/wasm-demo/index.html"
echo "::endgroup::"
bench-perf:
Expand Down Expand Up @@ -285,7 +284,7 @@ jobs:
if: success() || failure()
run: |
git checkout empty
gsutil -m cp -r benchmarks/perf/${{ matrix.component }} gs://${{ env.GCP_PR_BUCKET_ID }}/gha/${{ github.sha }}/benchmarks/perf/${{ matrix.component }}
gsutil -m cp -r benchmarks/perf/${{ matrix.component }} gs://${{ env.GCP_MAIN_BUCKET_ID }}/gha/benchmarks/perf/${{ matrix.component }}
# Run examples with dhat-rs in order to collect memory heap size metrics. These
# metrics will then be charted over time. See tools/benchmark/memory/README.md for
Expand Down Expand Up @@ -401,7 +400,7 @@ jobs:
if: success() || failure()
run: |
git checkout empty
gsutil -m cp -r benchmarks/memory/${{ matrix.os }} gs://${{ env.GCP_PR_BUCKET_ID }}/gha/${{ github.sha }}/benchmarks/memory/${{ matrix.os }}
gsutil -m cp -r benchmarks/memory/${{ matrix.os }} gs://${{ env.GCP_MAIN_BUCKET_ID }}/gha/benchmarks/memory/${{ matrix.os }}
# Binary size benchmark: build and size wasm binaries; creates ndjson output data format
bench-binsize:
Expand Down Expand Up @@ -520,7 +519,7 @@ jobs:
if: success() || failure()
run: |
git checkout empty
gsutil -m cp -r benchmarks/binsize/ gs://${{ env.GCP_PR_BUCKET_ID }}/gha/${{ github.sha }}/benchmarks/binsize
gsutil -m cp -r benchmarks/binsize/ gs://${{ env.GCP_MAIN_BUCKET_ID }}/gha/benchmarks/binsize
# Data size benchmark: track size of provider/datagen/tests/data/testdata.postcard (total data size).
bench-datasize:
Expand Down Expand Up @@ -584,7 +583,7 @@ jobs:
if: success() || failure()
run: |
git checkout empty
gsutil -m cp -r benchmarks/datasize/ gs://${{ env.GCP_PR_BUCKET_ID }}/gha/${{ github.sha }}/benchmarks/datasize
gsutil -m cp -r benchmarks/datasize/ gs://${{ env.GCP_MAIN_BUCKET_ID }}/gha/benchmarks/datasize
gh-pages:
name: "Deploy to GitHub Pages"
Expand All @@ -608,15 +607,13 @@ jobs:
uses: google-github-actions/setup-gcloud@v1
- name: Download artifacts
run: |
gsutil -m cp -rn gs://${{ env.GCP_PR_BUCKET_ID }}/gha/${{ github.sha }}/benchmarks tools/website-skeleton/ || true
gsutil -m cp -rn gs://${{ env.GCP_PR_BUCKET_ID }}/gha/${{ github.sha }}/docs tools/website-skeleton || true
mkdir -p tools/website-skeleton/docs/ffi
gsutil -m cp -r gs://${{ env.GCP_PR_BUCKET_ID }}/gha/${{ github.sha }}/ffi/cpp tools/website-skeleton/docs/ffi || true
gsutil -m cp -r gs://${{ env.GCP_PR_BUCKET_ID }}/gha/${{ github.sha }}/ffi/js tools/website-skeleton/docs/ffi || true
gsutil -m cp -r gs://${{ env.GCP_PR_BUCKET_ID }}/gha/${{ github.sha }}/wasm-demo tools/website-skeleton/ || true
- name: Upload to main bucket
run: |
gsutil -m cp -r gs://${{ env.GCP_PR_BUCKET_ID}}/gha/${{ github.sha }} gs://${{ env.GCP_MAIN_BUCKET_ID }}/gha/
gsutil -m cp -r gs://${{ env.GCP_MAIN_BUCKET_ID }}/gha/benchmarks tools/website-skeleton/ || true
gsutil -m cp -r gs://${{ env.GCP_MAIN_BUCKET_ID }}/gha/wasm-demo tools/website-skeleton/ || true
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2023-01-31
toolchain: nightly-2022-09-26
override: true

- run: cargo test --all-features --no-fail-fast
Expand Down
5 changes: 4 additions & 1 deletion components/calendar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ icu_locid_transform = { version = "1.2.0", path = "../../components/locid_transf
libm = { version = "0.2", default-features = false }

[dev-dependencies]
criterion = "0.4"
icu = { path = "../icu", default-features = false }
icu_benchmark_macros = { path = "../../tools/benchmark/macros" }
serde = { version = "1.0", features = ["derive", "alloc"] }
serde_json = "1.0"

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
criterion = "0.4"


[features]
default = ["compiled_data"]
std = ["icu_provider/std", "icu_locid/std"]
Expand Down
42 changes: 42 additions & 0 deletions components/calendar/src/any_calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ macro_rules! match_cal_and_date {
) => $e,
(&Self::Ethiopian(ref $cal_matched), &AnyDateInner::Ethiopian(ref $date_matched)) => $e,
(&Self::Indian(ref $cal_matched), &AnyDateInner::Indian(ref $date_matched)) => $e,
(&Self::Chinese(ref $cal_matched), &AnyDateInner::Chinese(ref $date_matched)) => $e,
(&Self::Persian(ref $cal_matched), &AnyDateInner::Persian(ref $date_matched)) => $e,
(&Self::Coptic(ref $cal_matched), &AnyDateInner::Coptic(ref $date_matched)) => $e,
(&Self::Roc(ref $cal_matched), &AnyDateInner::Roc(ref $date_matched)) => $e,
Expand Down Expand Up @@ -254,6 +255,9 @@ impl Calendar for AnyCalendar {
(Self::Indian(c), &mut AnyDateInner::Indian(ref mut d)) => {
c.offset_date(d, offset.cast_unit())
}
(Self::Chinese(c), &mut AnyDateInner::Chinese(ref mut d)) => {
c.offset_date(d, offset.cast_unit())
}
(Self::Coptic(c), &mut AnyDateInner::Coptic(ref mut d)) => {
c.offset_date(d, offset.cast_unit())
}
Expand Down Expand Up @@ -333,6 +337,14 @@ impl Calendar for AnyCalendar {
) => c1
.until(d1, d2, c2, largest_unit, smallest_unit)
.cast_unit(),
(
Self::Chinese(c1),
Self::Chinese(c2),
AnyDateInner::Chinese(d1),
AnyDateInner::Chinese(d2),
) => c1
.until(d1, d2, c2, largest_unit, smallest_unit)
.cast_unit(),
(
Self::Persian(c1),
Self::Persian(c2),
Expand Down Expand Up @@ -724,6 +736,7 @@ impl AnyCalendarKind {
b"japanese" => AnyCalendarKind::Japanese,
b"japanext" => AnyCalendarKind::JapaneseExtended,
b"indian" => AnyCalendarKind::Indian,
b"chinese" => AnyCalendarKind::Chinese,
b"coptic" => AnyCalendarKind::Coptic,
b"iso" => AnyCalendarKind::Iso,
b"ethiopic" => AnyCalendarKind::Ethiopian,
Expand Down Expand Up @@ -752,6 +765,8 @@ impl AnyCalendarKind {
AnyCalendarKind::JapaneseExtended
} else if *x == value!("indian") {
AnyCalendarKind::Indian
} else if *x == value!("chinese") {
AnyCalendarKind::Chinese
} else if *x == value!("coptic") {
AnyCalendarKind::Coptic
} else if *x == value!("iso") {
Expand Down Expand Up @@ -953,6 +968,18 @@ impl IntoAnyCalendar for Indian {
}
}

impl IntoAnyCalendar for Chinese {
fn to_any(self) -> AnyCalendar {
AnyCalendar::Chinese(Chinese)
}
fn to_any_cloned(&self) -> AnyCalendar {
AnyCalendar::Chinese(Chinese)
}
fn date_to_any(&self, d: &Self::DateInner) -> AnyDateInner {
AnyDateInner::Chinese(*d)
}
}

impl IntoAnyCalendar for Coptic {
fn to_any(self) -> AnyCalendar {
AnyCalendar::Coptic(Coptic)
Expand Down Expand Up @@ -1082,6 +1109,7 @@ mod tests {
let ethioaa = AnyCalendar::new(AnyCalendarKind::EthiopianAmeteAlem);
let gregorian = AnyCalendar::new(AnyCalendarKind::Gregorian);
let indian = AnyCalendar::new(AnyCalendarKind::Indian);
let chinese = AnyCalendar::new(AnyCalendarKind::Chinese);
let japanese = AnyCalendar::new(AnyCalendarKind::Japanese);
let japanext = AnyCalendar::new(AnyCalendarKind::JapaneseExtended);
let persian = AnyCalendar::new(AnyCalendarKind::Persian);
Expand All @@ -1092,6 +1120,7 @@ mod tests {
let ethioaa = Ref(&ethioaa);
let gregorian = Ref(&gregorian);
let indian = Ref(&indian);
let chinese = Ref(&chinese);
let japanese = Ref(&japanese);
let japanext = Ref(&japanext);
let persian = Ref(&persian);
Expand Down Expand Up @@ -1188,6 +1217,19 @@ mod tests {
1,
CalendarError::UnknownMonthCode("M13".parse().unwrap(), "Indian"),
);

single_test_roundtrip(chinese, "chinese", 400, "M02", 5);
single_test_roundtrip(chinese, "chinese", 4660, "M07", 29);
single_test_roundtrip(chinese, "chinese", -100, "M11", 12);
single_test_error(
chinese,
"chinese",
4658,
"M13",
1,
CalendarError::UnknownMonthCode("M13".parse().unwrap(), "Chinese"),
);

single_test_roundtrip(japanese, "reiwa", 3, "M03", 1);
single_test_roundtrip(japanese, "heisei", 6, "M12", 1);
single_test_roundtrip(japanese, "meiji", 10, "M03", 1);
Expand Down
1 change: 0 additions & 1 deletion components/calendar/src/calendar_arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ impl<C: CalendarArithmetic> ArithmeticDate<C> {
max: max_month as usize,
});
}

let max_day = C::month_days(year, month);
if day > max_day {
return Err(CalendarError::Overflow {
Expand Down
Loading

0 comments on commit 6f94526

Please sign in to comment.