ci/nix: use a `"test"` cargo profile

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-07-25 18:06:45 -04:00
parent 04971d0430
commit fb8a2846df
6 changed files with 40 additions and 5 deletions

View File

@ -62,6 +62,8 @@ jobs:
tests: tests:
name: Test name: Test
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
CARGO_PROFILE: "test"
steps: steps:
- name: Free Disk Space (Ubuntu) - name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main uses: jlumbroso/free-disk-space@main

View File

@ -657,7 +657,16 @@ opt-level = 'z'
# '-Clink-arg=-Wl,-z,nodelete', # '-Clink-arg=-Wl,-z,nodelete',
#] #]
# primarily used for CI
[profile.test] [profile.test]
inherits = "dev"
codegen-units = 16
incremental = false
[profile.test.package.'*']
inherits = "dev"
debug = 0
codegen-units = 16
incremental = false incremental = false
############################################################################### ###############################################################################

View File

@ -73,7 +73,9 @@ script = "cargo audit -D warnings -D unmaintained -D unsound -D yanked"
[[task]] [[task]]
name = "cargo-fmt" name = "cargo-fmt"
group = "lints" group = "lints"
script = "cargo fmt --check -- --color=always" script = """
cargo fmt --check -- --color=always
"""
[[task]] [[task]]
name = "cargo-doc" name = "cargo-doc"
@ -84,6 +86,7 @@ env DIRENV_DEVSHELL=all-features \
direnv exec . \ direnv exec . \
cargo doc \ cargo doc \
--workspace \ --workspace \
--profile test \
--all-features \ --all-features \
--no-deps \ --no-deps \
--document-private-items \ --document-private-items \
@ -96,6 +99,7 @@ group = "lints"
script = """ script = """
cargo clippy \ cargo clippy \
--workspace \ --workspace \
--profile test \
--all-targets \ --all-targets \
--color=always \ --color=always \
-- \ -- \
@ -110,6 +114,7 @@ env DIRENV_DEVSHELL=all-features \
direnv exec . \ direnv exec . \
cargo clippy \ cargo clippy \
--workspace \ --workspace \
--profile test \
--all-targets \ --all-targets \
--all-features \ --all-features \
--color=always \ --color=always \
@ -123,6 +128,7 @@ group = "lints"
script = """ script = """
cargo clippy \ cargo clippy \
--workspace \ --workspace \
--profile test \
--features jemalloc \ --features jemalloc \
--all-targets \ --all-targets \
--color=always \ --color=always \
@ -161,6 +167,7 @@ env DIRENV_DEVSHELL=all-features \
direnv exec . \ direnv exec . \
cargo test \ cargo test \
--workspace \ --workspace \
--profile test \
--all-targets \ --all-targets \
--all-features \ --all-features \
--color=always \ --color=always \
@ -174,6 +181,7 @@ group = "tests"
script = """ script = """
cargo test \ cargo test \
--workspace \ --workspace \
--profile test \
--all-targets \ --all-targets \
--color=always \ --color=always \
-- \ -- \
@ -190,9 +198,11 @@ name = "nix-default"
group = "tests" group = "tests"
script = """ script = """
env DIRENV_DEVSHELL=dynamic \ env DIRENV_DEVSHELL=dynamic \
CARGO_PROFILE="test" \
direnv exec . \ direnv exec . \
bin/nix-build-and-cache just .#default bin/nix-build-and-cache just .#default-test
env DIRENV_DEVSHELL=dynamic \ env DIRENV_DEVSHELL=dynamic \
CARGO_PROFILE="test" \
direnv exec . \ direnv exec . \
nix run -L .#default -- --help nix run -L .#default-test -- --help && nix run -L .#default-test -- --version
""" """

View File

@ -154,6 +154,10 @@
# debug build users expect full logs # debug build users expect full logs
disable_release_max_log_level = true; disable_release_max_log_level = true;
}; };
default-test = scopeHost.main.override {
profile = "test";
disable_release_max_log_level = true;
};
all-features = scopeHost.main.override { all-features = scopeHost.main.override {
all_features = true; all_features = true;
disable_features = [ disable_features = [
@ -247,6 +251,16 @@
}; };
} }
# An output for a statically-linked unstripped debug binary with the
# "test" profile (for CI usage only)
{
name = "${binaryName}-test";
value = scopeCrossStatic.main.override {
profile = "test";
disable_release_max_log_level = true;
};
}
# An output for a statically-linked binary with `--all-features` # An output for a statically-linked binary with `--all-features`
{ {
name = "${binaryName}-all-features"; name = "${binaryName}-all-features";

View File

@ -14,7 +14,7 @@
let let
main' = main.override { main' = main.override {
profile = "dev"; profile = "test";
all_features = true; all_features = true;
disable_release_max_log_level = true; disable_release_max_log_level = true;
disable_features = [ disable_features = [

View File

@ -153,7 +153,7 @@ commonAttrs = {
]; ];
}; };
dontStrip = profile == "dev"; dontStrip = profile == "dev" || profile == "test";
buildInputs = lib.optional (featureEnabled "jemalloc") rust-jemalloc-sys'; buildInputs = lib.optional (featureEnabled "jemalloc") rust-jemalloc-sys';