Skip to content

Commit 0d1a1a7

Browse files
authored
Merge pull request #51 from innoave/chore/optimize-ci-workflow
chore: optimize ci workflow
2 parents b398e14 + de16a04 commit 0d1a1a7

8 files changed

Lines changed: 134 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ permissions:
1818
contents: read
1919

2020
jobs:
21+
# Depends on all actions that are required for a "successful" CI run.
22+
tests-pass:
23+
name: all checks successful
24+
runs-on: ubuntu-latest
25+
needs:
26+
- fmt
27+
- clippy
28+
- msrv
29+
- doc
30+
- test-all-features
31+
- test-default-features
32+
- test-no-std
33+
steps:
34+
- run: exit 0
35+
2136
clippy:
2237
name: Clippy
2338
runs-on: ubuntu-latest
@@ -29,12 +44,12 @@ jobs:
2944
with:
3045
toolchain: stable
3146
override: true
32-
- uses: Swatinem/rust-cache@v2
3347
- name: Run cargo clippy
3448
uses: actions-rs/cargo@v1
3549
with:
3650
command: clippy
3751
args: --all-features
52+
- uses: Swatinem/rust-cache@v2
3853

3954
fmt:
4055
name: Rustfmt check
@@ -48,10 +63,16 @@ jobs:
4863
toolchain: nightly
4964
components: rustfmt
5065
- run: cargo +nightly fmt --check --all
66+
- uses: Swatinem/rust-cache@v2
5167

52-
test:
53-
name: Run tests
68+
test-all-features:
69+
name: Run tests for all features
5470
runs-on: ${{ matrix.os }}
71+
needs:
72+
- fmt
73+
- clippy
74+
- msrv
75+
- doc
5576
strategy:
5677
fail-fast: false
5778
matrix:
@@ -71,16 +92,21 @@ jobs:
7192
with:
7293
toolchain: ${{ matrix.rust }}
7394
override: true
74-
- uses: Swatinem/rust-cache@v2
7595
- name: Run cargo test
7696
uses: actions-rs/cargo@v1
7797
with:
7898
command: test
7999
args: --all-features --no-fail-fast
100+
- uses: Swatinem/rust-cache@v2
80101

81-
no-std:
82-
name: Test no-std support
102+
test-default-features:
103+
name: Test with default features
83104
runs-on: ubuntu-latest
105+
needs:
106+
- fmt
107+
- clippy
108+
- msrv
109+
- doc
84110
steps:
85111
- name: Checkout sources
86112
uses: actions/checkout@v4
@@ -89,12 +115,34 @@ jobs:
89115
with:
90116
toolchain: stable
91117
override: true
118+
- name: Run cargo test
119+
uses: actions-rs/cargo@v1
120+
with:
121+
command: test
92122
- uses: Swatinem/rust-cache@v2
123+
124+
test-no-std:
125+
name: Test no-std support
126+
runs-on: ubuntu-latest
127+
needs:
128+
- fmt
129+
- clippy
130+
- msrv
131+
- doc
132+
steps:
133+
- name: Checkout sources
134+
uses: actions/checkout@v4
135+
- name: Install toolchain
136+
uses: actions-rs/toolchain@v1
137+
with:
138+
toolchain: stable
139+
override: true
93140
- name: Run cargo test
94141
uses: actions-rs/cargo@v1
95142
with:
96143
command: test
97144
args: --no-default-features --features "colored, float-cmp, num-bigint, rust-decimal, bigdecimal"
145+
- uses: Swatinem/rust-cache@v2
98146

99147
msrv:
100148
name: Build with MSRV
@@ -131,9 +179,9 @@ jobs:
131179
with:
132180
toolchain: nightly
133181
override: true
134-
- uses: Swatinem/rust-cache@v2
135182
- name: Run cargo doc
136183
uses: actions-rs/cargo@v1
137184
with:
138185
command: doc
139186
args: --all-features --no-deps
187+
- uses: Swatinem/rust-cache@v2
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Clippy default-features" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
3+
<option name="command" value="clippy --all-targets" />
4+
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
5+
<envs />
6+
<option name="emulateTerminal" value="false" />
7+
<option name="channel" value="DEFAULT" />
8+
<option name="requiredFeatures" value="false" />
9+
<option name="allFeatures" value="false" />
10+
<option name="withSudo" value="false" />
11+
<option name="buildTarget" value="REMOTE" />
12+
<option name="backtrace" value="NO" />
13+
<option name="isRedirectInput" value="false" />
14+
<option name="redirectInputPath" value="" />
15+
<method v="2">
16+
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
17+
</method>
18+
</configuration>
19+
</component>

.ide-settings/jetbrains/runConfigurations/Clippy no-std.run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Clippy no-std" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
3-
<option name="command" value="clippy --all-targets --no-default-features --features &quot;colored, float-cmp&quot;" />
3+
<option name="command" value="clippy --all-targets --no-default-features --features &quot;colored, float-cmp, num-bigint, bigdecimal, rust-decimal&quot;" />
44
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
55
<envs />
66
<option name="emulateTerminal" value="false" />
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Test default-features" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
3+
<option name="buildProfileId" value="test" />
4+
<option name="command" value="test" />
5+
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
6+
<envs />
7+
<option name="emulateTerminal" value="false" />
8+
<option name="channel" value="DEFAULT" />
9+
<option name="requiredFeatures" value="false" />
10+
<option name="allFeatures" value="false" />
11+
<option name="withSudo" value="false" />
12+
<option name="buildTarget" value="REMOTE" />
13+
<option name="backtrace" value="NO" />
14+
<option name="isRedirectInput" value="false" />
15+
<option name="redirectInputPath" value="" />
16+
<method v="2">
17+
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
18+
</method>
19+
</configuration>
20+
</component>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Test lib default-features" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
3+
<option name="buildProfileId" value="test" />
4+
<option name="command" value="test --lib" />
5+
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
6+
<envs />
7+
<option name="emulateTerminal" value="false" />
8+
<option name="channel" value="DEFAULT" />
9+
<option name="requiredFeatures" value="false" />
10+
<option name="allFeatures" value="false" />
11+
<option name="withSudo" value="false" />
12+
<option name="buildTarget" value="REMOTE" />
13+
<option name="backtrace" value="NO" />
14+
<option name="isRedirectInput" value="false" />
15+
<option name="redirectInputPath" value="" />
16+
<method v="2">
17+
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
18+
</method>
19+
</configuration>
20+
</component>

.ide-settings/jetbrains/runConfigurations/Test no-std.run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Test no-std" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
33
<option name="buildProfileId" value="test" />
4-
<option name="command" value="test --no-default-features --features &quot;colored, float-cmp, num-bigint&quot;" />
4+
<option name="command" value="test --no-default-features --features &quot;colored, float-cmp, num-bigint, bigdecimal, rust-decimal&quot;" />
55
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
66
<envs />
77
<option name="emulateTerminal" value="false" />

justfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ alias cc := code-coverage
88
alias d := doc
99
alias l := lint
1010
alias la := lint-all-features
11+
alias ld := lint-default
1112
alias ln := lint-no-std
1213
alias t := test
1314
alias ta := test-all-features
15+
alias td := test-default
1416
alias tn := test-no-std
1517

1618
# list recipies
@@ -29,12 +31,17 @@ check:
2931
lint:
3032
just lint-all-features
3133
just lint-no-std
34+
just lint-default
3235
just lint-no-features
3336

3437
# linting code using Clippy with all features enabled
3538
lint-all-features:
3639
cargo clippy --all-targets --all-features
3740

41+
# linting code using Clippy with default features enabled
42+
lint-default:
43+
cargo clippy --all-targets
44+
3845
# linting code using Clippy for no-std environment
3946
lint-no-std:
4047
cargo clippy --all-targets --no-default-features --features "colored, float-cmp, num-bigint, rust-decimal, bigdecimal"
@@ -47,12 +54,17 @@ lint-no-features:
4754
test:
4855
just test-all-features
4956
just test-no-std
57+
just test-default
5058
just test-no-features
5159

5260
# run tests for all features
5361
test-all-features:
5462
cargo test --all-features
5563

64+
# run tests for default features
65+
test-default:
66+
cargo test
67+
5668
# run tests for no-std environment
5769
test-no-std:
5870
cargo test --no-default-features --features "colored, float-cmp, num-bigint, rust-decimal, bigdecimal"

src/env.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ mod fake_env {
1919
use std::env::VarError;
2020

2121
thread_local! {
22-
static ENV_STORE: RefCell<EnvStore> = RefCell::new(EnvStore::fake());
22+
static ENV_STORE: RefCell<EnvStore> = RefCell::new({
23+
let env = EnvStore::fake();
24+
env.remove_var("ASSERTING_HIGHLIGHT_DIFFS");
25+
env.remove_var("NO_COLOR");
26+
env
27+
});
2328
}
2429

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

0 commit comments

Comments
 (0)