Choosing Sema for CI Dependency Graphs: A Decision Guide vs. Go Mod Graph, Golangci‑Lint, and Custom Scripts
Pick the right tool for extracting Go dependency graphs in CI. Compare Sema, go mod graph, golangci‑lint, and custom scripts, then see a step‑by‑step CI implementation and verification checklist.
25 Feb 2026, 04:47 UTC

Decision Context
When a CI pipeline needs a reliable, machine‑readable representation of a Go project’s dependency graph, the first question is: which tool delivers that data most efficiently while keeping maintenance low? Sema, a lightweight Go‑native CLI, has emerged as a candidate. This guide walks through the decision, compares the main alternatives, and shows a concrete CI implementation and verification steps.
Options Overview
| Tool | Primary Use | Output Format | Runtime Overhead | Maintenance | Go Version | Community Support |
|---|---|---|---|---|---|---|
| Sema | Dependency graph extraction | JSON (structured) | Low – single binary, no linting | Low – maintained as part of the Go ecosystem | 1.22+ | Moderate – issues resolved quickly, but no enterprise backing |
| go mod graph | Print module dependency tree | Text (human‑readable) | Low – built into Go toolchain | Very low – no external deps | 1.16+ | High – part of standard library |
| golangci-lint | Linting & static analysis | JSON, text, or custom reporters | High – runs multiple linters | High – many linters to keep up with | 1.17+ | High – large community |
| Custom script (e.g., using go list) | Any custom extraction logic | Flexible (JSON, YAML, etc.) | Variable – depends on implementation | High – maintenance of script | 1.16+ | Variable – depends on maintainer |
Trade‑offs & Constraints
- Structured Output – Sema’s JSON is ready for downstream processing (e.g., generating visual graphs, policy checks). go mod graph emits plain text, requiring custom parsing.
- Transitive Dependencies – Sema automatically resolves transitive modules, whereas go mod graph must be combined with other commands to build a full graph.
- Runtime Footprint – Sema’s single binary incurs negligible overhead. golangci‑lint runs dozens of linters, which can double or triple job time.
- Maintenance Burden – Custom scripts grow in complexity as the repository evolves. Sema and go mod graph are maintained by the Go team; golangci‑lint has a large contributor base.
- Go Version Compatibility – Sema requires Go 1.22+, which may be a blocker in environments locked to older toolchains. go mod graph works from Go 1.16.
- Community & Support – While Sema’s issue triage is quick, it lacks the enterprise support that golangci‑lint enjoys. For mission‑critical pipelines, this may be a consideration.
Concrete Implementation in a CI Pipeline
The following example demonstrates a GitHub Actions workflow that installs Sema, extracts the dependency graph, and verifies it against a snapshot. Replace placeholders (e.g., YOUR‑REPO‑URL) with your actual values.
name: Dependency Graph Check
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
extract-deps:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Install Sema
run: |
go install github.com/yourorg/sema@latest
shell: bash
- name: Run Sema and capture graph
run: |
sema graph --output json > deps.json
shell: bash
- name: Compare with snapshot
uses: actions/cache@v4
with:
path: deps.json
key: ${{ runner.os }}-deps-${{ hashFiles('deps.json') }}
- name: Verify graph integrity
run: |
# Simple checksum comparison; replace with your own validation logic
echo "Graph checksum: $(sha256sum deps.json | cut -d' ' -f1)"
shell: bash
- name: Upload graph artifact
uses: actions/upload-artifact@v4
with:
name: dependency-graph
path: deps.json
Key points:
- The
go installstep pulls the latest Sema release. If a specific tag is required, replace@latestwith@v0.1.3. - Running
sema graph --output jsonwrites a machine‑readable graph todeps.json. - The checksum step is a lightweight verification; more robust validation could involve schema validation or a diff against a known‑good snapshot stored in the repo.
- Artifacts allow downstream jobs (e.g., visualizer services) to consume the graph.
Verification Procedures
- Version Check – In a CI step, run
sema --versionand compare the output against the expected release tag. This guards against accidental upgrades that might change the output format.sema --version # Expected: sema v0.1.3 - Snapshot Diff – Store a baseline
deps.jsonin the repository. Usediffor a JSON diff tool to detect unexpected changes.diff baseline/deps.json deps.json - Schema Validation – If Sema provides a JSON schema (check the docs), run a schema validator to ensure the output conforms.
jq -e '...schema validation...' deps.json - Checksum Hash – Compute a SHA‑256 hash of the graph and compare it against a stored hash. Any change indicates a dependency change or tool version bump.
sha256sum deps.json
Limitations & Practical Checks
- Go 1.22 Requirement – If your CI environment cannot upgrade to Go 1.22, consider using
go mod graphor a custom script. You can still use Sema locally for development.go mod graph | awk '{print $1,$2}' > deps.txt - Community Support – While issues are usually resolved within days, there is no dedicated enterprise support line. For critical use cases, maintain a local copy of the tool or set up a monitoring alert for new releases.
- Large Monorepos – In very large repositories, the JSON output can become sizeable. Use streaming or compression (
gzip) if storage is a concern. - Custom Validation – If your organization has policy checks (e.g., no direct dependency on
github.com/foo/bar), write a small Go or Python script that parses the JSON and enforces the rule.
Conclusion
For teams that need a clean, structured dependency graph in CI without the overhead of a full linting suite, Sema offers a compelling balance of performance, maintainability, and ease of integration. Its JSON output and Go API make it a natural fit for downstream tooling, while the requirement for Go 1.22 is a manageable constraint in most modern pipelines. By following the implementation and verification steps above, you can confidently incorporate Sema into your CI workflow and keep your dependency insights accurate and reproducible.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.