Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose rkyv features as features for chrono users. #1368

Merged
merged 2 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
name: codecov

env:
# It's really `--all-features`, but not adding the mutually exclusive features from rkyv
ALL_NON_EXCLUSIVE_FEATURES: --features "default unstable-locales rkyv-64 rkyv-validation rustc-serialize serde arbitrary"

on:
push:
branches: [main, 0.4.x]
Expand All @@ -18,7 +23,7 @@ jobs:
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage
run: cargo +nightly llvm-cov --all-features --workspace --lcov --doctests --output-path lcov.info
run: cargo +nightly llvm-cov ${{ env.ALL_NON_EXCLUSIVE_FEATURES }} --workspace --lcov --doctests --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
env:
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: lint

env:
# It's really `--all-features`, but not adding the mutually exclusive features from rkyv
ALL_NON_EXCLUSIVE_FEATURES: --features "default unstable-locales rkyv-64 rkyv-validation rustc-serialize serde arbitrary"

on:
push:
branches: [main, 0.4.x]
Expand All @@ -19,7 +23,7 @@ jobs:
- run: cargo fmt --check --manifest-path fuzz/Cargo.toml
- run: cargo fmt --check --manifest-path bench/Cargo.toml
- run: |
cargo clippy --all-features --all-targets --color=always \
cargo clippy ${{ env.ALL_NON_EXCLUSIVE_FEATURES }} --all-targets --color=always \
-- -D warnings
- run: |
cargo clippy --manifest-path fuzz/Cargo.toml --color=always \
Expand Down Expand Up @@ -50,8 +54,8 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo install cargo-deadlinks
- run: cargo deadlinks -- --all-features
- run: cargo doc --all-features --no-deps
- run: cargo deadlinks -- ${{ env.ALL_NON_EXCLUSIVE_FEATURES }}
- run: cargo doc ${{ env.ALL_NON_EXCLUSIVE_FEATURES }} --no-deps
env:
RUSTDOCFLAGS: -Dwarnings

Expand Down
22 changes: 13 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: All Tests and Builds

env:
# It's really `--all-features`, but not adding the mutually exclusive features from rkyv
ALL_NON_EXCLUSIVE_FEATURES: --features "default unstable-locales rkyv-32 rkyv-validation rustc-serialize serde arbitrary"

on:
push:
branches: [main, 0.4.x]
Expand All @@ -16,7 +20,7 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --all-features --color=always -- --color=always
- run: cargo test ${{ env.ALL_NON_EXCLUSIVE_FEATURES }} --color=always -- --color=always

# later this may be able to be included with the below
# kept separate for now as the following don't compile on 1.60
Expand Down Expand Up @@ -61,8 +65,8 @@ jobs:
- run: cargo check --manifest-path fuzz/Cargo.toml --all-targets
# run --lib and --doc to avoid the long running integration tests
# which are run elsewhere
- run: cargo test --lib --all-features --color=always -- --color=always
- run: cargo test --doc --all-features --color=always -- --color=always
- run: cargo test --lib ${{ env.ALL_NON_EXCLUSIVE_FEATURES }} --color=always -- --color=always
- run: cargo test --doc ${{ env.ALL_NON_EXCLUSIVE_FEATURES }} --color=always -- --color=always

features_check:
strategy:
Expand All @@ -76,7 +80,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
- run: |
cargo hack check --feature-powerset --optional-deps serde \
--skip __internal_bench,iana-time-zone,pure-rust-locales,libc,winapi \
--skip __internal_bench,iana-time-zone,pure-rust-locales,libc,winapi,rkyv-16,rkyv-64,rkyv-validation \
--all-targets
# run using `bash` on all platforms for consistent
# line-continuation marks
Expand Down Expand Up @@ -182,16 +186,16 @@ jobs:
- uses: actions/checkout@v4
- run: cargo install cross
- uses: Swatinem/rust-cache@v2
- run: cross test --lib --all-features --target i686-unknown-linux-gnu --color=always
- run: cross test --doc --all-features --target i686-unknown-linux-gnu --color=always
- run: cross test --lib --all-features --target i686-unknown-linux-musl --color=always
- run: cross test --doc --all-features --target i686-unknown-linux-musl --color=always
- run: cross test --lib ${{ env.ALL_NON_EXCLUSIVE_FEATURES }} --target i686-unknown-linux-gnu --color=always
- run: cross test --doc ${{ env.ALL_NON_EXCLUSIVE_FEATURES }} --target i686-unknown-linux-gnu --color=always
- run: cross test --lib ${{ env.ALL_NON_EXCLUSIVE_FEATURES }} --target i686-unknown-linux-musl --color=always
- run: cross test --doc ${{ env.ALL_NON_EXCLUSIVE_FEATURES }} --target i686-unknown-linux-musl --color=always

check-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: cargo +nightly doc --all-features --no-deps
- run: cargo +nightly doc ${{ env.ALL_NON_EXCLUSIVE_FEATURES }} --no-deps
env:
RUSTDOCFLAGS: "-D warnings --cfg docsrs"
10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ rust-version = "1.61.0"
name = "chrono"

[features]
# Don't forget to adjust `ALL_NON_EXCLUSIVE_FEATURES` in CI scripts when adding a feature or an optional dependency.
default = ["clock", "std", "oldtime", "wasmbind"]
alloc = []
libc = []
Expand All @@ -27,15 +28,20 @@ now = ["std"]
oldtime = []
wasmbind = ["wasm-bindgen", "js-sys"]
unstable-locales = ["pure-rust-locales"]
rkyv-validation = ["rkyv/validation"]
# Note that rkyv-16, rkyv-32, and rkyv-64 are mutually exclusive.
rkyv-16 = ["rkyv", "rkyv?/size_16"]
rkyv-32 = ["rkyv", "rkyv?/size_32"]
rkyv-64 = ["rkyv", "rkyv?/size_64"]
rkyv-validation = ["rkyv", "rkyv?/validation"]
# Features for internal use only:
__internal_bench = []

[dependencies]
num-traits = { version = "0.2", default-features = false }
rustc-serialize = { version = "0.3.20", optional = true }
serde = { version = "1.0.99", default-features = false, optional = true }
pure-rust-locales = { version = "0.7", optional = true }
rkyv = { version = "0.7.41", optional = true }
rkyv = { version = "0.7.43", optional = true, default-features = false }
arbitrary = { version = "1.0.0", features = ["derive"], optional = true }

[target.'cfg(all(target_arch = "wasm32", not(any(target_os = "emscripten", target_os = "wasi"))))'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/month.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::OutOfRange;
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "rkyv",
archive(compare(PartialEq)),
archive(compare(PartialEq, PartialOrd)),
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))
)]
#[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
Expand Down
2 changes: 1 addition & 1 deletion src/naive/isoweek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use rkyv::{Archive, Deserialize, Serialize};
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "rkyv",
archive(compare(PartialEq)),
archive(compare(PartialEq, PartialOrd)),
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))
)]
#[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
Expand Down