Compare commits

...

2 Commits

Author SHA1 Message Date
Holt Skinner
0710b78dee ci(lint): Add API Linting Configuration 2026-02-10 13:04:58 -06:00
Darrel Miller
3628e974ef feat(linter): Add API Linter job to workflow for proto file validation against 2026-02-10 12:58:38 -06:00
3 changed files with 82 additions and 0 deletions

View File

@ -27,3 +27,23 @@ jobs:
uses: super-linter/super-linter/slim@v8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
api-linter:
name: API Linter
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Run API Linter
uses: googleapis/api-linter@v2.2.0
with:
# Lint all proto files in the specification directory
proto-path: specification
# Use the api-linter configuration file
config-path: specification/.api-linter.yaml
# Lint all proto files
args: specification/*.proto

27
scripts/api-linter.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
# Exit on error (-e), undefined variable usage (-u), or failed pipe command (-o pipefail).
set -euo pipefail
# Determine the repository root directory based on the script's location.
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
REPO_ROOT=$(cd -- "${SCRIPT_DIR}/.." &>/dev/null && pwd)
# Change to the repository root so that file paths are relative to it.
cd "${REPO_ROOT}"
# Run API Linter locally using Docker.
# This mirrors the configuration used in GitHub Actions.
# Using the image used by the googleapis/api-linter action.
echo "Running API Linter..."
docker run \
--rm \
-t \
-v "${REPO_ROOT}:/workspace" \
-w /workspace \
gcr.io/gapic-images/api-linter:latest \
--proto-path=specification \
--config-path=specification/.api-linter.yaml \
specification/*.proto
echo "API Linter finished."

View File

@ -0,0 +1,35 @@
# API Linter Configuration
# https://linter.aip.dev/
# Disable rules related to blank lines and formatting
disabled_rules:
# Formatting and blank line rules
- core::0191::java-multiple-files
- core::0191::java-outer-classname
- core::0191::java-package
- core::0191::csharp-namespace
- core::0191::go-package
# Comment and documentation rules
# Enabled relevant rules for better checks
# - core::0192::has-comments # Suppress missing comment warnings
# - core::0123::resource-annotation # Resource name annotations
# - core::0203::optional # Optional field comments
# - core::0203::required # Required field comments
# - core::0127::http-annotation # HTTP annotation comments
# - core::0131::request-message-name # Request naming
# - core::0132::response-message-name # Response naming
# - core::0158::request-required-fields # Required request fields
# Keeping these disabled as they might be too strict for now, but can be enabled later
- core::0203::input-only # Input only field comments
- core::0203::output-only # Output only field comments
- core::0203::immutable # Immutable field comments
# You can also use include_rules to be more specific
# enabled_rules:
# - all
# Set the minimum severity level to report
# Options: disabled, info, warning, error
# severity: warning