interpreter = ["bash", "-euo", "pipefail", "-c"]

[[task]]
name = "engage"
group = "versions"
script = "engage --version"

[[task]]
name = "nix"
group = "versions"
script = "nix --version"

[[task]]
name = "direnv"
group = "versions"
script = "direnv --version"

[[task]]
name = "rustc"
group = "versions"
script = "rustc --version -v"

[[task]]
name = "cargo"
group = "versions"
script = "cargo --version -v"

[[task]]
name = "cargo-fmt"
group = "versions"
script = "cargo fmt --version"

[[task]]
name = "rustdoc"
group = "versions"
script = "rustdoc --version"

[[task]]
name = "cargo-clippy"
group = "versions"
script = "cargo clippy -- --version"

[[task]]
name = "cargo-audit"
group = "versions"
script = "cargo audit --version"

[[task]]
name = "cargo-deb"
group = "versions"
script = "cargo deb --version"

[[task]]
name = "lychee"
group = "versions"
script = "lychee --version"

[[task]]
name = "markdownlint"
group = "versions"
script = "markdownlint --version"

[[task]]
name = "cargo-audit"
group = "security"
script = "cargo audit --color=always -D warnings -D unmaintained -D unsound -D yanked"

[[task]]
name = "cargo-fmt"
group = "lints"
script = """
cargo fmt --check -- --color=always
"""

[[task]]
name = "cargo-doc"
group = "lints"
script = """
env DIRENV_DEVSHELL=all-features \
    RUSTDOCFLAGS="-D warnings" \
    direnv exec . \
    cargo doc \
        --workspace \
        --locked \
        --profile test \
        --features full \
        --no-deps \
        --document-private-items \
        --color always
"""

[[task]]
name = "clippy/default"
group = "lints"
script = """
direnv exec . \
cargo clippy \
    --workspace \
    --features full \
    --locked \
    --profile test \
    --color=always \
    -- \
    -D warnings
"""

[[task]]
name = "clippy/all"
group = "lints"
script = """
env DIRENV_DEVSHELL=all-features \
    direnv exec . \
    cargo clippy \
        --workspace \
        --locked \
        --profile test \
        --features full \
        --color=always \
        -- \
        -D warnings
"""

[[task]]
name = "clippy/no-features"
group = "lints"
script = """
env DIRENV_DEVSHELL=no-features \
    direnv exec . \
    cargo clippy \
        --workspace \
        --locked \
        --profile test \
        --no-default-features \
        --color=always \
        -- \
        -D warnings
"""

[[task]]
name = "clippy/other-features"
group = "lints"
script = """
direnv exec . \
cargo clippy \
    --workspace \
    --locked \
    --profile test \
    --no-default-features \
    --features=console,systemd,element_hacks,direct_tls,perf_measurements,brotli_compression,blurhashing \
    --color=always \
    -- \
    -D warnings
"""

[[task]]
name = "lychee"
group = "lints"
script = "lychee --verbose --offline docs *.md --exclude development.md --exclude contributing.md --exclude testing.md"

[[task]]
name = "markdownlint"
group = "lints"
script = "markdownlint docs *.md || true" # TODO: fix the ton of markdown lints so we can drop `|| true`

[[task]]
name = "cargo/default"
group = "tests"
script = """
env DIRENV_DEVSHELL=default \
    direnv exec . \
    cargo test \
        --workspace \
        --locked \
        --profile test \
        --all-targets \
        --no-fail-fast \
        --color=always \
        -- \
        --color=always
"""

# Checks if the generated example config differs from the checked in repo's
# example config.
[[task]]
name = "example-config"
group = "tests"
depends = ["cargo/default"]
script = """
git diff --exit-code conduwuit-example.toml
"""
