A2A/scripts/lint.sh
Shingo OKAWA 8c17173de3
ci: add local script to run super-linter (#1289)
## Summary

This PR adds a local helper script (`scripts/lint.sh`) to run GitHub
Super Linter in a Docker container.
It mirrors the configuration used in our CI workflow, allowing
contributors to validate linting rules locally before opening a Pull
Request.

## Details

 - Added `scripts/lint.sh` for running Super Linter locally
- Uses the same environment variables and config files as
`.github/workflows/linter.yaml`

## Motivation

The CI lint job sometimes fails due to rule violations that are hard to
reproduce locally.
This script ensures consistent developer experience by enabling
contributors to run the exact same linter setup.

## Notes

 - No functional changes to source code
 - CI behavior remains unchanged
 
 Closes #1290

Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>
2026-02-06 12:56:45 -06:00

26 lines
989 B
Bash
Executable File

#!/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)
# Absolute path to the Super Linter configuration file.
SUPER_LINTER_ENV="${REPO_ROOT}/.github/super-linter.env"
# Detect the default branch from the remote repository.
DEFAULT_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)
# Run Super Linter locally using Docker.
# This mirrors the configuration used in GitHub Actions to provide consistent linting behavior.
docker run \
--rm -t \
--platform linux/x86_64 \
-v "${REPO_ROOT}":/tmp/lint \
-e SHELL=/bin/bash \
-e DEFAULT_BRANCH="${DEFAULT_BRANCH}" \
-e RUN_LOCAL=true \
-e LOG_LEVEL=INFO \
--env-file "${SUPER_LINTER_ENV}" \
ghcr.io/super-linter/super-linter:slim-v8