Skip to content
This repository was archived by the owner on Sep 12, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
# Priority values are: `low, normal, high, higher`
#
{Credo.Check.Design.AliasUsage,
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
[priority: :low, if_nested_deeper_than: 1, if_called_more_often_than: 0]},
{Credo.Check.Design.TagFIXME, []},
# You can also customize the exit_status of each check.
# If you don't want TODO comments to cause `mix credo` to fail, just
Expand Down
27 changes: 26 additions & 1 deletion .githooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,31 @@ if ! mix format --check-formatted; then
fi
fi

# Check for markdown files and lint them if markdownlint-cli2 is available
if command -v markdownlint-cli2 >/dev/null 2>&1; then
# Check if any .md files are in the repository
if find . -name "*.md" -not -path "./deps/*" -not -path "./_build/*" | head -1 | grep -q .; then
echo "📋 Checking markdown formatting..."
# Get list of project markdown files (excluding deps and _build)
md_files=$(find . -name "*.md" -not -path "./deps/*" -not -path "./_build/*")
if ! echo "$md_files" | xargs markdownlint-cli2 --config .markdownlint.json 2>/dev/null; then
echo "❌ Markdown linting failed!"
echo "💡 Fix markdown issues manually or run:"
echo " find . -name \"*.md\" -not -path \"./deps/*\" -not -path \"./_build/*\" | xargs markdownlint-cli2 --config .markdownlint.json --fix"
echo "💡 Install markdownlint-cli2 with: npm install -g markdownlint-cli2"
exit 1
fi
echo "✅ Markdown formatting looks good"
fi
else
# Check if any .md files exist to give helpful message
if find . -name "*.md" -not -path "./deps/*" -not -path "./_build/*" | head -1 | grep -q .; then
echo "ℹ️ markdownlint-cli2 not found - skipping markdown linting"
echo "💡 Install with: npm install -g markdownlint-cli2"
echo "💡 Or run manually: find . -name \"*.md\" -not -path \"./deps/*\" -not -path \"./_build/*\" | xargs markdownlint-cli2"
fi
fi

# Run regression tests (critical - these should never break)
echo "🧪 Running regression tests..."
if ! mix test.regression; then
Expand All @@ -48,4 +73,4 @@ fi
# exit 1
# fi

echo "✅ All validation checks passed! Ready to push."
echo "✅ All validation checks passed! Ready to push."
59 changes: 59 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# GitHub Workflows

This directory contains the CI/CD workflows for the SC project.

## Workflow Strategy

### **Conditional Execution Based on File Changes**

The workflows are designed to run conditionally based on what files have been changed:

#### **Code Changes** → `ci.yml`

- **Triggers**: Changes to `.ex`, `.exs`, `mix.exs`, `mix.lock`, `config/`, etc.
- **Skips**: Documentation files (`.md`), license files, `.gitignore`
- **Jobs**: Full CI pipeline (compile, format, test, credo, dialyzer, regression tests)
- **Purpose**: Validates code quality, functionality, and compatibility

#### **Documentation Changes** → `docs.yml`

- **Triggers**: Changes to `.md` files, `docs/` directory
- **Jobs**: Markdown linting, link checking, documentation validation
- **Purpose**: Ensures documentation quality and consistency

### **Benefits**

- ✅ **Faster feedback** - Documentation changes don't run expensive code tests
- ✅ **Resource efficient** - Saves CI minutes on documentation-only changes
- ✅ **Focused validation** - Each workflow validates what actually changed
- ✅ **Clear separation** - Code and documentation validation are distinct concerns

### **Example Scenarios**

| Change | ci.yml | docs.yml | Result |
|--------|--------|----------|---------|
| `lib/sc/validator.ex` | ✅ Runs | ❌ Skipped | Full code validation |
| `README.md` | ❌ Skipped | ✅ Runs | Documentation validation only |
| `lib/sc/state.ex` + `CLAUDE.md` | ✅ Runs | ✅ Runs | Both workflows run |

## Workflows

### **`ci.yml`** - Main CI Pipeline

- **Compilation** - Compile with warnings as errors
- **Code Formatting** - Verify `mix format` compliance
- **Testing** - Multi-version testing with coverage (Elixir 1.17+ / OTP 26+)
- **Static Analysis** - Credo strict mode validation
- **Type Checking** - Dialyzer static analysis
- **Regression Testing** - Critical functionality validation

### **`docs.yml`** - Documentation Pipeline

- **Markdown Linting** - Style and structure validation
- **Link Checking** - Verify external links are valid
- **Memory Validation** - Ensure CLAUDE.md and README.md have required sections
- **API Consistency** - Check that documentation references current API

## Configuration Files

- **`markdown-link-check-config.json`** - Link checker configuration with retry policies
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,22 @@ name: CI
on:
push:
branches: [ main ]
paths-ignore:
- '**/*.md'
- 'CLAUDE.md'
- 'README.md'
- 'LICENSE*'
- 'docs/**'
- '.gitignore'
pull_request:
branches: [ main ]
paths-ignore:
- '**/*.md'
- 'CLAUDE.md'
- 'README.md'
- 'LICENSE*'
- 'docs/**'
- '.gitignore'

env:
MIX_ENV: test
Expand Down
87 changes: 87 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Documentation

on:
push:
branches: [ main ]
paths:
- '**/*.md'
- 'CLAUDE.md'
- 'README.md'
- 'docs/**'
pull_request:
branches: [ main ]
paths:
- '**/*.md'
- 'CLAUDE.md'
- 'README.md'
- 'docs/**'

jobs:
lint-docs:
name: Lint Documentation
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Lint Markdown files
uses: DavidAnson/markdownlint-cli2-action@v13
with:
globs: |
**/*.md
!node_modules/**/*.md

- name: Check for broken links
uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
config-file: '.github/workflows/markdown-link-check-config.json'

validate-memory:
name: Validate Memory Files
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check CLAUDE.md structure
run: |
echo "Validating CLAUDE.md structure..."
if ! grep -q "## Commands" CLAUDE.md; then
echo "❌ CLAUDE.md missing Commands section"
exit 1
fi
if ! grep -q "## Architecture" CLAUDE.md; then
echo "❌ CLAUDE.md missing Architecture section"
exit 1
fi
echo "✅ CLAUDE.md structure looks good"

- name: Check README.md structure
run: |
echo "Validating README.md structure..."
if ! grep -q "## Features" README.md; then
echo "❌ README.md missing Features section"
exit 1
fi
if ! grep -q "## Current Status" README.md; then
echo "❌ README.md missing Current Status section"
exit 1
fi
echo "✅ README.md structure looks good"

- name: Validate documentation consistency
run: |
echo "Checking for API consistency between CLAUDE.md and README.md..."

# Check that both files reference SC.Validator (not SC.Document.Validator)
if grep -q "SC\.Document\.Validator" CLAUDE.md README.md; then
echo "❌ Found outdated SC.Document.Validator references - should be SC.Validator"
grep -n "SC\.Document\.Validator" CLAUDE.md README.md || true
exit 1
fi

echo "✅ API references look consistent"
22 changes: 22 additions & 0 deletions .github/workflows/markdown-link-check-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"ignorePatterns": [
{
"pattern": "^http://localhost"
},
{
"pattern": "^https://codecov.io"
}
],
"timeout": "20s",
"retryOn429": true,
"retryCount": 3,
"fallbackHttpStatus": [
400,
401,
403,
404,
500,
502,
503
]
}
33 changes: 33 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"default": true,
"line-length": false,
"no-duplicate-heading": false,
"no-inline-html": {
"allowed_elements": ["br", "kbd", "sub", "sup"]
},
"whitespace": true,
"no-hard-tabs": true,
"no-trailing-spaces": true,
"no-multiple-blanks": {
"maximum": 2
},
"blanks-around-headings": {
"lines_above": 1,
"lines_below": 1
},
"heading-increment": true,
"no-missing-space-atx": true,
"no-missing-space-closed-atx": true,
"ul-style": {
"style": "dash"
},
"ol-prefix": {
"style": "one_or_ordered"
},
"list-indent": true,
"blanks-around-fences": true,
"fenced-code-language": false,
"first-line-h1": false,
"heading-start-left": true,
"single-trailing-newline": true
}
Loading