Skip to content
Arxo Arxo

CI/CD Integration

Arxo is designed for CI/CD integration with fast analysis, policy enforcement, and multiple output formats.

Create .github/workflows/architecture.yml:

name: Architecture Analysis
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for git-based metrics
- name: Install Arxo
run: |
# Download pre-built binary from GitHub Releases (see https://github.com/arxohq/arxo/releases)
curl -sL "https://github.com/arxohq/arxo/releases/latest/download/arxo-linux-x86_64.tar.gz" | tar xz
chmod +x arxo && sudo mv arxo /usr/local/bin/
- name: Run Architecture Analysis
run: |
arxo analyze --preset ci --fail-fast

Speed up runs with caching:

- name: Cache Arxo Analysis
uses: actions/cache@v3
with:
path: |
~/.cache/arxo
key: arxo-${{ hashFiles('**/*.ts', '**/*.tsx', '**/*.py') }}
restore-keys: |
arxo-
- name: Run Analysis
run: arxo analyze --preset ci

Upload analysis reports as artifacts:

- name: Generate Report
run: |
arxo analyze --format json --output architecture-report.json
arxo analyze --format html --output architecture-report.html
- name: Upload Report
uses: actions/upload-artifact@v3
if: always()
with:
name: architecture-reports
path: |
architecture-report.json
architecture-report.html

Post results as PR comments:

- name: Analyze Architecture
id: analyze
run: |
arxo analyze --format json --output report.json
echo "status=$?" >> $GITHUB_OUTPUT
- name: Comment PR
uses: actions/github-script@v7
if: github.event_name == 'pull_request'
with:
script: |
const fs = require('fs');
const report = JSON.parse(fs.readFileSync('report.json', 'utf8'));
const violations = report.violations || [];
const body = violations.length > 0
? `## ⚠️ Architecture Violations\n\n${violations.map(v => `- ${v.message}`).join('\n')}`
: '## ✅ No Architecture Violations';
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});

Analyze only changed files in PRs:

- name: Analyze Changed Files
run: |
arxo analyze --only-changed origin/${{ github.base_ref }}

Compare against main branch:

- name: Compare with Baseline
run: |
arxo analyze --baseline origin/main --format json --output diff.json

Create .gitlab-ci.yml:

architecture:
stage: test
image: ubuntu:22.04
cache:
paths:
- .cache/arxo
before_script:
- apt-get update && apt-get install -y curl
- curl -sL "https://github.com/arxohq/arxo/releases/latest/download/arxo-linux-x86_64.tar.gz" | tar xz
- chmod +x arxo && mv arxo /usr/local/bin/
script:
- arxo analyze --preset ci --fail-fast
artifacts:
when: always
paths:
- architecture-report.json
reports:
junit: architecture-report.xml

Create Jenkinsfile:

pipeline {
agent any
stages {
stage('Architecture Analysis') {
steps {
sh 'curl -sL "https://github.com/arxohq/arxo/releases/latest/download/arxo-linux-x86_64.tar.gz" | tar xz && chmod +x arxo && sudo mv arxo /usr/local/bin/'
sh 'arxo analyze --preset ci --format json --output report.json'
}
}
stage('Archive Reports') {
steps {
archiveArtifacts artifacts: 'report.json', allowEmptyArchive: false
publishHTML([
reportDir: '.',
reportFiles: 'report.html',
reportName: 'Architecture Report'
])
}
}
}
post {
failure {
echo 'Architecture violations detected!'
}
}
}

Create .circleci/config.yml:

version: 2.1
jobs:
analyze:
docker:
- image: ubuntu:22.04
steps:
- checkout
- restore_cache:
keys:
- arxo-{{ checksum ".cache/arxo" }}
- run:
name: Install Arxo
command: |
apt-get update && apt-get install -y curl
curl -sL "https://github.com/arxohq/arxo/releases/latest/download/arxo-linux-x86_64.tar.gz" | tar xz
chmod +x arxo && sudo mv arxo /usr/local/bin/
- run:
name: Analyze Architecture
command: arxo analyze --preset ci --fail-fast
- save_cache:
key: arxo-{{ checksum ".cache/arxo" }}
paths:
- ~/.cache/arxo
- store_artifacts:
path: architecture-report.json
workflows:
version: 2
build:
jobs:
- analyze

Run quick analysis before commits:

Create .git/hooks/pre-commit:

#!/bin/bash
echo "Running architecture analysis..."
# Quick analysis (few seconds)
if ! arxo analyze --quick --quiet; then
echo "❌ Architecture violations detected!"
echo "Run: arxo analyze --quick"
exit 1
fi
echo "✅ Architecture check passed"

Make executable:

Terminal window
chmod +x .git/hooks/pre-commit

Create .pre-commit-config.yaml:

repos:
- repo: local
hooks:
- id: arxo
name: Architecture Analysis
entry: arxo analyze --quick
language: system
pass_filenames: false
always_run: true

Install:

Terminal window
pip install pre-commit
pre-commit install

FROM ubuntu:22.04
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
# Install Arxo (pre-built binary)
RUN curl -sL "https://github.com/arxohq/arxo/releases/latest/download/arxo-linux-x86_64.tar.gz" | tar xz \
&& chmod +x arxo && mv arxo /usr/local/bin/
COPY . /app
WORKDIR /app
RUN arxo analyze --preset ci --format json --output /report.json
services:
arxo:
image: ubuntu:22.04
volumes:
- .:/workspace
working_dir: /workspace
command: |
sh -c "
apt-get update && apt-get install -y curl &&
curl -sL https://github.com/arxohq/arxo/releases/latest/download/arxo-linux-x86_64.tar.gz | tar xz &&
chmod +x arxo && ./arxo analyze --preset ci
"

Use presets for consistent CI runs:

Terminal window
# Fast CI checks (30 seconds)
arxo analyze --preset ci --fail-fast
# Full analysis (2-5 minutes)
arxo analyze --preset full

Create .arxo.ci.yaml:

data:
import_graph:
group_by: folder
group_depth: 2
exclude:
- "**/test/**"
- "**/node_modules/**"
metrics:
- id: scc
- id: propagation_cost
- id: smells
policy:
invariants:
- metric: scc.max_cycle_size
op: "=="
value: 0
message: "No circular dependencies"
- metric: propagation_cost.system.ratio
op: "<="
value: 0.15
message: "System coupling too high"
run_options:
fail_fast: true
quiet: true

Use in CI:

Terminal window
arxo analyze --config .arxo.ci.yaml

For PRs, use quick mode:

Terminal window
arxo analyze --quick # Skips expensive metrics
Terminal window
arxo analyze --only-changed HEAD~1
# GitHub Actions
- uses: actions/cache@v3
with:
path: ~/.cache/arxo
key: arxo-${{ hashFiles('**/*.ts') }}

Metrics run in parallel by default. Ensure adequate CPU:

# GitHub Actions
runs-on: ubuntu-latest-4-cores
import_graph:
exclude:
- "**/node_modules/**"
- "**/dist/**"
- "**/test/**"
- "**/*.test.ts"

Arxo uses standard exit codes for CI integration:

Exit CodeMeaning
0Success - No violations
1Policy violations detected
2Configuration error
3Analysis error
4Invalid arguments
Terminal window
# Fail on violations
arxo analyze --preset ci || exit 1
# Continue on violations (report only)
arxo analyze --preset ci || true
# Fail fast (stop at first violation)
arxo analyze --preset ci --fail-fast

#!/bin/bash
STATUS=$(arxo analyze --preset ci --format json --output report.json && echo "success" || echo "failure")
if [ "$STATUS" = "failure" ]; then
VIOLATIONS=$(jq '.violations | length' report.json)
curl -X POST -H 'Content-type: application/json' \
--data "{\"text\":\"❌ Architecture violations: $VIOLATIONS\"}" \
$SLACK_WEBHOOK_URL
fi
Terminal window
if ! arxo analyze --preset ci; then
curl -H 'Content-Type: application/json' \
-d '{
"@type": "MessageCard",
"title": "Architecture Violations",
"text": "CI build failed due to architecture violations"
}' \
$TEAMS_WEBHOOK_URL
fi

  1. Start with Loose Policies - Tighten gradually
  2. Use Presets - Consistent across team
  3. Cache Analysis Results - Faster CI runs
  4. Analyze Changed Files in PRs - Quick feedback
  5. Generate HTML Reports - Visual debugging
  6. Set Clear Exit Codes - Predictable CI behavior
  7. Track Metrics Over Time - Spot trends
  8. Document Policies - Why rules exist

  • Use --quick mode
  • Analyze --only-changed files
  • Exclude test/build directories
  • Cache analysis results
  • Adjust policy thresholds
  • Exclude specific patterns
  • Use custom metrics
  • Review grouping strategy
  • Reduce max_nodes in config
  • Exclude large dependencies
  • Use file-level grouping
  • Increase CI machine size

For AI-assisted development workflows, use the MCP server to integrate architecture analysis directly into your IDE:

Quick health check before commit:

Ask your AI assistant:
"Check for circular dependencies in my project"

The AI uses check_cycles via MCP to run instant analysis.

Policy gate in development:

"Verify this change meets our architecture policies"

The AI uses evaluate_policy and analyze_file_impact to validate changes before pushing.

See MCP Workflows for complete IDE-driven development patterns.