Skip to content

Latest commit

 

History

History
83 lines (60 loc) · 3.02 KB

File metadata and controls

83 lines (60 loc) · 3.02 KB

Lint SQL Action

The "Lint SQL" GitHub Action is designed to perform linting on SQL files or directories containing SQL files, ensuring adherence to best practices and coding standards.

Description

This action uses SQLFluff, a popular SQL linter, to analyze your SQL code. It's highly configurable, allowing you to specify a particular version of SQLFluff, choose the Python runtime, and provide additional configuration for the linting process.

Inputs

The action accepts the following inputs:

  • config:

    • Description: Include additional config file. By default, the config is generated from the standard configuration files described in the documentation. This input allows you to specify an additional configuration file that overrides the standard configuration files. Note that the cfg format is required.
    • Required: No
    • Default: ''
  • path:

    • Description: The path to a SQL file or directory to lint. This can be either a file ('path/to/file.sql'), a path ('directory/of/sql/files'), a single ('-') character indicating reading from stdin, or a dot/blank ('.'/' ') which will be interpreted as the current working directory.
    • Required: Yes
  • python-version:

    • Description: The version of Python to use. Defaults to the latest version.
    • Required: No
    • Default: 'latest'
  • sqlfluff-version:

    • Description: The version of SQLFluff to use. If not specified, defaults to the latest version.
    • Required: No
    • Default: ''

Usage

To use the "Lint SQL" action in your workflow, include it as a step:

- name: Lint SQL Files
  uses: generalui/github-workflow-accelerators/.github/actions/[email protected]
  with:
    config: 'path/to/config.cfg' # Optional: Path to additional config
    path: 'path/to/sql/files' # Required: Path to SQL file or directory
    python-version: '3.8' # Optional: Specify Python version
    sqlfluff-version: '0.8.1' # Optional: Specify SQLFluff version

Workflow Steps

  1. Checkout Code:

    • Checks out the code in your repository so that it can be analyzed by SQLFluff.
  2. Setup Python:

    • Sets up the Python environment using the specified version.
  3. Install SQLFluff:

    • Installs SQLFluff, optionally locking it to a specific version.
  4. Lint:

    • Runs SQLFluff lint on the specified path. If an additional config is provided, it's included in the linting process.

Notes

  • Ensure that the path to the SQL files or directories is correctly specified.
  • If using an additional config file, ensure it's in the correct cfg format as expected by SQLFluff.
  • The action is highly customizable, allowing you to lock in specific versions of both Python and SQLFluff, making it suitable for projects with specific requirements.

Integration

Integrate this action into your workflows to ensure your SQL code remains clean, maintainable, and adheres to your coding standards.


This README provides a comprehensive guide on how to integrate and leverage the "Lint SQL" action in your GitHub workflows.