refactor(ci): introduce flake checks for static analysis, linting, and formatting
- Add `checks.${system}` block to `flake.nix` executing Ruff (linting and formatting checks), Pyright (static type analysis), and ShellCheck (shell script analysis across all `.sh` scripts).
- Add `shellcheck` package to `home/dev.nix`.
- Resolve linting and formatting issues across Python and Bash scripts (`bundle_project.py`, `git.sh`, `jump.sh`, `pdf.sh`, `todo.sh`, etc.) to ensure clean check evaluations.
Rationale: Automates quality control and code health standards directly inside the Nix flake ecosystem via `nix flake check`.
This commit is contained in:
1 parent
a19ed0aec6
commit
dfd09539b2
10 files changed
+62
-11
No files matched your search
@@ -56,7 +56,48 @@
|
||||
};
|
||||
|
||||
# --- System Outputs ---
|
||||
outputs = { self, nixpkgs, home-manager, dms, dgop, dank-greeter, dankcalendar, danksearch, zen-browser, antigravity, ... }@inputs: {
|
||||
outputs = { self, nixpkgs, home-manager, dms, dgop, dank-greeter, dankcalendar, danksearch, zen-browser, antigravity, ... }@inputs:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
# --- Linting, Formatting & Static Analysis Checks ---
|
||||
# Executed via `nix flake check` or `nix build .#checks.<system>.<check>`
|
||||
checks.${system} = {
|
||||
# Python linting via ruff
|
||||
ruff-lint = pkgs.runCommand "check-ruff-lint" {
|
||||
nativeBuildInputs = [ pkgs.ruff ];
|
||||
} ''
|
||||
ruff check --no-cache ${self}
|
||||
touch $out
|
||||
'';
|
||||
|
||||
# Python formatting check via ruff
|
||||
ruff-format = pkgs.runCommand "check-ruff-format" {
|
||||
nativeBuildInputs = [ pkgs.ruff ];
|
||||
} ''
|
||||
ruff format --check ${self}
|
||||
touch $out
|
||||
'';
|
||||
|
||||
# Python static type analysis via pyright
|
||||
pyright = pkgs.runCommand "check-pyright" {
|
||||
nativeBuildInputs = [ pkgs.pyright ];
|
||||
} ''
|
||||
pyright ${self}
|
||||
touch $out
|
||||
'';
|
||||
|
||||
# Shell script linting via ShellCheck
|
||||
shellcheck = pkgs.runCommand "check-shellcheck" {
|
||||
nativeBuildInputs = [ pkgs.shellcheck ];
|
||||
} ''
|
||||
find ${self} -type f -name "*.sh" -exec shellcheck -s bash {} +
|
||||
touch $out
|
||||
'';
|
||||
};
|
||||
|
||||
nixosConfigurations = {
|
||||
# 💻 LAPTOP HOST (Mobile Workstation)
|
||||
laptop = nixpkgs.lib.nixosSystem {
|
||||
|
||||
+2
-1
@@ -75,7 +75,7 @@
|
||||
nodejs
|
||||
prettier
|
||||
|
||||
# Language Servers (Zed, Neovim, General)
|
||||
# Language Servers, Linters & Diagnostics (Zed, Neovim, General)
|
||||
nil
|
||||
nixd
|
||||
jdt-language-server
|
||||
@@ -83,6 +83,7 @@
|
||||
lua-language-server
|
||||
taplo
|
||||
marksman
|
||||
shellcheck
|
||||
|
||||
# Cloud CLI, Git Forge & Database Management
|
||||
tea # Gitea official CLI client
|
||||
|
||||
@@ -29,7 +29,7 @@ def is_binary(file_path: Path) -> bool:
|
||||
def create_bundle(target_dir: Path, output_file: Path) -> None:
|
||||
"""
|
||||
Creates a single text bundle of a directory structure and its file contents.
|
||||
|
||||
|
||||
Args:
|
||||
target_dir: The directory to bundle.
|
||||
output_file: The path to write the bundled text file to.
|
||||
@@ -114,8 +114,7 @@ def main() -> None:
|
||||
"""
|
||||
parser = argparse.ArgumentParser(
|
||||
description=(
|
||||
"Bundle a directory structure and its files into "
|
||||
"a single text document."
|
||||
"Bundle a directory structure and its files into a single text document."
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
|
||||
+5
-2
@@ -1,3 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
# 🌟 Custom Git Automation & Helper Utilities
|
||||
# Sourced in .bashrc to streamline gitignore modifications, commit-push workflows, and new repo setups.
|
||||
|
||||
@@ -10,7 +11,8 @@ gitignore() {
|
||||
fi
|
||||
|
||||
# Find the top-level repository directory path
|
||||
local GIT_ROOT=$(git rev-parse --show-toplevel 2> /dev/null)
|
||||
local GIT_ROOT
|
||||
GIT_ROOT=$(git rev-parse --show-toplevel 2> /dev/null)
|
||||
if [ -z "$GIT_ROOT" ]; then
|
||||
echo "Error: Not a Git repository."
|
||||
return 1
|
||||
@@ -63,7 +65,8 @@ gacp() {
|
||||
fi
|
||||
git add -A
|
||||
git commit -m "$1"
|
||||
local branch_name=$(git branch --show-current)
|
||||
local branch_name
|
||||
branch_name=$(git branch --show-current)
|
||||
git push origin "${branch_name}"
|
||||
echo "Pushed to origin/${branch_name}"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
# --- Word Deletion & Readline Keybindings ---
|
||||
if [[ -n "$BASH_VERSION" ]] && [[ "$-" == *i* ]]; then
|
||||
# Ctrl+W: Delete entire word under cursor (backward-word + kill-word)
|
||||
|
||||
+4
-2
@@ -1,13 +1,15 @@
|
||||
# shellcheck shell=bash
|
||||
# 🗺️ Fuzzy Navigation & Directory Jump Helpers
|
||||
# Sourced in .bashrc to provide quick, interactive folder traversal using Yazi and fzf.
|
||||
|
||||
# 1. fm: Interactive file manager wrapper using Yazi.
|
||||
# Synchronizes the active terminal shell working directory to Yazi's exit folder (sticky directory).
|
||||
fm() {
|
||||
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")"
|
||||
local tmp
|
||||
tmp="$(mktemp -t "yazi-cwd.XXXXXX")"
|
||||
yazi "$@" --cwd-file="$tmp"
|
||||
if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
|
||||
cd -- "$cwd"
|
||||
cd -- "$cwd" || return
|
||||
fi
|
||||
rm -f -- "$tmp"
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
# 📄 Command Line PDF Utilities
|
||||
# Sourced in .bashrc to provide quick file operations on PDF documents.
|
||||
|
||||
@@ -30,7 +31,7 @@ pdf_dc() {
|
||||
# Handle file overwrite prompts
|
||||
if [[ -f "$output_file" ]]; then
|
||||
echo "Error: Output file '$output_file' already exists."
|
||||
read -p "Do you want to overwrite it? (y/n): " overwrite
|
||||
read -r -p "Do you want to overwrite it? (y/n): " overwrite
|
||||
if [[ "$overwrite" != "y" ]]; then
|
||||
echo "Operation cancelled."
|
||||
return 1
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
# 🚀 Quicklinks Launcher Utility
|
||||
# Sourced in .bashrc to provide an interactive bookmarks and command-launcher interface.
|
||||
# Parses a pipe-separated config file (`~/.quicklinks`) containing custom CLI commands or URLs.
|
||||
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
# 📝 Todo.txt & Tuxedo Productivity Helper and Syntax Highlighter
|
||||
# Sourced in .bashrc to provide colorized listings and quick task management shortcuts.
|
||||
|
||||
@@ -58,7 +59,7 @@ todo() {
|
||||
local task_id
|
||||
task_id=$(echo "$top_task" | awk '{print $1}')
|
||||
echo "Completing: $top_task"
|
||||
tuxedo do "$task_id"
|
||||
tuxedo "do" "$task_id"
|
||||
else
|
||||
echo "No tasks found in todo.txt"
|
||||
fi
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
# 📋 Custom Wayland Desktop Utilities
|
||||
# Sourced in .bashrc to provide command-line utilities optimized for Wayland compositor environments.
|
||||
|
||||
|
||||
Reference in new issue
Block a user