this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

build: add shellcheck, actionlint, statix, deadnix as nix checks

+83 -20
+1 -1
.github/workflows/codeberg-mirror.yml
··· 8 8 codeberg: 9 9 runs-on: ubuntu-latest 10 10 steps: 11 - - uses: actions/checkout@v3 11 + - uses: actions/checkout@v4 12 12 with: 13 13 fetch-depth: 0 14 14 - uses: yesolutions/mirror-action@master
+15 -12
bin/test.sh
··· 8 8 # Create a tmp directory and cd into it 9 9 tmpdir() { 10 10 mkdir -p "$CACHE_DIR" 11 - local dir=$(mktemp --directory --tmpdir="$CACHE_DIR") 11 + local dir 12 + dir=$(mktemp --directory --tmpdir="$CACHE_DIR") 12 13 cd "$dir" 13 14 } 14 15 ··· 30 31 local file2="$2" 31 32 # Use $3 as the max difference or 100 bytes 32 33 local max_diff=${3:-100} 33 - local size1=$(stat -c %s "$file1") 34 - local size2=$(stat -c %s "$file2") 35 - if [ $((size1 - size2)) -gt $max_diff ]; then 34 + local size1 35 + local size2 36 + size1=$(stat -c %s "$file1") 37 + size2=$(stat -c %s "$file2") 38 + if [ $((size1 - size2)) -gt "$max_diff" ]; then 36 39 echo "Size difference too large: $file1:$size1 $file2:$size2" 37 40 exit 1 38 41 fi ··· 67 70 echo "Creating random data" 68 71 random_file 1000000 file 69 72 echo "Compressing with gzip and cmprss" 70 - gzip -$1 -c file >gzip_file.gz 71 - cmprss gzip --level $1 file cmprss_file.gz --progress=off 73 + gzip -"$1" -c file >gzip_file.gz 74 + cmprss gzip --level "$1" file cmprss_file.gz --progress=off 72 75 # Compare the two archives 73 76 # The archives may have slight variations (versioning or whatever) so we 74 77 # only compare the sizes to make sure they are similar ··· 100 103 echo "Creating random data" 101 104 random_file 1000000 file 102 105 echo "Compressing with xz and cmprss" 103 - xz -$1 --stdout file >xz_file.xz 104 - cmprss xz --level $1 file cmprss_file.xz --progress=off 106 + xz -"$1" --stdout file >xz_file.xz 107 + cmprss xz --level "$1" file cmprss_file.xz --progress=off 105 108 # Compare the two archives 106 109 # The archives may have slight variations (versioning or whatever) so we 107 110 # only compare the sizes to make sure they are similar ··· 134 137 echo "Creating random data" 135 138 random_file 1000000 file 136 139 echo "Compressing with bzip2 and cmprss" 137 - bzip2 -$1 --stdout file >bzip2_file.bz2 138 - cmprss bzip2 --level $1 file cmprss_file.bz2 --progress=off 140 + bzip2 -"$1" --stdout file >bzip2_file.bz2 141 + cmprss bzip2 --level "$1" file cmprss_file.bz2 --progress=off 139 142 # Compare the two archives 140 143 # The archives may have slight variations (versioning or whatever) so we 141 144 # only compare the sizes to make sure they are similar ··· 167 170 echo "Creating random data" 168 171 random_file 1000000 file 169 172 echo "Compressing with zstd and cmprss" 170 - zstd -$1 -c file >zstd_file.zst 171 - cmprss zstd --level $1 file cmprss_file.zst --progress=off 173 + zstd -"$1" -c file >zstd_file.zst 174 + cmprss zstd --level "$1" file cmprss_file.zst --progress=off 172 175 # Compare the two archives 173 176 # The archives may have slight variations (versioning or whatever) so we 174 177 # only compare the sizes to make sure they are similar
+67 -7
flake.nix
··· 83 83 doCheck = false; # Tests are run as a separate build with nextest 84 84 meta.mainProgram = "cmprss"; 85 85 }); 86 + # Source filtered to specific file extensions for lightweight linter checks 87 + cleanSrc = pkgs.lib.cleanSource ./.; 88 + sourceWithExts = exts: 89 + pkgs.lib.cleanSourceWith { 90 + src = cleanSrc; 91 + filter = path: type: 92 + (type == "directory") 93 + || (pkgs.lib.any (ext: pkgs.lib.hasSuffix ".${ext}" path) exts); 94 + }; 95 + 96 + mkSimpleLinter = { 97 + name, 98 + packages ? [], 99 + src ? cleanSrc, 100 + command, 101 + }: 102 + pkgs.runCommand "lint-${name}" { 103 + nativeBuildInputs = packages; 104 + inherit src; 105 + } '' 106 + cd $src 107 + ${command} 108 + mkdir -p $out 109 + ''; 110 + 111 + linters = { 112 + statix = mkSimpleLinter { 113 + name = "statix"; 114 + packages = [pkgs.statix]; 115 + src = sourceWithExts ["nix"]; 116 + command = "statix check ."; 117 + }; 118 + deadnix = mkSimpleLinter { 119 + name = "deadnix"; 120 + packages = [pkgs.deadnix]; 121 + src = sourceWithExts ["nix"]; 122 + command = "deadnix --fail ."; 123 + }; 124 + shellcheck = mkSimpleLinter { 125 + name = "shellcheck"; 126 + packages = [pkgs.shellcheck pkgs.findutils]; 127 + src = sourceWithExts ["sh"]; 128 + command = ''find . -name "*.sh" -type f -exec shellcheck {} +''; 129 + }; 130 + actionlint = mkSimpleLinter { 131 + name = "actionlint"; 132 + packages = [pkgs.actionlint pkgs.shellcheck pkgs.findutils]; 133 + src = pkgs.lib.cleanSourceWith { 134 + src = cleanSrc; 135 + filter = path: type: 136 + (type == "directory") 137 + || (pkgs.lib.hasSuffix ".yml" path && pkgs.lib.hasInfix ".github" path); 138 + }; 139 + command = ''find .github/workflows -name "*.yml" -exec actionlint {} +''; 140 + }; 141 + }; 86 142 in { 87 143 packages = { 88 144 default = cmprss; 89 - cmprss = cmprss; 145 + inherit cmprss; 90 146 91 147 # Check code coverage with tarpaulin 92 148 coverage = craneLib.cargoTarpaulin (commonArgs ··· 118 174 }); 119 175 }; 120 176 121 - checks = { 122 - inherit cmprss; 123 - # Build almost every package in checks, with exceptions: 124 - # - coverage: It requires a full rebuild, and only needs to be run occasionally 125 - inherit (self.packages.${system}) clippy doc fmt test deny; 126 - }; 177 + checks = 178 + { 179 + inherit cmprss; 180 + # Build almost every package in checks, with exceptions: 181 + # - coverage: It requires a full rebuild, and only needs to be run occasionally 182 + inherit (self.packages.${system}) clippy doc fmt test deny; 183 + } 184 + // linters; 127 185 128 186 # This also sets up `nix fmt` to run all formatters 129 187 treefmt = { ··· 167 225 packages = with pkgs; [ 168 226 act # For running Github Actions locally 169 227 alejandra 228 + actionlint 170 229 deadnix 171 230 git-cliff 172 231 go-task 173 232 gum # Pretty printing in scripts 174 233 nodePackages.prettier 234 + shellcheck 175 235 statix 176 236 177 237 # For running tests