GitHub Action

Run linecop in a workflow and annotate the report.

linecop v0.9.1 Manual

Manual contents

The composite action installs the linecop release for the runner, verifies its checksum, runs the scan with JSON output, and puts the result where a review can see it. Over rows become error annotations, and near rows become warnings. The step summary carries a table.

A workflow

name: linecop
on: [pull_request]

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mlavrinenko/linecop@v0.9.1
with:
paths: src/
args: --top 10

The action runs after a checkout. It puts the binary on PATH for the rest of the job, so a later step can call linecop directly.

Inputs

InputRequiredDefaultWhat it does
pathsno.Path to scan, relative to the working directory. Pass one path; spaces are preserved.
argsnoemptyExtra linecop arguments, whitespace-separated. Do not pass --format, -q or --quiet.
versionnoemptyRelease tag to install, e.g. v0.9.0. Defaults to the action ref; set it for @main and SHA pins.
working-directoryno.Directory to run linecop from, relative to the workspace.

paths names one path, relative to the working directory. The action splits args on whitespace and passes it through to linecop. Do not pass -q, --quiet, or --format in args. The action already selects JSON output and rejects any of those flags with exit code 2.

version defaults to the ref that called the action. Set it when the workflow pins @main or a commit SHA, because those refs do not carry a release tag.

Outputs

OutputWhat it contains
violationsNumber of files over their limits.

Use the output after the action step:

- uses: mlavrinenko/linecop@v0.9.1
id: patrol
- run: echo "${{ steps.patrol.outputs.violations }} files over"

Exit codes

The action maps the outcome to an exit code, so a job fails on a breach, an install failure, or a linecop error:

CodeMeaning
0Every file is below the reporting line.
1At least one file is over, at the baseline when the workflow passes --baseline, or the action could not install the release binary.
2linecop could not run: a bad config, a missing path, or an I/O error. The action also exits 2 when it refuses its own inputs.

An install failure exits 1, the same code as a breach. A linecop operational failure exits 2.

The step summary

With the examples/patrol example, the action writes a summary in this shape:

## linecop

**2 over**, 1 near, 4 selected.

| File | Language | Status | Detail |
| --- | --- | --- | --- |
| `./docs/guide.md` | Markdown | over | 20/12 lines |
| `./src/checkout.rs` | Rust | over | 30/20 lines |
| `./src/render.rs` | Rust | near | 18/20 lines |
| `./src/parse.rs` | Rust | ok | 12/20 lines |

The real table also carries a scope name in the detail cell when a scope gauge breaches. The annotation title repeats the path, the count, the cap, and the overage or percentage, so a review comment is readable without opening the log.

Runner support

The action installs on Linux and macOS runners, on x86_64 and aarch64. On Windows it stops with an error and points at cargo. Use WSL or install the binary with cargo install linecop in the job.

The usage page covers the flags that args can pass. The configuration page covers the file the scan reads.