Skip to main content

CI/CD Integration

ROS2 Inspector v0.1.0 can analyze source without starting ROS2, which makes audit and validate suitable for pull-request checks.

GitHub Actions

name: ROS2 architecture

on:
pull_request:
push:
branches: [main]

jobs:
inspect:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install ros2inspector

- name: Built-in architecture audit
run: ros2inspector audit . --fail-on warning --format json > audit.json

- name: Project policy
run: ros2inspector validate . --policy ros2inspector_policy.yaml --fail-on error

- name: Export architecture
if: always()
run: ros2inspector graph full --format json -o architecture.json

- uses: actions/upload-artifact@v4
if: always()
with:
name: ros2-architecture
path: |
audit.json
architecture.json

Machine-readable package health

scan --format json returns a list of package records. A simple threshold check can be written in Python:

ros2inspector scan . --format json | python3 -c '
import json, sys
packages = json.load(sys.stdin)
low = [p for p in packages if (p.get("health_score") or 0) < 70]
for package in low:
name = package.get("name", "<unknown>")
score = package.get("health_score", 0)
print(f"{name}: {score}/100")
raise SystemExit(1 if low else 0)
'

For a workspace-level threshold, use the health_threshold rule in a policy file instead of reconstructing the aggregate in shell.

Exit codes

  • 0: no result reached the configured failure threshold;
  • 1: audit findings or policy violations reached the threshold;
  • 2: invalid arguments or policy configuration;
  • 3: workspace packages or the policy file were not found.

Use audit --fail-on warning for a zero-configuration baseline, then add validate when the project has explicit dependency, naming, license, or health rules.