Skip to content
Lisa edited this page Jan 5, 2026 · 2 revisions

CKB Examples

Ready-to-use templates for CI/CD integration and local development hooks.

Which Workflow?

I want to... Use this
Post a simple PR comment impact-comment.yml
Full workflow with risk gates impact-analysis.yml
Org-wide reusable workflow ckb-reusable.yml
Scheduled index refresh ckb-refresh.yml
Use GitLab CI ckb.yml
Local pre-commit hook pre-commit

Quick Install

# GitHub Actions - Simple PR comment
curl -o .github/workflows/impact-comment.yml \
  https://raw.githubusercontent.com/SimplyLiz/CodeMCP/main/examples/github-actions/impact-comment.yml

# GitHub Actions - Full workflow
curl -o .github/workflows/impact-analysis.yml \
  https://raw.githubusercontent.com/SimplyLiz/CodeMCP/main/examples/github-actions/impact-analysis.yml

# GitLab CI
curl -o .gitlab/ci/ckb.yml \
  https://raw.githubusercontent.com/SimplyLiz/CodeMCP/main/examples/gitlab-ci/ckb.yml

# Pre-commit hook
curl -o .git/hooks/pre-commit \
  https://raw.githubusercontent.com/SimplyLiz/CodeMCP/main/examples/hooks/pre-commit
chmod +x .git/hooks/pre-commit

Directory Structure

examples/
├── github-actions/
│   ├── impact-comment.yml    # Simple PR comment widget
│   ├── impact-analysis.yml   # Full workflow with risk gates
│   ├── ckb-reusable.yml      # Reusable workflow for org-wide use
│   └── ckb-refresh.yml       # Scheduled architecture refresh
├── gitlab-ci/
│   └── ckb.yml               # GitLab CI template (include in your pipeline)
└── hooks/
    ├── pre-commit            # Git pre-commit hook (bash)
    ├── pre-commit-config.yaml # pre-commit framework config
    └── husky/
        ├── pre-commit        # Husky pre-commit hook
        └── ckb-check.js      # Complexity check for lint-staged

GitHub Actions

Simple PR Comment (impact-comment.yml)

Minimal setup - just post impact analysis as a PR comment:

- uses: actions/checkout@v4
  with:
    fetch-depth: 0

- run: |
    npm install -g @tastehub/ckb
    ckb index --if-stale=24h
    ckb impact --range="${{ github.event.pull_request.base.sha }}..${{ github.sha }}" \
      --format=markdown > impact.md

- uses: marocchino/sticky-pull-request-comment@v2
  with:
    header: ckb-impact
    path: impact.md

Full Workflow (impact-analysis.yml)

Complete integration with:

  • Risk gates (fail on critical)
  • Automatic reviewer assignment
  • PR comments with impact summary
  • Caching for faster runs

Reusable Workflow (ckb-reusable.yml)

For organizations - create once, use everywhere:

# In your app repo
jobs:
  ckb:
    uses: your-org/workflows/.github/workflows/ckb-reusable.yml@main
    with:
      risk-threshold: 'high'

GitLab CI

Include the template in your .gitlab-ci.yml:

include:
  - local: '.gitlab/ci/ckb.yml'

stages:
  - .pre
  - test
  - build

Features:

  • MR notes with impact analysis
  • Affected tests detection
  • Scheduled architecture refresh
  • Artifact storage

Local Hooks

Git Pre-commit Hook

cp examples/hooks/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

Blocks commits with critical risk, warns on high risk.

pre-commit Framework

pip install pre-commit
cp examples/hooks/pre-commit-config.yaml .pre-commit-config.yaml
pre-commit install

Husky (JS/TS)

npm install -D husky lint-staged
npx husky init
cp examples/hooks/husky/pre-commit .husky/pre-commit
cp examples/hooks/husky/ckb-check.js scripts/ckb-check.js
chmod +x .husky/pre-commit scripts/ckb-check.js

Add to package.json:

{
  "lint-staged": {
    "*.{ts,tsx}": ["node scripts/ckb-check.js"]
  }
}

Documentation

Clone this wiki locally