[fractal/fractal-next] checks: Use stricter rustfmt rules
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/fractal-next] checks: Use stricter rustfmt rules
- Date: Thu, 20 Jan 2022 10:45:17 +0000 (UTC)
commit 3abd9fde87ac23a5d3724c8b45eae2351433c311
Author: Kévin Commaille <zecakeh tedomum fr>
Date: Thu Jan 20 09:08:11 2022 +0100
checks: Use stricter rustfmt rules
.gitlab-ci.yml | 2 +-
.rustfmt.toml | 8 ++++++++
scripts/checks.sh | 14 +++++++-------
3 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 291a55dd..ad322622 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -35,7 +35,7 @@ flatpak:
# Configure and run code checks
# Exits and fails if an error is encountered
checks:
- image: "rust:slim"
+ image: "rustlang/rust:nightly-slim"
stage: check
script:
- scripts/checks.sh --verbose --force-install
diff --git a/.rustfmt.toml b/.rustfmt.toml
new file mode 100644
index 00000000..6aa51c16
--- /dev/null
+++ b/.rustfmt.toml
@@ -0,0 +1,8 @@
+condense_wildcard_suffixes = true
+format_code_in_doc_comments = true
+group_imports = "StdExternalCrate"
+imports_granularity = "Crate"
+newline_style = "Unix"
+normalize_comments = true
+normalize_doc_attributes = true
+wrap_comments = true
diff --git a/scripts/checks.sh b/scripts/checks.sh
index 5dd7a68a..c620445d 100755
--- a/scripts/checks.sh
+++ b/scripts/checks.sh
@@ -87,7 +87,7 @@ check_rustup() {
if ! which rustup &> /dev/null; then
if [[ "$1" == '-i' ]]; then
echo -e "$Installing rustup…"
- curl https://sh.rustup.rs -sSf | sh -s -- -y
+ curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly
export PATH=$PATH:$HOME/.cargo/bin
if ! which rustup &> /dev/null; then
echo -e "$Failed to install rustup"
@@ -145,7 +145,7 @@ check_cargo() {
if [[ $verbose -eq 1 ]]; then
echo ""
- rustc -Vv && cargo -Vv
+ rustc -Vv && cargo +nightly -Vv
fi
}
@@ -154,8 +154,8 @@ install_rustfmt() {
check_rustup -i
echo -e "$Installing rustfmt…"
- rustup component add rustfmt
- if ! cargo fmt --version >/dev/null 2>&1; then
+ rustup component add --toolchain nightly rustfmt
+ if ! cargo +nightly fmt --version >/dev/null 2>&1; then
echo -e "$Failed to install rustfmt"
exit 2
fi
@@ -163,7 +163,7 @@ install_rustfmt() {
# Run rustfmt to enforce code style.
run_rustfmt() {
- if ! cargo fmt --version >/dev/null 2>&1; then
+ if ! cargo +nightly fmt --version >/dev/null 2>&1; then
if [[ $force_install -eq 1 ]]; then
install_rustfmt
elif [ ! -t 1 ]; then
@@ -197,11 +197,11 @@ run_rustfmt() {
if [[ $verbose -eq 1 ]]; then
echo ""
- cargo fmt --version
+ cargo +nightly fmt --version
echo ""
fi
- if ! cargo fmt --all -- --check; then
+ if ! cargo +nightly fmt --all -- --check; then
echo -e " Checking code style result: $fail"
echo "Please fix the above issues, either manually or by running: cargo fmt --all"
exit 1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]