github-actions-concurrency-explicit
github-actions-concurrency-explicit
- Package
- lint-meta-rules v1.1.0
- Runs under
@noctcore/harnesslint-meta, not ESLint- Factory
createGithubActionsConcurrencyExplicitRule- Entry point
@noctcore/lint-meta-rules- Category
ci- Fails CI by default
- Yes
A workflow-level or job-level concurrency mapping must state cancel-in-progress, so the choice to cancel a running job is written down.
When a concurrency mapping leaves out cancel-in-progress, GitHub does not cancel the running job
when a newer one enters the group. That is a decision, and one a reader of the file cannot tell from
a forgotten key. Writing cancel-in-progress: true or false shows the choice was made, and it
stops a copied block from carrying the default into a workflow where cancelling is wrong (or right).
What it flags
Section titled “What it flags”A concurrency key at workflow level, or directly under a job, whose mapping has no
cancel-in-progress entry. Both block and flow mappings are read, and an empty concurrency: or
concurrency: {} counts as a mapping without the key. The violation points at the concurrency:
line. A job that calls a reusable workflow (uses: on the job) is checked like any other job.
With requireMappingForm: true the string form is reported too, at both levels, because it cannot
carry cancel-in-progress.
# Badconcurrency: group: ci-${{ github.ref }}
jobs: build: concurrency: { group: build }
# Goodconcurrency: group: ci-${{ github.ref }} cancel-in-progress: true
jobs: build: concurrency: { group: build, cancel-in-progress: false }What it does not flag
Section titled “What it does not flag”- The string form,
concurrency: ${{ github.workflow }}-${{ github.ref }}, unlessrequireMappingFormis set. cancel-in-progresswith any value, includingfalse, a quoted value and a${{ }}expression.- A
concurrencykey nested deeper than a job’s own keys, for example underwith:orenv:, or inside arun: |script, and a line that is commented out. - A flow mapping that wraps over several lines. It is not read, so the rule stays quiet on it.
Line-based text, not a YAML parse. A block mapping whose key is quoted ("cancel-in-progress":) is not
recognised and is reported.
Options
Section titled “Options”createGithubActionsConcurrencyExplicitRule(options?: GithubActionsConcurrencyExplicitOptions): IMetaRule| Option | Type | Default | Meaning |
|---|---|---|---|
workflowGlobs |
string[] |
['.github/workflows/*.yml', '.github/workflows/*.yaml'] |
Workflow files to scan. |
requireMappingForm |
boolean |
false |
Also report the string form of concurrency, which cannot state cancel-in-progress. |
ciCritical |
boolean |
true |
Whether a violation fails CI. |
When not to use it
Section titled “When not to use it”If your workflows rely on GitHub’s default on purpose and a missing key reads fine to your team, this asks for a line that changes nothing.
Related
Section titled “Related”github-actions-security-no-cancelchecks the value of the same key in security scan workflows.