Skip to main content

GitLab CI ShellCheck pre-commit hook

Project description

GitLab CI ShellCheck pre-commit hook

┏━╸╻  ┏━┓┏━╸┏━┓┏━╸
┃╺┓┃  ┗━┓┃  ┣━┛┃  
┗━┛┗━╸┗━┛┗━╸╹  ┗━╸

This is a small project to help with maintaining clean GitLab CI scripts.

Supported

Dependencies

It's required to install shellcheck and make it available in $PATH. You can specify the feature (aka extra) "shellcheck" and it will be installed via the optional dependency shellcheck-py. (pip install glscpc[shellcheck])

All Python dependencies (see pyproject.toml) are installed by pip when you install the package.

When setting up a development environment, use hatch to set up the dependencies. Running hatch build will do the heavy lifting for you.

For Pycham support run hatch env run which python and add its output as an "existing" virtualenv interpreter.

Usage

This script should be run after you check that the yml file is well-formed and valid.

The intended use is via the provided hook in the repo:

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: main
    hooks:
      # Check if all yaml files are well-formed
      - id: check-yaml
  - repo: https://github.com/bjd2385/pre-commit-gitlabci-lint
    rev: master
    hooks:
      # Linting API requires you set the project ID correctly and also have an API token configured in your environment!
      # You also should skip this step in the CI, since if it was invalid, the CI wouldn't be running anyway.
      - id: gitlabci-lint
        args: ['-p', '49052761']
  # This repo <3
  - repo: https://gitlab.com/Qteal/oss/gitlabci-shellcheck-precommit
    rev: main
    hooks:
      - id: glscpc

The pre-commit hook automatically installs shellcheck, so it's not required to pre-install it in your CI for example.

Run pre-commit autoupdate to replace the branch references with the latest tags.

But it's also possible to install the Python package in your environment and run the glscpc script.

You can install the package via pypi (only tagged versions / releases are pushed) or the GitLab package registry (includes dev builds).

To automatically download a shellcheck binary as a dependency, use pip install glscpc[shellcheck].

Run glscpc --help for up-to-date usage information and the help text.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glscpc-0.3.1.tar.gz (19.3 kB view hashes)

Uploaded Source

Built Distribution

glscpc-0.3.1-py3-none-any.whl (15.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page