Skip to content
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
62 changes: 55 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ permissions:
contents: read

jobs:
# Depends on all actions that are required for a "successful" CI run.
tests-pass:
name: all checks successful
runs-on: ubuntu-latest
needs:
- fmt
- clippy
- msrv
- doc
- test-all-features
- test-default-features
- test-no-std
steps:
- run: exit 0

clippy:
name: Clippy
runs-on: ubuntu-latest
Expand All @@ -29,12 +44,12 @@ jobs:
with:
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v2
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features
- uses: Swatinem/rust-cache@v2

fmt:
name: Rustfmt check
Expand All @@ -48,10 +63,16 @@ jobs:
toolchain: nightly
components: rustfmt
- run: cargo +nightly fmt --check --all
- uses: Swatinem/rust-cache@v2

test:
name: Run tests
test-all-features:
name: Run tests for all features
runs-on: ${{ matrix.os }}
needs:
- fmt
- clippy
- msrv
- doc
strategy:
fail-fast: false
matrix:
Expand All @@ -71,16 +92,21 @@ jobs:
with:
toolchain: ${{ matrix.rust }}
override: true
- uses: Swatinem/rust-cache@v2
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --no-fail-fast
- uses: Swatinem/rust-cache@v2

no-std:
name: Test no-std support
test-default-features:
name: Test with default features
runs-on: ubuntu-latest
needs:
- fmt
- clippy
- msrv
- doc
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand All @@ -89,12 +115,34 @@ jobs:
with:
toolchain: stable
override: true
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
- uses: Swatinem/rust-cache@v2

test-no-std:
name: Test no-std support
runs-on: ubuntu-latest
needs:
- fmt
- clippy
- msrv
- doc
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features --features "colored, float-cmp, num-bigint, rust-decimal, bigdecimal"
- uses: Swatinem/rust-cache@v2

msrv:
name: Build with MSRV
Expand Down Expand Up @@ -131,9 +179,9 @@ jobs:
with:
toolchain: nightly
override: true
- uses: Swatinem/rust-cache@v2
- name: Run cargo doc
uses: actions-rs/cargo@v1
with:
command: doc
args: --all-features --no-deps
- uses: Swatinem/rust-cache@v2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Clippy default-features" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="command" value="clippy --all-targets" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<option name="emulateTerminal" value="false" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="false" />
<option name="allFeatures" value="false" />
<option name="withSudo" value="false" />
<option name="buildTarget" value="REMOTE" />
<option name="backtrace" value="NO" />
<option name="isRedirectInput" value="false" />
<option name="redirectInputPath" value="" />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
</component>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Clippy no-std" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="command" value="clippy --all-targets --no-default-features --features &quot;colored, float-cmp&quot;" />
<option name="command" value="clippy --all-targets --no-default-features --features &quot;colored, float-cmp, num-bigint, bigdecimal, rust-decimal&quot;" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<option name="emulateTerminal" value="false" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test default-features" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="buildProfileId" value="test" />
<option name="command" value="test" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<option name="emulateTerminal" value="false" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="false" />
<option name="allFeatures" value="false" />
<option name="withSudo" value="false" />
<option name="buildTarget" value="REMOTE" />
<option name="backtrace" value="NO" />
<option name="isRedirectInput" value="false" />
<option name="redirectInputPath" value="" />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
</component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test lib default-features" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="buildProfileId" value="test" />
<option name="command" value="test --lib" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<option name="emulateTerminal" value="false" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="false" />
<option name="allFeatures" value="false" />
<option name="withSudo" value="false" />
<option name="buildTarget" value="REMOTE" />
<option name="backtrace" value="NO" />
<option name="isRedirectInput" value="false" />
<option name="redirectInputPath" value="" />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
</component>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test no-std" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="buildProfileId" value="test" />
<option name="command" value="test --no-default-features --features &quot;colored, float-cmp, num-bigint&quot;" />
<option name="command" value="test --no-default-features --features &quot;colored, float-cmp, num-bigint, bigdecimal, rust-decimal&quot;" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<option name="emulateTerminal" value="false" />
Expand Down
12 changes: 12 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ alias cc := code-coverage
alias d := doc
alias l := lint
alias la := lint-all-features
alias ld := lint-default
alias ln := lint-no-std
alias t := test
alias ta := test-all-features
alias td := test-default
alias tn := test-no-std

# list recipies
Expand All @@ -29,12 +31,17 @@ check:
lint:
just lint-all-features
just lint-no-std
just lint-default
just lint-no-features

# linting code using Clippy with all features enabled
lint-all-features:
cargo clippy --all-targets --all-features

# linting code using Clippy with default features enabled
lint-default:
cargo clippy --all-targets

# linting code using Clippy for no-std environment
lint-no-std:
cargo clippy --all-targets --no-default-features --features "colored, float-cmp, num-bigint, rust-decimal, bigdecimal"
Expand All @@ -47,12 +54,17 @@ lint-no-features:
test:
just test-all-features
just test-no-std
just test-default
just test-no-features

# run tests for all features
test-all-features:
cargo test --all-features

# run tests for default features
test-default:
cargo test

# run tests for no-std environment
test-no-std:
cargo test --no-default-features --features "colored, float-cmp, num-bigint, rust-decimal, bigdecimal"
Expand Down
7 changes: 6 additions & 1 deletion src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ mod fake_env {
use std::env::VarError;

thread_local! {
static ENV_STORE: RefCell<EnvStore> = RefCell::new(EnvStore::fake());
static ENV_STORE: RefCell<EnvStore> = RefCell::new({
let env = EnvStore::fake();
env.remove_var("ASSERTING_HIGHLIGHT_DIFFS");
env.remove_var("NO_COLOR");
env
});
}

pub fn var(key: &str) -> Result<String, VarError> {
Expand Down
Loading