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.4.0.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

glscpc-0.4.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file glscpc-0.4.0.tar.gz.

File metadata

  • Download URL: glscpc-0.4.0.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.26.0

File hashes

Hashes for glscpc-0.4.0.tar.gz
Algorithm Hash digest
SHA256 928f47a62d5b69565a771287f569786446773a0c84f8aa8eb5df3e7afab1dacd
MD5 ec64b9547442a754e99297cb67098252
BLAKE2b-256 576c3f87a873a78a83bef4e0324f935eb6c36b93d4cf836dfd5c59be6b6650e4

See more details on using hashes here.

File details

Details for the file glscpc-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: glscpc-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.26.0

File hashes

Hashes for glscpc-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 84910ab8d3bf161f92bc00af60e8cd16789b5d79c26c364ed1b5a8454330970b
MD5 412e0f50bb971f4a7d611121793e768f
BLAKE2b-256 add809ef4ca2797887138f4bc241d6e3098e7ccc1b20755d64f7f6c6fc9fcfbf

See more details on using hashes here.

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