citarget
Checks that every make/gmake/just invocation in a repository's CI configuration names a target or recipe that actually exists.
$ citarget .
.github/workflows/ci.yml:6: error: unknown-target: make target "lints" not found in Makefile (make lints) (did you mean "lint"?)
Why
A CI workflow calls make lints. The Makefile defines lint. GNU make's
answer to an unknown target is No rule to make target 'lints', and CI goes
red — but only on the next push, sometimes hours after the typo landed,
because nothing checks the CI file against the Makefile at edit time.
Two tools look adjacent to this problem and don't cover it:
- actionlint validates GitHub Actions workflow syntax, expressions, and
shellcheck's opinions on
run: steps. It does not know what a Makefile is.
- checkmake lints a Makefile's own style (missing
.PHONY, missing
all/clean, long recipes). It never looks at a CI file.
Neither cross-checks the two. Measured on a workflow that runs make lints
against a Makefile that only defines lint:
$ go run github.com/rhysd/actionlint/cmd/actionlint@latest .github/workflows/ci.yml
(no output, exit 0)
$ go run github.com/checkmake/checkmake/cmd/checkmake@latest Makefile
RULE DESCRIPTION FILE NAME LINE NUMBER
minphony Required target Makefile 4
"all" is missing
from the Makefile.
minphony Required target Makefile 4
"clean" is missing
from the Makefile.
minphony Required target Makefile 4
"test" is missing
from the Makefile.
Error: violations found (3)
(exit 1 — a real finding, but about the Makefile's own shape, not the CI file)
A search of GitHub (gh search code/gh search repos, several phrasings —
"make target does not exist", "unknown make target", "ci makefile target
validator", "actionlint make target") turned up ad hoc, repo-local scripts
(shell one-offs, a handful of internal Go test helpers) but no standalone,
published tool that does this check generically across a repo's CI files.
Installation
go install github.com/quietpelican42/citarget/cmd/citarget@latest
Or build from source: go build ./cmd/citarget.
Usage
Check a repository
citarget /path/to/repo # defaults to "."
Wire it into CI
- name: citarget
run: citarget -format=github .
-format=github prints workflow command
annotations
(::error file=...,line=...::...), which GitHub renders inline on the run.
Get machine-readable output
citarget -format=json . | jq '.[] | select(.severity == "error")'
Reference
citarget [flags] [path]
| Flag |
Default |
Description |
-format |
text |
Output format: text, json, or github. |
Exit codes:
| Code |
Meaning |
0 |
No findings, or only informational ones. |
1 |
At least one error-severity finding (unknown-target or unknown-file). |
2 |
A CI configuration file itself (a workflow, a composite action, .gitlab-ci.yml, or a file it includes) could not be parsed at all. |
Finding kinds
| Kind |
Severity |
Meaning |
unknown-target |
error |
The invoked target/recipe isn't defined by the Makefile/justfile it resolved to. Includes an edit-distance "did you mean" suggestion when a close name exists. |
unknown-file |
error |
The -C/cd directory exists in the repository, but the -f/--justfile file named in the invocation (or the default Makefile/justfile) doesn't. |
unresolved-directory |
info |
The -C/cd directory does not exist anywhere in the repository. citarget cannot tell a typo apart from a directory the CI job only creates at run time (a downloaded-and-extracted tarball, a second actions/checkout of a different repository, a build script's own scratch directory), so this is reported but does not fail the build. |
dynamic-target |
info |
The target, directory, or file is computed at run time (a shell variable or a ${{ }} GitHub Actions expression) and was not checked. |
unparsed-snippet |
info |
One run:/script: block could not be parsed as POSIX shell — almost always PowerShell/cmd on a Windows runner that citarget's shell-family detection didn't catch. Every other snippet is still analysed. |
analysis-error |
error |
A CI configuration file itself could not be parsed at all (bad YAML, an unreadable included file, ...); citarget still reports whatever else it found. |
How it works
- Discover CI files.
.github/workflows/*.yml/.yaml, .github/**/action.yml/.yaml composite actions, and .gitlab-ci.yml plus any files it pulls in via include: - local:.
- Extract shell snippets, tracking the effective working directory: GitHub's
defaults.run.working-directory (workflow, then job, then step, each fully overriding the one before it — that's how GitHub itself resolves it, not a directory nesting), remapped back onto the actual repository root when a job's actions/checkout step used with: path: (GitHub checks the repo out at $GITHUB_WORKSPACE/<path>, so a working-directory:/${{ github.workspace }}/$GITHUB_WORKSPACE prefix under that same path really means the repository root, not a missing subdirectory — a checkout step naming a different with: repository: is left alone, since its path: isn't this repository at all); and GitLab's before_script/script/after_script, with extends (including chains) and YAML anchors/merge keys resolved through a real YAML parser (gopkg.in/yaml.v3, walked as a node tree so anchors, aliases, and << merges are followed instead of guessed at).
- Extract make/gmake/just invocations from each snippet with a real shell parser (
mvdan.cc/sh/v3/syntax), not regexes: make -C dir target, make -f other.mk t1 t2, VAR=x make t, env X=1 make t, sudo make install, &&/;-chained commands, and a preceding cd that shifts the effective directory for the rest of the script are all handled the way a shell would actually interpret them. A target/directory/file containing ${{ ... }} (GitHub Actions substitutes these before the shell ever runs) or an unresolved shell variable is flagged dynamic-target rather than guessed at. A run:/script: block citarget's shell parser can't parse at all (in practice, always PowerShell or cmd misidentified as bash — see "Detecting non-bash shells" below) is flagged unparsed-snippet and skipped, rather than aborting the scan.
- Resolve real targets. For a Makefile, when
make is on PATH, citarget asks make itself: make -pRrq -f <file> : dumps make's own target database, which citarget parses for the # Files section (explicit and include-pulled targets, minus GNU make's own reserved dot-target names like .PHONY — a real target whose name merely starts with ., such as a rule that produces a dotfile, is kept) and the # Implicit Rules section (pattern rules like %.o: %.c, matched against requested targets by prefix/suffix). This correctly handles include, generated targets, and multiple makefiles without re-implementing make's own resolution logic. Verified on macOS's bundled GNU Make 3.81; the database dump format (# Files, # Not a target:, # Implicit Rules) has been stable across GNU make versions for decades. Without make on PATH, citarget falls back to a static line parser that only sees targets written literally in that one file. For a justfile, when just is on PATH, citarget runs just --dump --dump-format json (falling back to just --summary for older just); without just, a static parser handles plain recipe definitions and alias x := y lines in a single file.
- A target not in the resolved set is
unknown-target. A -C/cd directory that exists in the repository but has no Makefile/justfile in it is unknown-file; one that doesn't exist in the repository at all is unresolved-directory (see Limitations) — citarget only ever states that the file it read doesn't have that target, never that the CI step itself is broken, since it cannot run the job to find out.
Detecting non-bash shells
citarget only parses POSIX shell. GitHub Actions runs a step as pwsh (not bash) by default on a Windows runner, and as whatever shell: says otherwise, so before parsing a run: block citarget resolves the effective shell from (in order of precedence) the step's own shell:, then defaults.run.shell at the job then workflow level, then a runs-on: label containing "windows", then — because a reusable workflow's runs-on: ${{ inputs.os }} can't be resolved from the callee alone — the workflow file's own name containing "windows" (a literal, explicit check, not a guess about content). A step whose effective shell isn't bash/sh is skipped outright, before parsing is even attempted. A step that still fails to parse (an unrecognized custom shell, or a heuristic miss) becomes unparsed-snippet instead of aborting the scan.
Real-world noise floor
Run against 8 real, unmodified repositories (shallow-cloned, not fixtures) that call make/just from CI, with the built binary on a machine with GNU Make 3.81 on PATH and no just:
| Repository |
Findings |
Errors |
Info |
| prometheus/prometheus |
0 |
0 |
0 |
| hashicorp/terraform |
0 |
0 |
0 |
| cli/cli |
0 |
0 |
0 |
| grafana/grafana |
31 |
0 |
31 (dynamic-target) |
| etcd-io/etcd |
6 |
0 |
6 (dynamic-target) |
| helm/helm |
2 |
0 |
2 (dynamic-target) |
| containerd/containerd |
9 |
0 |
5 dynamic-target, 4 unresolved-directory |
| moby/moby |
1 |
0 |
1 (dynamic-target) |
Zero errors, and every one of the 8 exits 0. That was not true of the first pass through these repos, and getting there took three real bugs, found and fixed here, not defined away:
unknown-target false positive (grafana/grafana): make .policy.yml — a legitimate file-target rule in the Makefile — was rejected because an early filter skipped every target name merely starting with ., conflating it with GNU make's own reserved names (.PHONY, .SUFFIXES, ...). Fixed by matching only that specific, finite set of reserved names (see "How it works" above and internal/target/make.go's specialTargets).
unknown-file false positives, 15 findings (containerd/containerd): make verify-vendor, make check-protos, make binaries, and others were reported unknown-file because their working-directory: (e.g. src/github.com/containerd/containerd) was checked against the actual repository root without accounting for actions/checkout's with: path: src/github.com/containerd/containerd in the same job — the CI puts the repo at that subdirectory of the workspace, so the working directory really is the repository root. Fixed by resolving the job's checkout path and remapping (see "How it works" above). The remaining 4 unresolved-directory findings in this repo are genuine "can't tell from here": a git clone-adjacent checkout of a different repository (kubernetes-sigs/cri-tools, via a second actions/checkout with an explicit with: repository:), and a directory built at run time by downloading and extracting a tarball inside a run: step — both correctly left unresolved rather than mis-classified either way.
analysis-error false positives, 13 findings (moby/moby): every one was PowerShell in .github/workflows/.windows.yml, a reusable workflow whose runs-on: ${{ inputs.os }} can't be resolved to "Windows" without tracing back to whatever workflow calls it with os: windows-.... Fixed with the file-name heuristic described above (a workflow literally named .windows.yml is skipped as non-bash); the one remaining moby/moby finding is an unrelated, genuine dynamic-target.
Limitations
- Non-POSIX shells are detected via explicit
shell:/defaults.run.shell keys, a runs-on label containing "windows", and the CI file's own name containing "windows" (see "Detecting non-bash shells"). A Windows-only reusable workflow that is named and structured differently — runs-on: ${{ inputs.os }} with no "windows" anywhere in its own file name or a static runs-on label — will still have its PowerShell mis-fed to the bash parser; it then surfaces as unparsed-snippet (informational, not a build failure) rather than a wrong unknown-target/unknown-file verdict.
- Checkout-path remapping (
actions/checkout with: path: