ci: Sort Cargo.toml and add a check for it

This commit is contained in:
Kévin Commaille 2023-03-06 19:50:17 +01:00
parent 160b648cfe
commit 960c74c21d
No known key found for this signature in database
GPG key ID: DD507DAE96E8245C
2 changed files with 104 additions and 41 deletions

View file

@ -16,69 +16,62 @@ overflow-checks = false
incremental = false
codegen-units = 16
# Please keep dependencies sorted.
[dependencies]
async-stream = "0.3"
log = "0.4"
mime = "0.3.16"
tracing-subscriber = "0.3"
gettext-rs = { version = "0.7", features = ["gettext-system"] }
once_cell = "1.5"
serde = "1.0.130"
serde_json = "1.0"
tokio = { version = "1.15", features = ["rt", "rt-multi-thread", "sync"] }
url = "2.2"
oo7 = { version = "0.1.0-beta.3", default-features = false, features = [
"native_crypto",
"tokio",
"tracing",
] }
html2pango = "0.5.0"
futures = "0.3"
rand = "0.8"
indexmap = "1.6.2"
qrcode = "0.12.0"
ashpd = { version = "0.4.0-alpha.4", default-features = false, features = [
"gtk4",
"pipewire",
"tracing",
"tokio",
] }
async-stream = "0.3"
djb_hash = "0.1.3"
futures = "0.3"
futures-signals = { version = "0.3.30", default-features = false }
geo-uri = "0.2.0"
gettext-rs = { version = "0.7", features = ["gettext-system"] }
gst = { version = "0.20.2", package = "gstreamer" }
gst_base = { version = "0.20.0", package = "gstreamer-base" }
gst_video = { version = "0.20.2", package = "gstreamer-video" }
gst_play = { version = "0.20.2", package = "gstreamer-play" }
gst_gtk = { version = "0.10.3", package = "gst-plugin-gtk4" }
gst_pbutils = { version = "0.20.0", package = "gstreamer-pbutils" }
gst_play = { version = "0.20.2", package = "gstreamer-play" }
gst_video = { version = "0.20.2", package = "gstreamer-video" }
html-escape = "0.2.11"
html2pango = "0.5.0"
image = "0.24"
regex = "1.5.4"
indexmap = "1.6.2"
log = "0.4"
mime = "0.3.16"
mime_guess = "2.0.3"
num_enum = "0.5.6"
thiserror = "1.0.25"
once_cell = "1.5"
oo7 = { version = "0.1.0-beta.3", default-features = false, features = [
"native_crypto",
"tokio",
"tracing",
] }
pulldown-cmark = "0.9.2"
qrcode = "0.12.0"
rand = "0.8"
regex = "1.5.4"
rqrr = "0.5"
secular = { version = "1.0.1", features = ["bmp", "normalization"] }
pulldown-cmark = "0.9.2"
geo-uri = "0.2.0"
html-escape = "0.2.11"
djb_hash = "0.1.3"
futures-signals = { version = "0.3.30", default-features = false }
[dependencies.sourceview]
package = "sourceview5"
version = "0.6.0"
[dependencies.gtk]
package = "gtk4"
version = "0.6.2"
features = ["v4_6"]
serde = "1.0.130"
serde_json = "1.0"
thiserror = "1.0.25"
tokio = { version = "1.15", features = ["rt", "rt-multi-thread", "sync"] }
tracing-subscriber = "0.3"
url = "2.2"
[dependencies.adw]
package = "libadwaita"
version = "0.3.1"
features = ["v1_3"]
[dependencies.shumate]
package = "libshumate"
version = "0.3.0"
[dependencies.gtk]
package = "gtk4"
version = "0.6.2"
features = ["v4_6"]
[dependencies.matrix-sdk]
git = "https://github.com/matrix-org/matrix-rust-sdk.git"
@ -101,6 +94,15 @@ features = ["crypto-store"]
version = "0.8.1"
features = ["unstable-unspecified", "client-api-c", "unstable-sanitize"]
[dependencies.shumate]
package = "libshumate"
version = "0.3.0"
[dependencies.sourceview]
package = "sourceview5"
version = "0.6.0"
# FIXME: Remove when matrix-sdk dependencies don't pin zeroize (conflict with oo7)
[patch.crates-io.x25519-dalek]
git = "https://github.com/A6GibKm/x25519-dalek"
rev = "9f19028c34107eea87d37bcee2eb2b350ec34cfe"

View file

@ -498,6 +498,65 @@ check_resources() {
fi
}
# Install cargo-sort with cargo.
install_cargo_sort() {
echo -e "$Installing cargo-sort…"
cargo install cargo-sort
if ! cargo-sort --version >/dev/null 2>&1; then
echo -e "$Failed to install cargo-sort"
exit 2
fi
}
# Run cargo-sort to check if Cargo.toml is sorted.
run_cargo_sort() {
if ! cargo-sort --version >/dev/null 2>&1; then
if [[ $force_install -eq 1 ]]; then
install_cargo_sort
elif [ ! -t 1 ]; then
echo "Unable to check Cargo.toml sorting, because cargo-sort could not be run"
exit 2
else
echo "Cargo-sort is needed to check the sorting in Cargo.toml, but it isnt available"
echo ""
echo "y: Install cargo-sort via cargo"
echo "N: Don't install cargo-sort and abort checks"
echo ""
while true; do
echo -n "Install cargo-sort? [y/N]: "; read yn < /dev/tty
case $yn in
[Yy]* )
install_cargo_sort
break
;;
[Nn]* | "" )
exit 2
;;
* )
echo $invalid
;;
esac
done
fi
fi
echo -e "$Checking Cargo.toml sorting…"
if [[ $verbose -eq 1 ]]; then
echo ""
cargo-sort --version
echo ""
fi
if ! cargo-sort --check --grouped --order package,lib,profile,features,dependencies,target,dev-dependencies,build-dependencies; then
echo -e " Cargo.toml sorting result: $fail"
echo "Please fix the Cargo.toml file, either manually or by running: cargo-sort --grouped --order package,lib,profile,features,dependencies,target,dev-dependencies,build-dependencies"
exit 1
else
echo -e " Cargo.toml sorting result: $ok"
fi
}
# Check arguments
while [[ "$1" ]]; do case $1 in
-s | --git-staged )
@ -547,3 +606,5 @@ else
check_resources
fi
echo ""
run_cargo_sort
echo ""