CI/CD Setup Guide
How to integrate CI/CD with your SDD project.
Quick Start
bash
# GitHub Actions setup
sdd cicd setup github
# Files created:
# .github/workflows/sdd-validate.yml
# .github/workflows/sdd-labeler.ymlGitHub Actions
Automatic Setup
bash
sdd cicd setup githubGenerated Workflows
1. sdd-validate.yml
Automatically validates specs on PR and push.
Triggers:
- Changes to
.sdd/directory - main, master, develop branches
Actions:
- Spec validation (
sdd validate) - Constitution validation
- Impact report generation
2. sdd-labeler.yml
Automatically adds labels to PRs.
Label types:
spec:domain-name- Changed domainconstitution- Constitution changesspec:new- New spec addedspec:update- Spec modifiedspec:remove- Spec deleted
Manual Setup
To create workflows manually:
yaml
# .github/workflows/sdd-validate.yml
name: SDD Validate
on:
pull_request:
paths:
- '.sdd/**'
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install SDD
run: npm install -g sdd-tool
- name: Validate Specs
run: sdd validate --ciCustomization
Strict Mode
bash
sdd cicd setup github --strictTreats warnings as errors.
Adding Notifications
yaml
# Slack notification on failure
- name: Notify Slack on Failure
if: failure()
uses: slackapi/slack-github-action@v1
with:
payload: |
{"text": "SDD validation failed: ${{ github.event.pull_request.html_url }}"}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}GitLab CI
Automatic Setup
bash
sdd cicd setup gitlabGenerated File
.gitlab-ci-sdd.yml file is created.
Include it in your existing .gitlab-ci.yml:
yaml
# .gitlab-ci.yml
include:
- local: '.gitlab-ci-sdd.yml'Status Check Setup
Connect to GitHub Branch Protection
- Settings → Branches → Edit main rule
- Enable "Require status checks to pass"
- Search for
Validate Specs - Add check
Now PR merging requires spec validation to pass.
Required Checks List
| Check Name | Description | Recommended |
|---|---|---|
Validate Specs | Spec validation | Required |
Add Labels | Label addition | Optional |
Git Hooks Integration
To run validation locally:
bash
# Install Git hooks
sdd git hooks installHook Types
| Hook | Timing | Validation |
|---|---|---|
pre-commit | Before commit | Validates only changed specs |
commit-msg | After commit message | Validates message format |
pre-push | Before push | Validates all specs |
CI Environment Check
Check if running in CI environment:
bash
# Run in CI environment (simplified output)
sdd validate --ci
# CI check
sdd cicd check
sdd cicd check --strictTroubleshooting
"Status check not found"
If status check is not visible:
- Workflow must run at least once
- Create PR with
.sdd/path changes - Check workflow file name
Validation Failure
bash
# Validate locally first
sdd validate
# Verbose output
sdd validate --verbosePermission Error
If label addition fails in GitHub Actions:
- Settings → Actions → General
- "Workflow permissions" section
- Select "Read and write permissions"