← Ecosystem

12 Tooling

setup-google-api-linter

A GitHub Action for Google AIP Linter - CI check, validating and formatting.

A GitHub Action that installs and runs the Google AIP api-linter against your Protocol Buffer files. It downloads a pinned (or the latest) linter release, lints your protos, and surfaces the results as inline annotations, a job-summary table, action outputs, and an optional report file.

The table of contents below maps the whole document. Each entry is a link to the matching section, so you can jump straight to what you need instead of scrolling: skim Features and Quick start to get running, use Inputs and Outputs as the configuration reference, and see Contributing and License for project and legal details.

How it works

Features

  • Installs any published api-linter version, or resolves latest.
  • Caches the binary across runs via the Actions tool cache.
  • Inline pull-request annotations for every rule violation.
  • Job-summary table with a link to each AIP rule.
  • Optional machine-readable report (json, yaml, github, summary).
  • Supports config files, import paths, rule toggles and descriptor sets.
  • Written entirely in documented TypeScript.

Quick start

name: API lint
on: [pull_request]
permissions:
  contents: read
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: the-protobuf-project/setup-google-api-linter@v1
        with:
          paths: proto/**/*.proto

By default the action lints **/*.proto, installs the latest linter, annotates each problem, writes a job summary, and fails the job if any problem is found.

Inputs

InputDefaultDescription
versionlatestapi-linter version to install (e.g. 1.69.2, v1.69.2) or latest.
paths**/*.protoNewline/comma-separated globs of proto files to lint.
config""Path to an api-linter config file (YAML or JSON).
proto-paths""Newline/comma-separated import search dirs, passed as -I.
enable-rules""Newline/comma-separated rule names to enable.
disable-rules""Newline/comma-separated rule names to disable.
ignore-comment-disablesfalseIgnore in-proto disable comments (strict enforcement).
descriptor-set-in""Newline/comma-separated FileDescriptorSet files for imports.
skip-compilationfalseSkip compilation and lint descriptor-set-in instead.
buffalseResolve buf.yaml dependencies (via buf) before linting.
buf-input.buf input to export when buf is enabled (a dir with buf.yaml).
buf-config""Path to a specific buf.yaml, passed to buf as --config.
buf-path""Path to a buf executable; used instead of PATH/auto-install.
buf-versionlatestbuf CLI version to install when buf is not already on PATH.
output-formatjsonReport file format: json, yaml, github or summary.
output-path""Where to write the report. When set, exposed via results-path.
annotatetrueEmit inline GitHub annotations for each problem.
job-summarytrueWrite a results table to the job summary.
fail-on-errortrueFail the job when one or more problems are reported.
working-directory.Directory to resolve paths and run the linter from.
github-tokengithub.tokenToken used when resolving latest and downloading the release.

Outputs

OutputDescription
versionThe concrete api-linter version that was installed.
problem-countTotal number of problems reported across all files.
results-pathAbsolute path to the written report, when output-path was set.

How results are surfaced

  • Annotations — each problem becomes an inline error annotation on the relevant proto line (disable with annotate: false).
  • Job summary — a table of file, line, rule and message, with each rule linking to its page on linter.aip.dev (disable with job-summary: false).
  • Report file — set output-path to write the full report in output-format for archiving or downstream tooling.
  • Outputs — read problem-count, version and results-path in later steps.

See docs/examples.md for config files, import paths, rule overrides, descriptor sets, artifact uploads and more.

Resolving Buf dependencies

If your protos import types managed by Buf — for example google/api/* pulled from the Buf Schema Registry via buf.yaml deps — set buf: true. The action runs buf export to materialise those dependencies onto disk and adds them to api-linter’s import paths, so imports resolve instead of failing. buf is used from PATH when present, otherwise it is installed automatically — or point buf-path at your own buf executable. To use a buf.yaml that lives outside the input directory, set buf-config to its path.

- uses: the-protobuf-project/setup-google-api-linter@v1
  with:
    buf: true
    working-directory: proto # directory containing buf.yaml
    paths: "**/*.proto"

A complete, AIP-compliant example module lives in examples/buf; it is exercised end-to-end by the golden test.

Supported runners

api-linter publishes binaries for these platforms, all of which this action supports:

OSArchitectureGitHub-hosted runner
Linuxamd64, armubuntu-latest
macOSamd64, arm64macos-latest
Windowsamd64windows-latest

Linux arm64 is not published upstream and is therefore unsupported; the action fails with a clear message on unsupported hosts.

Why the bundle is committed

GitHub runs a JavaScript action by executing its compiled entry point directly from the repository at the ref you pin — it does not run bun install or bun run build for you. The bundled dist/index.js (produced by bun run build) is therefore committed to the repository, and CI fails if it drifts from src/. Rebuild and commit dist/ after any change under src/.

Versioning

  • Reference a released major tag (@v1) for stability, or a full commit SHA for maximum pinning.
  • No auto-fix — api-linter is a linter, not a formatter, so it does not rewrite protos. This action surfaces problems (including any suggestion fields) and can persist a report; applying changes is left to you.

Contributing

Contributions are welcome. See CONTRIBUTING.md for the development workflow, coding standards, and how to run bun run all before opening a pull request. In short: this project uses Bun, all code is documented TypeScript, and every file stays under 200 lines.

License

Licensed under the Apache License, Version 2.0. See LICENSE for the full text and NOTICE for attribution.

api-linter is a separate Google project, also under Apache-2.0; this action installs and invokes it but does not redistribute it.

See it on a real schema.

The editor opens an annotated .proto beside the output the actual plugin binaries produced from it.

Open the editor
GitHub