17
17
required : false
18
18
default : x86_64-unknown-linux-gnu
19
19
description : Rust target for the build step. Clippy and tests are still executed with the default target.
20
+ features :
21
+ type : string
22
+ required : false
23
+ # Make sure we always an empty string to "--features <FEATURES>"
24
+ default : ' ""'
25
+ description : Comma-separated String with additional Rust features relevant for a certain job.
20
26
do-style-check :
21
27
type : boolean
22
28
required : false
23
29
default : true
24
- description : Whether style checks should be done .
30
+ description : Perform code and doc style checks .
25
31
do-test :
26
32
type : boolean
27
33
required : false
28
34
default : true
29
- description : Whether tests should be executed .
35
+ description : Execute tests.
30
36
31
37
jobs :
32
- build :
38
+ check_rust :
33
39
runs-on : ubuntu-latest
34
40
steps :
35
41
- name : Check out
36
42
uses : actions/checkout@v3
37
- - name : Install Rust
43
+ - name : Set up rustup cache
44
+ uses : actions/cache@v3
45
+ continue-on-error : false
46
+ with :
47
+ path : |
48
+ ~/.rustup/downloads
49
+ ~/.rustup/toolchains
50
+ # key: ${{ runner.os }}-rustup-${{ inputs.rust-version }}-${{ inputs.rust-target }}-${{ hashFiles('**/rustup-toolchain.toml') }}
51
+ key : ${{ runner.os }}-rustup-${{ inputs.rust-version }}-${{ inputs.rust-target }}
52
+ # The effect of this is must smaller than the cache for Cargo. However, it
53
+ # still saves a few seconds. Note that many CI runs within a week may
54
+ # quickly bring you close to the 10GB limit:
55
+ # https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#managing-caches
56
+ - name : Install Rust Toolchain via Rustup
38
57
uses : actions-rs/toolchain@v1
39
58
with :
40
59
profile : minimal
41
60
toolchain : ${{ inputs.rust-version }}
42
61
override : true
43
62
components : clippy, rustfmt
44
63
target : ${{ inputs.rust-target }}
45
- - name : Set up cargo cache
64
+ - name : Set up Cargo cache
46
65
uses : actions/cache@v3
47
66
continue-on-error : false
48
67
with :
@@ -54,23 +73,22 @@ jobs:
54
73
target/
55
74
# We do not have a Cargo.lock here, so I hash Cargo.toml
56
75
key : ${{ runner.os }}-rust-${{ inputs.rust-version }}-cargo-${{ hashFiles('**/Cargo.toml') }}
57
- restore-keys : ${{ runner.os }}-cargo-${{ inputs.rust-version }}
58
76
- run : cargo version
77
+ - name : Build (library)
78
+ run : cargo build --target ${{ inputs.rust-target }} --features ${{ inputs.features }}
79
+ - name : Build (all targets)
80
+ run : cargo build --all-targets --features ${{ inputs.features }}
59
81
- name : Code Formatting
60
82
if : ${{ inputs.do-style-check }}
61
83
run : cargo fmt --all -- --check
62
- - name : Build (library)
63
- run : cargo build --target ${{ inputs.rust-target }}
64
- - name : Build (all targets)
65
- run : cargo build --all-targets
66
84
- name : Code Style and Doc Style
67
85
if : ${{ inputs.do-style-check }}
68
86
run : |
69
- cargo doc --document-private-items
70
- cargo clippy --all-targets
87
+ cargo doc --document-private-items --features ${{ inputs.features }}
88
+ cargo clippy --all-targets --features ${{ inputs.features }}
71
89
- name : Unit Test
72
90
if : ${{ inputs.do-test }}
73
91
run : |
74
92
curl -LsSf https://get.nexte.st/latest/linux | tar zxf -
75
93
chmod u+x cargo-nextest
76
- ./cargo-nextest nextest run
94
+ ./cargo-nextest nextest run --features ${{ inputs.features }}
0 commit comments