From 3b17c94597dc0cd2aa911752f966bd227a912849 Mon Sep 17 00:00:00 2001 From: Charles Hall Date: Fri, 21 Jun 2024 15:28:36 -0700 Subject: [PATCH] apply changes from project template --- Cargo.toml | 82 +++++++++++++++++++++++++++++++++++++++++++-- engage.toml | 9 ++++- flake.lock | 96 +++++++++++++++++++---------------------------------- flake.nix | 68 +++++++++++++++++-------------------- src/main.rs | 39 +--------------------- 5 files changed, 153 insertions(+), 141 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a1cd1e5..c9f3921 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,85 @@ +[workspace.lints.rust] +elided_lifetimes_in_paths = "warn" +explicit_outlives_requirements = "warn" +macro_use_extern_crate = "warn" +missing_abi = "warn" +missing_docs = "warn" +noop_method_call = "warn" +pointer_structural_match = "warn" +single_use_lifetimes = "warn" +unit_bindings = "warn" +unreachable_pub = "warn" +unsafe_op_in_unsafe_fn = "warn" +unused_extern_crates = "warn" +unused_import_braces = "warn" +unused_lifetimes = "warn" +unused_macro_rules = "warn" +unused_qualifications = "warn" + +[workspace.lints.clippy] +pedantic = "warn" + +as_conversions = "warn" +assertions_on_result_states = "warn" +dbg_macro = "warn" +default_union_representation = "warn" +deref_by_slicing = "warn" +empty_drop = "warn" +empty_enum_variants_with_brackets = "warn" +empty_structs_with_brackets = "warn" +error_impl_error = "warn" +exit = "warn" +filetype_is_file = "warn" +float_cmp_const = "warn" +format_push_string = "warn" +get_unwrap = "warn" +if_then_some_else_none = "warn" +impl_trait_in_params = "warn" +infinite_loop = "warn" +let_underscore_must_use = "warn" +let_underscore_untyped = "warn" +lossy_float_literal = "warn" +map_err_ignore = "warn" +mem_forget = "warn" +missing_assert_message = "warn" +missing_docs_in_private_items = "warn" +mod_module_files = "warn" +multiple_inherent_impl = "warn" +mutex_atomic = "warn" +negative_feature_names = "warn" +pub_without_shorthand = "warn" +rc_buffer = "warn" +rc_mutex = "warn" +redundant_feature_names = "warn" +redundant_type_annotations = "warn" +ref_patterns = "warn" +rest_pat_in_fully_bound_structs = "warn" +same_name_method = "warn" +semicolon_inside_block = "warn" +str_to_string = "warn" +string_add = "warn" +string_lit_chars_any = "warn" +string_slice = "warn" +string_to_string = "warn" +suspicious_xor_used_as_pow = "warn" +tests_outside_test_module = "warn" +try_err = "warn" +undocumented_unsafe_blocks = "warn" +unnecessary_safety_comment = "warn" +unnecessary_safety_doc = "warn" +unnecessary_self_imports = "warn" +unneeded_field_pattern = "warn" +unseparated_literal_suffix = "warn" +unwrap_used = "warn" +verbose_file_reads = "warn" +wildcard_dependencies = "warn" + [package] name = "ghat" description = "GitHub Actions Test" version = "0.1.0" edition = "2021" license = "MIT OR Apache-2.0" -authors = [ - "Charles Hall ", -] + +[lints] +workspace = true diff --git a/engage.toml b/engage.toml index e4c0b2e..2595279 100644 --- a/engage.toml +++ b/engage.toml @@ -86,4 +86,11 @@ script = "cargo clippy --workspace --all-targets --color=always -- -D warnings" [[task]] name = "cargo" group = "tests" -script = "cargo test --workspace --all-targets --color=always -- --color=always" +script = """ +cargo llvm-cov \ + --workspace \ + --all-targets \ + --color=always \ + -- \ + --color=always +""" diff --git a/flake.lock b/flake.lock index cde9b5d..5230460 100644 --- a/flake.lock +++ b/flake.lock @@ -2,25 +2,21 @@ "nodes": { "crane": { "inputs": { - "flake-compat": "flake-compat", - "flake-utils": [ - "flake-utils" - ], "nixpkgs": [ "nixpkgs" - ], - "rust-overlay": "rust-overlay" + ] }, "locked": { - "lastModified": 1696384830, - "narHash": "sha256-j8ZsVqzmj5sOm5MW9cqwQJUZELFFwOislDmqDDEMl6k=", + "lastModified": 1718730147, + "narHash": "sha256-QmD6B6FYpuoCqu6ZuPJH896ItNquDkn0ulQlOn4ykN8=", "owner": "ipetkov", "repo": "crane", - "rev": "f2143cd27f8bd09ee4f0121336c65015a2a0a19c", + "rev": "32c21c29b034d0a93fdb2379d6fabc40fc3d0e6c", "type": "github" }, "original": { "owner": "ipetkov", + "ref": "master", "repo": "crane", "type": "github" } @@ -33,60 +29,62 @@ "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1696314121, - "narHash": "sha256-Dd0xm92D6cQ0c46uTMzBy7Zq9tyHScArpJtkzT87L4E=", + "lastModified": 1717827974, + "narHash": "sha256-ixopuTeTouxqTxfMuzs6IaRttbT8JqRW5C9Q/57WxQw=", "owner": "nix-community", "repo": "fenix", - "rev": "c543df32930d075f807fc0b00c3101bc6a3b163d", + "rev": "ab655c627777ab5f9964652fe23bbb1dfbd687a8", "type": "github" }, "original": { "owner": "nix-community", + "ref": "main", "repo": "fenix", "type": "github" } }, - "flake-compat": { - "flake": false, + "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1696267196, - "narHash": "sha256-AAQ/2sD+0D18bb8hKuEEVpHUYD1GmO2Uh/taFamn6XQ=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "4f910c9827911b1ec2bf26b5a062cd09f8d89f85", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { - "owner": "edolstra", - "repo": "flake-compat", + "owner": "numtide", + "ref": "main", + "repo": "flake-utils", "type": "github" } }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, + "nix-filter": { "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "lastModified": 1710156097, + "narHash": "sha256-1Wvk8UP7PXdf8bCCaEoMnOT1qe5/Duqgj+rL8sRQsSM=", "owner": "numtide", - "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "repo": "nix-filter", + "rev": "3342559a24e85fc164b295c3444e8a139924675b", "type": "github" }, "original": { "owner": "numtide", - "repo": "flake-utils", + "ref": "main", + "repo": "nix-filter", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1696193975, - "narHash": "sha256-mnQjUcYgp9Guu3RNVAB2Srr1TqKcPpRXmJf4LJk6KRY=", + "lastModified": 1718895438, + "narHash": "sha256-k3JqJrkdoYwE3fHE6xGDY676AYmyh4U2Zw+0Bwe5DLU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "fdd898f8f79e8d2f99ed2ab6b3751811ef683242", + "rev": "d603719ec6e294f034936c0d0dc06f689d91b6c3", "type": "github" }, "original": { @@ -101,17 +99,18 @@ "crane": "crane", "fenix": "fenix", "flake-utils": "flake-utils", + "nix-filter": "nix-filter", "nixpkgs": "nixpkgs" } }, "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1696238629, - "narHash": "sha256-KfFwKSVS0fj6XFNjmiOvtjkwtPCZAzN2eGE5UAIfJ5k=", + "lastModified": 1717583671, + "narHash": "sha256-+lRAmz92CNUxorqWusgJbL9VE1eKCnQQojglRemzwkw=", "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "4c9d2c75b55ab3f21abcaa0ae55373d8b5d7f80a", + "rev": "48bbdd6a74f3176987d5c809894ac33957000d19", "type": "github" }, "original": { @@ -121,31 +120,6 @@ "type": "github" } }, - "rust-overlay": { - "inputs": { - "flake-utils": [ - "crane", - "flake-utils" - ], - "nixpkgs": [ - "crane", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1696299134, - "narHash": "sha256-RS77cAa0N+Sfj5EmKbm5IdncNXaBCE1BSSQvUE8exvo=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "611ccdceed92b4d94ae75328148d84ee4a5b462d", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index 42d8cac..c1e7fe3 100644 --- a/flake.nix +++ b/flake.nix @@ -1,39 +1,24 @@ { inputs = { + crane = { url = "github:ipetkov/crane?ref=master"; inputs.nixpkgs.follows = "nixpkgs"; }; + fenix = { url = "github:nix-community/fenix?ref=main"; inputs.nixpkgs.follows = "nixpkgs"; }; + flake-utils.url = "github:numtide/flake-utils?ref=main"; + nix-filter.url = "github:numtide/nix-filter?ref=main"; nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - - fenix = { - url = "github:nix-community/fenix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - crane = { - url = "github:ipetkov/crane"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.flake-utils.follows = "flake-utils"; - }; }; - outputs = - { self - , nixpkgs - , flake-utils - - , fenix - , crane - }: flake-utils.lib.eachDefaultSystem (system: + outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem (system: let - pkgs = nixpkgs.legacyPackages.${system}; + pkgs = inputs.nixpkgs.legacyPackages.${system}; stdenv = if pkgs.stdenv.isLinux then pkgs.stdenvAdapters.useMoldLinker pkgs.stdenv else pkgs.stdenv; - mkToolchain = fenix.packages.${system}.combine; + mkToolchain = inputs.fenix.packages.${system}.combine; - toolchain = fenix.packages.${system}.stable; + toolchain = inputs.fenix.packages.${system}.stable; buildToolchain = mkToolchain (with toolchain; [ cargo @@ -43,43 +28,50 @@ devToolchain = mkToolchain (with toolchain; [ cargo clippy + llvm-tools rust-src rustc # Always use nightly rustfmt because most of its options are unstable - fenix.packages.${system}.latest.rustfmt + inputs.fenix.packages.${system}.latest.rustfmt ]); - builder = - ((crane.mkLib pkgs).overrideToolchain buildToolchain).buildPackage; + builder = ( + (inputs.crane.mkLib pkgs).overrideToolchain buildToolchain + ).buildPackage; in { packages.default = builder { - src = ./.; + src = let filter = inputs.nix-filter.lib; in filter { + root = ./.; + include = [ + "Cargo.lock" + "Cargo.toml" + "README.md" + "src" + ]; + }; inherit stdenv; }; devShells.default = (pkgs.mkShell.override { inherit stdenv; }) { - # Rust Analyzer needs to be able to find the path to default crate - # sources, and it can read this environment variable to do so. The - # `rust-src` component is required in order for this to work. - RUST_SRC_PATH = "${devToolchain}/lib/rustlib/src/rust/library"; + env = { + # Rust Analyzer needs to be able to find the path to default crate + # sources, and it can read this environment variable to do so. The + # `rust-src` component is required in order for this to work. + RUST_SRC_PATH = "${devToolchain}/lib/rustlib/src/rust/library"; + }; - # Development tools - nativeBuildInputs = [ + packages = [ devToolchain ] ++ (with pkgs; [ + cargo-llvm-cov engage nixpkgs-fmt ]) ++ (with pkgs.nodePackages; [ markdownlint-cli ]); }; - - checks = { - packagesDefault = self.packages.${system}.default; - devShellsDefault = self.devShells.${system}.default; - }; }); } diff --git a/src/main.rs b/src/main.rs index 09b06b6..9208ca2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,41 +1,4 @@ -#![doc = include_str!("../README.md")] -#![warn(missing_abi)] -#![warn(missing_docs)] -#![warn(noop_method_call)] -#![warn(pointer_structural_match)] -#![warn(unreachable_pub)] -#![warn(unused_extern_crates)] -#![warn(unused_import_braces)] -#![warn(unused_lifetimes)] -#![warn(unused_qualifications)] -#![warn(unused_tuple_struct_fields)] -#![warn(clippy::pedantic)] -#![warn(clippy::as_conversions)] -#![warn(clippy::dbg_macro)] -#![warn(clippy::empty_structs_with_brackets)] -#![warn(clippy::get_unwrap)] -#![warn(clippy::if_then_some_else_none)] -#![warn(clippy::let_underscore_must_use)] -#![warn(clippy::map_err_ignore)] -#![warn(clippy::missing_docs_in_private_items)] -#![warn(clippy::negative_feature_names)] -#![warn(clippy::pub_without_shorthand)] -#![warn(clippy::rc_buffer)] -#![warn(clippy::rc_mutex)] -#![warn(clippy::redundant_feature_names)] -#![warn(clippy::redundant_type_annotations)] -#![warn(clippy::ref_patterns)] -#![warn(clippy::rest_pat_in_fully_bound_structs)] -#![warn(clippy::str_to_string)] -#![warn(clippy::string_add)] -#![warn(clippy::string_slice)] -#![warn(clippy::string_to_string)] -#![warn(clippy::tests_outside_test_module)] -#![warn(clippy::undocumented_unsafe_blocks)] -#![warn(clippy::unneeded_field_pattern)] -#![warn(clippy::unseparated_literal_suffix)] -#![warn(clippy::unwrap_used)] -#![warn(clippy::wildcard_dependencies)] +#![doc = env!("CARGO_PKG_DESCRIPTION")] fn main() { println!("Hello, world!");