Local On-Device CI/CD Pipeline
When to Use
Use this skill when building, maintaining, or troubleshooting a local on-device CI/CD pipeline. This includes:
- Setting up preflight checks, static analysis, test automation, smoke tests, build, and deploy stages
- Configuring git hooks (pre-commit, pre-push) for automated pipeline execution
- Troubleshooting pipeline failures (stale reports, historical diff ranges, Gradle error parsing)
- Adding file watchers or scheduler triggers for continuous automation
Overview
A fully custom, self-contained CI/CD pipeline that runs entirely on the local machine with no cloud runners. It provides preflight checks, static analysis, parallel tests, smoke tests, build automation, and deployment — all orchestrated through a single Python script with git hooks, file watchers, and scheduler triggers.
Pipeline Stages (in order)
- preflight — Python version, venv, dependencies (pip check), git state, disk space, optional tools (QEMU, JDK)
- static — compileall, ruff (E9,F63,F7,F82,B006,B008), bare except detection, secret pattern scanning, big file detection
- tests — pytest with xdist parallel, flaky rerun, JUnit XML output, timeout
- smoke — real hub in throwaway VMH_HOME, health/catalog/MCP over HTTP+stdio, clean shutdown
- android — gradlew testDebugUnitTest assembleDebug (when android/ changed + JDK present)
- build — PyInstaller executable
- deploy — restart running hub from this checkout
Always-On Rules
- Comprehensive scope: The user expects exhaustive implementation, never minimal. All stages, all checks, all features.
- Working artifacts: Every pipeline run must produce real reports (JSON + history.jsonl + logs). No placeholders.
- Change-aware: Use git diff to skip unneeded stages. Only run what changed.
- Lock mechanism: One pipeline at a time via a lock file naming the running PID.
- Timeout everything: Every command has a timeout; on timeout kill the whole process tree.
- Flaky rerun: Failed tests are re-run once on their own to distinguish flakes from real failures.
Critical Pitfalls
Big-file/secret checks: scan working tree, NOT historical range
When checking for big files or secrets, examine only the working tree (uncommitted + untracked + staged files) against HEAD. Do NOT scan the full historical diff range — old commits may have tracked build artifacts (e.g., target/) that were later removed, causing false failures.
Gradle error parsing: use FAILURE:/What went wrong: blocks
When a Gradle build fails, parse for FAILURE: and What went wrong: blocks in the output. Do NOT use tail(out) — it grabs version numbers (e.g., 25.0.2) instead of the real error message.
Staticmethod self reference
A @staticmethod that references class attributes must use the class name directly (e.g., ClassName._ATTR), not self._ATTR.
Exception variable lambda capture
Python 3 deletes the exception variable after the except block ends. If the exception is captured in a lambda (e.g., QTimer.singleShot(0, lambda: ...)), use a default argument: lambda exc=exc: ....
Bare except
Never use bare except: — it catches KeyboardInterrupt and SystemExit. Always use except Exception:.
Build artifacts in git
Add target/, dist/, build/ to .gitignore. If already tracked, remove with git rm -r --cached target/.
CLI Usage
python -m ci --full # Run all stages
python -m ci --fast # Preflight, static, tests only
python -m ci --only tests # Run specific stage(s)
python -m ci --list # Show what would run and why
python -m ci --no-deploy # Skip deploy stage
python -m ci --build # Also build executable
Git Hooks
- pre-push: Runs full pipeline before every push
- pre-commit: Runs static checks before every commit
Install with: python ci/install_hooks.py
Triggers
- File watcher: Watches src/, tests/, crates/, scripts/, gui/ for changes
- Scheduler: Runs pipeline on a schedule (e.g., every 60 minutes)
- Git hooks: Pre-commit and pre-push hooks
References
references/pipeline-stages.md — Detailed stage implementations and configuration
references/troubleshooting.md — Common failures and fixes
1---2name: local-cicd-pipeline3description: "Build local CI/CD pipelines with preflight, tests, deploy."4version: 1.0.05author: Hermes Agent6license: MIT7metadata:8 source: https://skillmd.com/skills/loopyluci/local-cicd-pipeline9 hermes:10 tags: [ci-cd, pipeline, automation, devops]11 related_skills: [github-pr-workflow, verified-release-artifacts]12---1314# Local On-Device CI/CD Pipeline1516## When to Use1718Use this skill when building, maintaining, or troubleshooting a local on-device CI/CD pipeline. This includes:19- Setting up preflight checks, static analysis, test automation, smoke tests, build, and deploy stages20- Configuring git hooks (pre-commit, pre-push) for automated pipeline execution21- Troubleshooting pipeline failures (stale reports, historical diff ranges, Gradle error parsing)22- Adding file watchers or scheduler triggers for continuous automation2324## Overview2526A fully custom, self-contained CI/CD pipeline that runs entirely on the local machine with no cloud runners. It provides preflight checks, static analysis, parallel tests, smoke tests, build automation, and deployment — all orchestrated through a single Python script with git hooks, file watchers, and scheduler triggers.2728## Pipeline Stages (in order)29301. **preflight** — Python version, venv, dependencies (pip check), git state, disk space, optional tools (QEMU, JDK)312. **static** — compileall, ruff (E9,F63,F7,F82,B006,B008), bare except detection, secret pattern scanning, big file detection323. **tests** — pytest with xdist parallel, flaky rerun, JUnit XML output, timeout334. **smoke** — real hub in throwaway VMH_HOME, health/catalog/MCP over HTTP+stdio, clean shutdown345. **android** — gradlew testDebugUnitTest assembleDebug (when android/ changed + JDK present)356. **build** — PyInstaller executable367. **deploy** — restart running hub from this checkout3738## Always-On Rules3940- **Comprehensive scope**: The user expects exhaustive implementation, never minimal. All stages, all checks, all features.41- **Working artifacts**: Every pipeline run must produce real reports (JSON + history.jsonl + logs). No placeholders.42- **Change-aware**: Use git diff to skip unneeded stages. Only run what changed.43- **Lock mechanism**: One pipeline at a time via a lock file naming the running PID.44- **Timeout everything**: Every command has a timeout; on timeout kill the whole process tree.45- **Flaky rerun**: Failed tests are re-run once on their own to distinguish flakes from real failures.4647## Critical Pitfalls4849### Big-file/secret checks: scan working tree, NOT historical range50When checking for big files or secrets, examine only the working tree (uncommitted + untracked + staged files) against HEAD. Do NOT scan the full historical diff range — old commits may have tracked build artifacts (e.g., `target/`) that were later removed, causing false failures.5152### Gradle error parsing: use FAILURE:/What went wrong: blocks53When a Gradle build fails, parse for `FAILURE:` and `What went wrong:` blocks in the output. Do NOT use `tail(out)` — it grabs version numbers (e.g., `25.0.2`) instead of the real error message.5455### Staticmethod self reference56A `@staticmethod` that references class attributes must use the class name directly (e.g., `ClassName._ATTR`), not `self._ATTR`.5758### Exception variable lambda capture59Python 3 deletes the exception variable after the except block ends. If the exception is captured in a lambda (e.g., `QTimer.singleShot(0, lambda: ...)`), use a default argument: `lambda exc=exc: ...`.6061### Bare except62Never use bare `except:` — it catches KeyboardInterrupt and SystemExit. Always use `except Exception:`.6364### Build artifacts in git65Add `target/`, `dist/`, `build/` to `.gitignore`. If already tracked, remove with `git rm -r --cached target/`.6667## CLI Usage6869```bash70python -m ci --full # Run all stages71python -m ci --fast # Preflight, static, tests only72python -m ci --only tests # Run specific stage(s)73python -m ci --list # Show what would run and why74python -m ci --no-deploy # Skip deploy stage75python -m ci --build # Also build executable76```7778## Git Hooks7980- **pre-push**: Runs full pipeline before every push81- **pre-commit**: Runs static checks before every commit8283Install with: `python ci/install_hooks.py`8485## Triggers8687- **File watcher**: Watches src/, tests/, crates/, scripts/, gui/ for changes88- **Scheduler**: Runs pipeline on a schedule (e.g., every 60 minutes)89- **Git hooks**: Pre-commit and pre-push hooks9091## References9293- `references/pipeline-stages.md` — Detailed stage implementations and configuration94- `references/troubleshooting.md` — Common failures and fixes