Skip to content

Commit

Permalink
Use submodule for generated data, update to 2022d (#127)
Browse files Browse the repository at this point in the history
* Clear src/generated

* Use submodule for generated data

* Update to 2022d

* Update to iana-time-zone 0.1.50

* Use once_cell=1.14 for benchmarking
  • Loading branch information
Kijewski authored Sep 25, 2022
1 parent 5c574a2 commit 79258f8
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 52,657 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Rust
uses: ./.github/actions/setup-rust
Expand Down Expand Up @@ -56,6 +58,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Rust
uses: ./.github/actions/setup-rust
Expand All @@ -78,6 +82,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Rust
uses: ./.github/actions/setup-rust
Expand All @@ -91,6 +97,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Rust
uses: ./.github/actions/setup-rust
Expand All @@ -102,6 +110,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Rust
uses: ./.github/actions/setup-rust
Expand All @@ -114,6 +124,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Rust
uses: ./.github/actions/setup-rust
Expand Down Expand Up @@ -141,6 +153,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Rust
uses: ./.github/actions/setup-rust
Expand All @@ -157,6 +171,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Rust
uses: ./.github/actions/setup-rust
Expand All @@ -180,6 +196,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Rust
uses: ./.github/actions/setup-rust
Expand Down Expand Up @@ -210,6 +228,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Rust
uses: ./.github/actions/setup-rust
Expand All @@ -236,6 +256,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Rust
uses: ./.github/actions/setup-rust
Expand All @@ -255,6 +277,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Rust
uses: ./.github/actions/setup-rust
Expand All @@ -273,6 +297,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive

- name: Run DevSkim scanner
uses: microsoft/DevSkim-Action@v1
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "src/generated"]
path = src/generated
url = ./
branch = generated
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
## Changes between the versions

### 0.5.0-pre.2 (2022-09-25)

* Update to Time Zone Database release 2022d
* Update to iana-time-zone 0.1.50

### 0.5.0-pre.1 (2022-09-14)

* Simplify a lot by removing feature gates [[#123](https://github.com/Kijewski/tzdb/pull/123)]
* Simplify a lot by removing feature gates [[#123](https://github.com/Kijewski/tzdb/pull/123)]

### 0.4.5 (2022-08-31)

Expand Down
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tzdb"
version = "0.5.0-pre.1"
version = "0.5.0-pre.2"
edition = "2018"
authors = ["René Kijewski <[email protected]>"]
repository = "https://github.com/Kijewski/tzdb"
Expand All @@ -13,7 +13,7 @@ rust-version = "1.55"

[dependencies]
tz-rs = { version = "^0.6.14", default-features = false, features = ["const"] }
iana-time-zone = { version = "^0.1.48", default-features = false }
iana-time-zone = { version = "^0.1.50", default-features = false }
utcnow = { version = "^0.2.1", default-features = false }

[dev-dependencies]
Expand All @@ -23,6 +23,9 @@ rand = { version = "^0.8.5", default-features = false, features = ["std", "small
test-strategy = "=0.1.2"
structmeta = "=0.1.4"

# 1.15 is edition 2021, used (transitively) by criterion
once_cell = "=1.14"

[features]
default = ["std", "fallback"]

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.DELETE_ON_ERROR:

TZDB_VERSION := tzdb-2022c
TZDB_VERSION := tzdb-2022d

src/generated/mod.rs: tmp/${TZDB_VERSION}/usr/share/zoneinfo/
cargo r --package make-tzdb --bin make-tzdb -- $(@D) $<
cargo r --package make-tzdb --bin make-tzdb -- $(@D) $< $(TZDB_VERSION).tar.lz.sha
cargo +nightly fmt -- $(@D)/mod.rs $(@D)/by_name.rs $(@D)/raw_tzdata.rs $(@D)/test_all_names.rs

tmp/${TZDB_VERSION}/usr/share/zoneinfo/: tmp/${TZDB_VERSION}/
Expand Down
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Static time zone information for [tz-rs](https://crates.io/crates/tz-rs).

This crate provides all time zones found in the [Time Zone Database](https://www.iana.org/time-zones),
currently in the version 2022c (released 2022-08-16).
currently in the version 2022d (released 2022-09-23).

See the documentation for a full list the the contained time zones:
<https://docs.rs/tzdb/latest/tzdb/time_zone/index.html>
Expand Down Expand Up @@ -43,8 +43,3 @@ let current_time = tzdb::now::in_named_or(tzdb::time_zone::GMT, "Some/City")?;
* `alloc` <sup>(enabled by default, enabled by `std`)</sup> – enable features that need the standard library `alloc`

* `fallback` <sup>(enabled by default)</sup> — compile for unknown target platforms, too

## Git cloning

The `main` branch gets squashed regularily to keep the size of the repository at a maintainable size.
To get the history until then, please refer to the id in the initial commit.
16 changes: 15 additions & 1 deletion make-tzdb/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod parse;
use std::cmp::Ordering;
use std::env::{args, var_os};
use std::fmt::Write as _;
use std::fs::{create_dir_all, read_dir, OpenOptions};
use std::fs::{create_dir_all, read_dir, read_to_string, OpenOptions};
use std::io::Write as _;
use std::path::PathBuf;

Expand Down Expand Up @@ -85,6 +85,7 @@ impl TzName {
pub fn main() -> anyhow::Result<()> {
let mut args = args().into_iter().fuse();
let _ = args.next(); // exe path

let target_dir = PathBuf::from(args.next().unwrap_or_else(|| "tzdb/generated".to_owned()));
create_dir_all(&target_dir)?;

Expand All @@ -104,6 +105,16 @@ pub fn main() -> anyhow::Result<()> {
base_path.push('/');
}

let hash_file = args.next().unwrap_or_else(|| "tzdb.tar.lz.sha".to_owned());
let hash_file = read_to_string(&hash_file)?;
let (hash, version) = hash_file
.trim()
.split_once(" ")
.ok_or_else(|| anyhow!("Hash file {hash_file:?} malformed."))?;
let version = version.rsplit_once('/').unwrap_or(("", version)).1;
let version = version.split_once('.').unwrap_or((version, "")).0;
let version = version.rsplit_once('-').unwrap_or(("", version)).1;

let mut entries_by_bytes = IndexMap::<Vec<u8>, Vec<TzName>>::new();

let mut folders = vec![];
Expand Down Expand Up @@ -221,6 +232,9 @@ macro_rules! unwrap {{
}}
}}
pub(crate) use unwrap;
pub(crate) const VERSION: &str = {version:?};
pub(crate) const VERSION_HASH: &str = {hash:?};
"#
)?;

Expand Down
1 change: 1 addition & 0 deletions src/generated
Submodule generated added at 456eed
Loading

0 comments on commit 79258f8

Please sign in to comment.