Skip to content

Conversation

@ognis1205
Copy link
Contributor

@ognis1205 ognis1205 commented Dec 8, 2025

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

@ognis1205 ognis1205 requested a review from a team as a code owner December 8, 2025 15:39
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ognis1205, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant improvement to the developer workflow by adding a local script for running the GitHub Super Linter. This script leverages Docker to replicate the exact linting environment used in the CI pipeline, ensuring that developers can catch and resolve linting issues on their local machines before submitting code. The primary goal is to enhance consistency, prevent unexpected CI failures, and provide a smoother development experience without altering any functional source code or existing CI behavior.

Highlights

  • Local Linting Script: A new script, scripts/lint.sh, has been added to enable local execution of the GitHub Super Linter.
  • CI Configuration Mirroring: The local linting script is configured to precisely mirror the environment variables and settings used in the CI workflow, ensuring consistent linting results.
  • Improved Developer Experience: This change allows contributors to validate linting rules locally before opening a Pull Request, reducing CI failures and streamlining the development process.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a helpful script for running the super-linter locally, which is a great addition for improving the developer workflow and catching linting issues before CI. The script is well-structured and mirrors the CI configuration as intended. I have a few suggestions to enhance its robustness and usability, primarily around pinning the Docker image version to ensure reproducible builds and making the output more user-friendly. Overall, great work!

@holtskinner
Copy link
Member

@gemini-code-assist Can you recommend a way to accomplish this task without duplicating the settings across lint.yaml and this new lint.sh ?

@gemini-code-assist
Copy link
Contributor

That's an excellent question, @holtskinner! Duplication of configuration settings between the CI workflow and local scripts is a common challenge, and it's great you're thinking about how to streamline this.

The GitHub Super Linter action supports configuration via a .super-linter.env file (or .super-linter.yml). This is the ideal way to centralize your linting settings and avoid duplicating them across linter.yaml and lint.sh.

Here's how you can achieve this:

  1. Create a .super-linter.env file: At the root of your repository, create a file named .super-linter.env. Move all the common environment variables (like LOG_LEVEL, SHELLCHECK_OPTS, VALIDATE_ALL_CODEBASE, FILTER_REGEX_EXCLUDE, all VALIDATE_ flags, and _CONFIG_FILE paths) from scripts/lint.sh into this new file. Each setting should be on a new line in KEY=VALUE format.

    Example .super-linter.env content:

    LOG_LEVEL=INFO
    SHELLCHECK_OPTS="-e SC1091 -e SC2086"
    VALIDATE_ALL_CODEBASE=false
    FILTER_REGEX_EXCLUDE="^(\.github/|\.vscode/).*|CODE_OF_CONDUCT.md|CHANGELOG.md|GOVERNANCE.md|MAINTAINERS.md"
    VALIDATE_BASH=true
    VALIDATE_BASH_EXEC=true
    # ... and so on for all other VALIDATE_ and _CONFIG_FILE variables
    TYPESCRIPT_ES_CONFIG_FILE=".eslintrc.js"
    MARKDOWN_CONFIG_FILE=".markdownlint.json"
    PROTOBUF_CONFIG_FILE=".protolint.yaml"
    
  2. Update scripts/lint.sh: Remove all the -e flags that correspond to the variables you moved into .super-linter.env. You'll need to add a volume mount for the .super-linter.env file so the Docker container can read it.

    Proposed change for scripts/lint.sh:

    #!/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)
    
    # 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 \
      -e SHELL=/bin/bash \
      -e DEFAULT_BRANCH="${DEFAULT_BRANCH}" \
      -e RUN_LOCAL=true \
      -v "${REPO_ROOT}":/tmp/lint \
      -v "${REPO_ROOT}/.super-linter.env":/tmp/lint/.super-linter.env:ro \
      ghcr.io/super-linter/super-linter:slim-v8
  3. Update .github/workflows/linter.yaml: The super-linter/super-linter action automatically detects and uses a .super-linter.env file if it's present in the repository root. Therefore, you can remove the corresponding env variables from your linter.yaml workflow step.

    Example of how the linter.yaml step would simplify:

          - name: Lint Code Base
            uses: super-linter/super-linter@v5
            env:
              # Only variables specific to CI or not in .super-linter.env need to be here
              DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
              # RUN_LOCAL is implicitly false in CI
              # All other common settings are now in .super-linter.env

This approach centralizes the majority of your Super Linter configuration into a single file, making it much easier to maintain consistency between your local development environment and your CI pipeline.

@ognis1205
Copy link
Contributor Author

Thanks for the great question @holtskinner , really appreciated!

.super-linter.env is not supported by Super Linter (the action does not auto-load .github/super-linter.env when running in GitHub Actions).

Because of that, I updated the implementation so that both lint.sh and linter.yml explicitly load the same .github/super-linter.env file as their environment variables. This avoids duplicating the configuration while keeping behavior consistent between local and CI environments.

@ognis1205 ognis1205 force-pushed the ci/local-linter-script branch 3 times, most recently from 0eadac2 to 5b674e5 Compare December 16, 2025 16:19
@ognis1205
Copy link
Contributor Author

@holtskinner

I updated the implementation so that both scripts/lint.sh and .github/workflows/linter.yaml explicitly load the same .github/super-linter.env, since Super Linter doesn't auto-load .super-linter.env. This avoids config duplication while keeping local and CI behavior aligned.

Would appreciate a quick look when you have time and please let me know if this approach/PR doesn't make sense or if you see a better alternative.

@ognis1205 ognis1205 force-pushed the ci/local-linter-script branch from 5b674e5 to 7973e9d Compare December 24, 2025 21:52
Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>
@ognis1205 ognis1205 force-pushed the ci/local-linter-script branch from 7973e9d to e2829fd Compare January 7, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI]: Provide a way to run GitHub Super Linter locally

3 participants