From 641e48c947c5433e767957f53a6181e3628b8bf1 Mon Sep 17 00:00:00 2001 From: Arne Beer Date: Fri, 13 Dec 2024 19:36:22 +0100 Subject: [PATCH] ci(toml): Use taplo for toml formatting --- .config/nextest.toml | 2 +- .github/workflows/lint.yml | 12 ++++-------- .taplo.toml | 4 ++++ Cargo.toml | 14 +++++++------- Cross.toml | 24 ++++++++---------------- Justfile | 38 +++++++++++++++++++++++--------------- pueue/Cargo.toml | 24 ++++++++++++------------ pueue_lib/Cargo.toml | 22 +++++++++++----------- 8 files changed, 70 insertions(+), 70 deletions(-) create mode 100644 .taplo.toml diff --git a/.config/nextest.toml b/.config/nextest.toml index f6299c3c..9936c0ed 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -43,5 +43,5 @@ path = "junit.xml" # - lower retry count as a compromise between speed and resilience # - no fail-fast to at least keep coverage percentages accurate. [profile.coverage] -retries = 1 fail-fast = false +retries = 1 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d9e6048e..1c83d70b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -80,12 +80,8 @@ jobs: - name: cargo clippy run: cargo clippy --tests --workspace -- -D warnings - #- name: cargo sort - # run: cargo sort --workspace --check - # # Don't run cargo-sort on windows, as the formatting behavior seems to be slightly different: - # # https://github.com/DevinR528/cargo-sort/issues/56 - # if: matrix.target != 'x86_64-pc-windows-msvc' + - name: Install taplo-cli + run: cargo install taplo-cli || exit 0 - #- name: Install cargo-sort - # run: cargo install cargo-sort || exit 0 - # if: matrix.target != 'x86_64-pc-windows-msvc' + - name: cargo sort + run: ~/.cargo/bin/taplo format --check diff --git a/.taplo.toml b/.taplo.toml new file mode 100644 index 00000000..21c70aac --- /dev/null +++ b/.taplo.toml @@ -0,0 +1,4 @@ +[formatting] +indent_string = " " +reorder_arrays = true +reorder_keys = true diff --git a/Cargo.toml b/Cargo.toml index aeba0094..8fef0840 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,28 +5,28 @@ resolver = "2" [workspace.package] authors = ["Arne Beer "] +edition = "2021" homepage = "https://github.com/nukesor/pueue" -repository = "https://github.com/nukesor/pueue" license = "MIT OR Apache-2.0" -edition = "2021" +repository = "https://github.com/nukesor/pueue" rust-version = "1.70" [workspace.dependencies] # Chrono version is hard pinned to a specific version. # See https://github.com/Nukesor/pueue/issues/534 +anyhow = "1" +better-panic = "0.3" chrono = { version = "0.4", features = ["serde"] } command-group = "5" +handlebars = "5.1" log = "0.4" +pretty_assertions = "1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde_yaml = "0.9" snap = "1.1" strum = { version = "0.26", features = ["derive"] } -tokio = { version = "1.36", features = ["rt-multi-thread", "time", "io-std"] } -handlebars = "5.1" -anyhow = "1" -better-panic = "0.3" -pretty_assertions = "1" +tokio = { version = "1.36", features = ["io-std", "rt-multi-thread", "time"] } [profile.release] codegen-units = 1 diff --git a/Cross.toml b/Cross.toml index df5e4a67..241ffce9 100644 --- a/Cross.toml +++ b/Cross.toml @@ -1,36 +1,28 @@ [target.x86_64-unknown-linux-musl] image = "ghcr.io/cross-rs/x86_64-unknown-linux-musl:main" -pre-build = [ - """ +pre-build = [""" dpkg --add-architecture amd64 && \ apt-get update && \ apt-get install --assume-yes lld clang - """ -] + """] [target.aarch64-unknown-linux-musl] image = "ghcr.io/cross-rs/aarch64-unknown-linux-musl:main" -pre-build = [ - """ +pre-build = [""" apt-get update && \ apt-get install --assume-yes lld clang - """ -] + """] [target.armv7-unknown-linux-musleabihf] image = "ghcr.io/cross-rs/armv7-unknown-linux-musleabihf:main" -pre-build = [ - """ +pre-build = [""" apt-get update && \ apt-get install --assume-yes lld clang - """ -] + """] [target.arm-unknown-linux-musleabihf] image = "ghcr.io/cross-rs/arm-unknown-linux-musleabihf:main" -pre-build = [ - """ +pre-build = [""" apt-get update && \ apt-get install --assume-yes lld clang - """ -] + """] diff --git a/Justfile b/Justfile index 1fceaefa..ba9ac5b8 100644 --- a/Justfile +++ b/Justfile @@ -1,31 +1,39 @@ # Bump all deps, including incompatible version upgrades bump: - just ensure_installed upgrade + just ensure-command cargo-upgrade cargo update cargo upgrade --incompatible cargo test --workspace -# Run the test suite with nexttest +# Run the test suite with nextest nextest: - just ensure_installed nextest + just ensure-command cargo-nextest cargo nextest run --workspace # If you change anything in here, make sure to also adjust the lint CI job! lint: - just ensure_installed sort + just ensure-command cargo-nextest cargo fmt --all -- --check - cargo sort --workspace --check + taplo format --check cargo clippy --tests --workspace -- -D warnings format: - just ensure_installed sort + just ensure-command taplo cargo fmt - cargo sort --workspace - -ensure_installed *args: - #!/bin/bash - cargo --list | grep -q {{ args }} - if [[ $? -ne 0 ]]; then - echo "error: cargo-{{ args }} is not installed" - exit 1 - fi + taplo format + + +# Ensures that one or more required commands are installed +ensure-command +command: + #!/usr/bin/env bash + set -euo pipefail + + read -r -a commands <<< "{{ command }}" + + for cmd in "${commands[@]}"; do + if ! command -v "$cmd" > /dev/null 2>&1 ; then + printf "Couldn't find required executable '%s'\n" "$cmd" >&2 + exit 1 + fi + done + diff --git a/pueue/Cargo.toml b/pueue/Cargo.toml index 386c950f..7da1e1fa 100644 --- a/pueue/Cargo.toml +++ b/pueue/Cargo.toml @@ -1,15 +1,15 @@ [package] -name = "pueue" -version = "4.0.0-rc.1" -description = "A cli tool for managing long running shell commands." -keywords = ["shell", "command", "parallel", "task", "queue"] -readme = "../README.md" authors.workspace = true +description = "A cli tool for managing long running shell commands." +edition.workspace = true homepage.workspace = true -repository.workspace = true +keywords = ["command", "parallel", "queue", "shell", "task"] license.workspace = true -edition.workspace = true +name = "pueue" +readme = "../README.md" +repository.workspace = true rust-version.workspace = true +version = "4.0.0-rc.1" [badges] maintenance = { status = "actively-developed" } @@ -17,7 +17,7 @@ maintenance = { status = "actively-developed" } [dependencies] anyhow = "1.0" chrono.workspace = true -clap = { version = "4.5.1", features = ["derive", "cargo", "help"] } +clap = { version = "4.5.1", features = ["cargo", "derive", "help"] } clap_complete = "4.5.1" clap_complete_nushell = "4.5.1" comfy-table = "7" @@ -62,14 +62,14 @@ crossterm = { version = "0.28", default-features = false } crossterm = { version = "0.28", default-features = false, features = [ "windows", ] } -windows-service = "0.7.0" windows = { version = "0.58.0", features = [ - "Win32_System_RemoteDesktop", "Win32_Security", - "Win32_System_Threading", - "Win32_System_SystemServices", "Win32_System_Environment", + "Win32_System_RemoteDesktop", + "Win32_System_SystemServices", + "Win32_System_Threading", ] } +windows-service = "0.7.0" # Test specific dev-dependencies [target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))'.dependencies] diff --git a/pueue_lib/Cargo.toml b/pueue_lib/Cargo.toml index 227ec18e..73447ec1 100644 --- a/pueue_lib/Cargo.toml +++ b/pueue_lib/Cargo.toml @@ -1,15 +1,15 @@ [package] -name = "pueue-lib" -version = "0.27.0" +authors.workspace = true description = "The shared library to work with the Pueue client and daemon." +edition.workspace = true +homepage.workspace = true keywords = ["pueue"] +license.workspace = true +name = "pueue-lib" readme = "README.md" -authors = { workspace = true } -homepage.workspace = true repository.workspace = true -license.workspace = true -edition.workspace = true rust-version.workspace = true +version = "0.27.0" [badges] maintenance = { status = "actively-developed" } @@ -27,8 +27,8 @@ rand = "0.8" rcgen = "0.13" rev_buf_reader = "0.3" rustls = { version = "0.23", features = [ - "ring", "logging", + "ring", "std", "tls12", ], default-features = false } @@ -41,7 +41,7 @@ shellexpand = "3.1" snap.workspace = true strum.workspace = true thiserror = "2" -tokio = { workspace = true, features = ["macros", "net", "io-util"] } +tokio = { workspace = true, features = ["io-util", "macros", "net"] } tokio-rustls = { version = "0.26", default-features = false } [dev-dependencies] @@ -56,11 +56,11 @@ tokio.workspace = true # Windows [target.'cfg(windows)'.dependencies] winapi = { version = "0.3", features = [ - "tlhelp32", "errhandlingapi", - "processthreadsapi", - "minwindef", "impl-default", + "minwindef", + "processthreadsapi", + "tlhelp32", ] } # Unix