Skip to main content

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.

Metadata

Release files for glscpc 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for glscpc 0.4.0
File Size Uploaded
glscpc-0.4.0.tar.gz 19.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for glscpc 0.4.0
File Interpreter ABI Platform
glscpc-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 35.7 kB

Release files / glscpc-0.4.0.tar.gz

Download URL glscpc-0.4.0.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
928f47a62d5b69565a771287f569786446773a0c84f8aa8eb5df3e7afab1dacd
BLAKE2b-256 checksum
How to use checksums
576c3f87a873a78a83bef4e0324f935eb6c36b93d4cf836dfd5c59be6b6650e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.26.0

Release files / glscpc-0.4.0-py3-none-any.whl

Download URL glscpc-0.4.0-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84910ab8d3bf161f92bc00af60e8cd16789b5d79c26c364ed1b5a8454330970b
BLAKE2b-256 checksum
How to use checksums
add809ef4ca2797887138f4bc241d6e3098e7ccc1b20755d64f7f6c6fc9fcfbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.26.0

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page