From abb74b9f495a218824c415a7d7cfca88a6c54e7b Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Sat, 8 Jan 2022 01:20:36 -0800 Subject: [PATCH] Add EditorConfig rules, fix trailing whitespaces --- .editorconfig | 22 ++++++++++++++++++++++ .github/workflows/editorconfig.yml | 20 ++++++++++++++++++++ README.md | 2 +- flake.nix | 2 +- manual/src/tutorial/index.md | 2 +- src/nix/hive/eval.nix | 2 +- src/nix/hive/mod.rs | 2 +- src/nix/host/mod.rs | 4 ++-- 8 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/workflows/editorconfig.yml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..607992b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +# EditorConfig configuration for Colmena + +# Top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file, utf-8 charset +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 + +# Rust +[*.rs] +indent_style = space +indent_size = 2 + +# Vendored +[manual/theme/highlight.js] +end_of_line = unset +insert_final_newline = unset +trim_trailing_whitespace = unset diff --git a/.github/workflows/editorconfig.yml b/.github/workflows/editorconfig.yml new file mode 100644 index 0000000..28607ab --- /dev/null +++ b/.github/workflows/editorconfig.yml @@ -0,0 +1,20 @@ +name: Check EditorConfig + +on: + pull_request: + push: +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2.3.4 + - uses: cachix/install-nix-action@v15 + + - name: Enable binary cache (optional) + uses: cachix/cachix-action@v10 + with: + name: colmena + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + + - run: nix-shell --run "editorconfig-checker" diff --git a/README.md b/README.md index 61eab23..e84ae0d 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Here is a sample `hive.nix` with two nodes, with some common configurations appl # If you share a hive with others, or use multiple machines, # and are not careful to always commit/push/pull changes # you can accidentaly overwrite a remote profile so in those - # scenarios you might want to change this default to false. + # scenarios you might want to change this default to false. # deployment.replaceUnknownProfiles = true; }; diff --git a/flake.nix b/flake.nix index e983382..4e2430e 100644 --- a/flake.nix +++ b/flake.nix @@ -52,7 +52,7 @@ devShell = pkgs.mkShell { inputsFrom = [ defaultPackage ]; - packages = with pkgs; [ clippy mdbook python3 rust-analyzer ]; + packages = with pkgs; [ clippy mdbook python3 editorconfig-checker rust-analyzer ]; shellHook = '' export NIX_PATH=nixpkgs=${pkgs.path} ''; diff --git a/manual/src/tutorial/index.md b/manual/src/tutorial/index.md index 5ccc766..1732dda 100644 --- a/manual/src/tutorial/index.md +++ b/manual/src/tutorial/index.md @@ -76,7 +76,7 @@ Here is a sample `hive.nix` with two nodes, with some common configurations appl # If you share a hive with others, or use multiple machines, # and are not careful to always commit/push/pull changes # you can accidentaly overwrite a remote profile so in those - # scenarios you might want to change this default to false. + # scenarios you might want to change this default to false. # deployment.replaceUnknownProfiles = true; }; diff --git a/src/nix/hive/eval.nix b/src/nix/hive/eval.nix index 2fcfdc6..385e413 100644 --- a/src/nix/hive/eval.nix +++ b/src/nix/hive/eval.nix @@ -316,7 +316,7 @@ let else {}; # The final hive will always have the meta key instead of network. - hive = let + hive = let userMeta = (lib.modules.evalModules { modules = [ metaOptions uncheckedUserMeta ]; }).config; diff --git a/src/nix/hive/mod.rs b/src/nix/hive/mod.rs index 0870a41..96c43d2 100644 --- a/src/nix/hive/mod.rs +++ b/src/nix/hive/mod.rs @@ -400,7 +400,7 @@ impl<'hive> NixInstantiate<'hive> { /// to generate Nix expressions directly or escaping a JSON string to strip /// off Nix interpolation. struct SerializedNixExpresssion { - json_file: TempPath, + json_file: TempPath, } impl SerializedNixExpresssion { diff --git a/src/nix/host/mod.rs b/src/nix/host/mod.rs index a178b75..b92de4f 100644 --- a/src/nix/host/mod.rs +++ b/src/nix/host/mod.rs @@ -106,7 +106,7 @@ pub trait Host: Send + Sync + std::fmt::Debug { /// If `require_ownership` is false, then the ownership of a key /// will not be applied if the specified user/group does not /// exist. - #[allow(unused_variables)] + #[allow(unused_variables)] async fn upload_keys(&mut self, keys: &HashMap, require_ownership: bool) -> ColmenaResult<()> { Err(ColmenaError::Unsupported) } @@ -127,7 +127,7 @@ pub trait Host: Send + Sync + std::fmt::Debug { } /// Runs an arbitrary command on the host. - #[allow(unused_variables)] + #[allow(unused_variables)] async fn run_command(&mut self, command: &[&str]) -> ColmenaResult<()> { Err(ColmenaError::Unsupported) }