Skip to content

chore: add coverage directory to gitignore #11

chore: add coverage directory to gitignore

chore: add coverage directory to gitignore #11

Workflow file for this run

name: Architecture Guardrails
on:
push:
pull_request:
jobs:
architecture-check:
name: Architectural Boundary Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check UI layer imports in core modules
id: ui-check
run: |
echo "Checking for UI layer imports in core modules..."
# Define core modules that should NOT import UI layers
# Note: The following modules are ALLOWED to use UI libraries:
# - cmd.rs (CLI interface)
# - main.rs (entry point)
# - process_args.rs (argument extraction - uses clap::ArgMatches)
# - process.rs (coordination layer - uses clap::ArgMatches)
# - file_ops.rs (uses indicatif for progress bars)
# Pure business logic modules that should NOT use UI:
CORE_MODULES=(
"src/process_error.rs"
"src/process_compiler.rs"
"src/process_content.rs"
"src/process_directory.rs"
"src/config.rs"
)
# UI layer patterns to detect
# These are terminal/console UI libraries
UI_PATTERNS=(
"use clap::"
"use colored::"
"use indicatif::"
"use dialoguer::"
"use console::"
"use termcolor::"
)
VIOLATIONS=0
for module in "${CORE_MODULES[@]}"; do
if [ -f "$module" ]; then
for pattern in "${UI_PATTERNS[@]}"; do
if grep -n "$pattern" "$module" 2>/dev/null; then
echo "::error file=$module::UI layer import found: '$pattern' in core module $module"
VIOLATIONS=$((VIOLATIONS + 1))
fi
done
fi
done
if [ $VIOLATIONS -gt 0 ]; then
echo "::error::Found $VIOLATIONS UI layer import violation(s) in core modules"
echo "violations=$VIOLATIONS" >> $GITHUB_OUTPUT
exit 1
fi
echo "No UI layer violations found in core modules"
echo "violations=0" >> $GITHUB_OUTPUT
- name: Check Network layer imports in core modules
id: network-check
run: |
echo "Checking for Network layer imports in core modules..."
# Define core modules that should NOT import Network layers
CORE_MODULES=(
"src/process_error.rs"
"src/process_args.rs"
"src/process_compiler.rs"
"src/process_content.rs"
"src/process_directory.rs"
"src/process.rs"
"src/config.rs"
"src/lib.rs"
)
# Network layer patterns to detect
NETWORK_PATTERNS=(
"use tokio::net::"
"use warp::"
"use hyper::"
"use reqwest::"
"use axum::"
"use actix_web::"
"use rocket::"
"use tide::"
"use std::net::"
)
VIOLATIONS=0
for module in "${CORE_MODULES[@]}"; do
if [ -f "$module" ]; then
for pattern in "${NETWORK_PATTERNS[@]}"; do
if grep -n "$pattern" "$module" 2>/dev/null; then
echo "::error file=$module::Network layer import found: '$pattern' in core module $module"
VIOLATIONS=$((VIOLATIONS + 1))
fi
done
fi
done
if [ $VIOLATIONS -gt 0 ]; then
echo "::error::Found $VIOLATIONS Network layer import violation(s) in core modules"
echo "violations=$VIOLATIONS" >> $GITHUB_OUTPUT
exit 1
fi
echo "No Network layer violations found in core modules"
echo "violations=0" >> $GITHUB_OUTPUT
- name: Check Filesystem layer imports in pure core modules
id: fs-check
run: |
echo "Checking for Filesystem layer imports in pure core modules..."
# Pure core modules that should NOT have direct filesystem access
# Note: config.rs and process_content.rs legitimately need fs access
# This check is for modules that should be purely computational
PURE_CORE_MODULES=(
"src/process_error.rs"
"src/process_args.rs"
"src/process_compiler.rs"
)
# Filesystem layer patterns to detect
# std::io::Error is allowed (it's just an error type)
# But std::io::{Read, Write, BufRead, etc.} are not
FS_PATTERNS=(
"use std::fs::"
"use std::fs;"
"use tokio::fs::"
"use tokio::fs;"
"std::io::Read"
"std::io::Write"
"std::io::BufRead"
"std::io::BufWriter"
"std::io::BufReader"
)
VIOLATIONS=0
for module in "${PURE_CORE_MODULES[@]}"; do
if [ -f "$module" ]; then
for pattern in "${FS_PATTERNS[@]}"; do
if grep -n "$pattern" "$module" 2>/dev/null; then
echo "::error file=$module::Filesystem layer import found: '$pattern' in pure core module $module"
VIOLATIONS=$((VIOLATIONS + 1))
fi
done
fi
done
if [ $VIOLATIONS -gt 0 ]; then
echo "::error::Found $VIOLATIONS Filesystem layer import violation(s) in pure core modules"
echo "violations=$VIOLATIONS" >> $GITHUB_OUTPUT
exit 1
fi
echo "No Filesystem layer violations found in pure core modules"
echo "violations=0" >> $GITHUB_OUTPUT
- name: Check for cross-layer dependencies (file_ops importing UI)
id: cross-layer-check
run: |
echo "Checking for cross-layer dependencies..."
# file_ops.rs (infrastructure/filesystem layer) should not import UI
if [ -f "src/file_ops.rs" ]; then
UI_PATTERNS=(
"use clap::"
"use colored::"
"use dialoguer::"
"use console::"
)
VIOLATIONS=0
for pattern in "${UI_PATTERNS[@]}"; do
if grep -n "$pattern" "src/file_ops.rs" 2>/dev/null; then
echo "::error file=src/file_ops.rs::Cross-layer violation: UI import '$pattern' in filesystem layer"
VIOLATIONS=$((VIOLATIONS + 1))
fi
done
if [ $VIOLATIONS -gt 0 ]; then
echo "::error::Found $VIOLATIONS cross-layer violation(s)"
echo "violations=$VIOLATIONS" >> $GITHUB_OUTPUT
exit 1
fi
fi
echo "No cross-layer violations found"
echo "violations=0" >> $GITHUB_OUTPUT
- name: Architecture Summary
if: always()
run: |
echo "=========================================="
echo " Architectural Boundary Check Summary"
echo "=========================================="
echo ""
echo "Layer Structure:"
echo " UI Layer: cmd.rs, main.rs"
echo " Network Layer: (via file_ops.rs async features)"
echo " Filesystem: file_ops.rs"
echo " Core/Business: process_*.rs, config.rs, lib.rs"
echo ""
echo "Enforced Rules:"
echo " 1. Core modules must NOT import UI layers directly"
echo " 2. Core modules must NOT import Network layers directly"
echo " 3. Pure core modules must NOT import Filesystem layers"
echo " 4. Infrastructure layers should not depend on UI layers"
echo ""
echo "Check Results:"
echo " UI Check: ${{ steps.ui-check.outcome }}"
echo " Network Check: ${{ steps.network-check.outcome }}"
echo " Filesystem Check: ${{ steps.fs-check.outcome }}"
echo " Cross-layer Check: ${{ steps.cross-layer-check.outcome }}"
echo "=========================================="