Metadata-Version: 2.1
Name: glscpc
Version: 0.3.0
Summary: GitLab CI ShellCheck pre-commit hook
Author-email: Dries Kennes <dries.kennes@qteal.com>
License: MIT License
        
        Copyright (c) 2023 Dries Kennes
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: >=3.8
Requires-Dist: click~=8.1
Requires-Dist: ruamel-yaml~=0.17.32
Requires-Dist: strenum~=0.4.15; python_version < '3.11'
Provides-Extra: shellcheck
Requires-Dist: shellcheck-py; extra == 'shellcheck'
Description-Content-Type: text/markdown

# GitLab CI ShellCheck pre-commit hook

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

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

## Supported

- [before_script](https://docs.gitlab.com/ee/ci/yaml/#before_script), [script](https://docs.gitlab.com/ee/ci/yaml/#script), [after_script](https://docs.gitlab.com/ee/ci/yaml/#after_script)
- [hooks:pre_get_sources_script](https://docs.gitlab.com/ee/ci/yaml/#hookspre_get_sources_script)

## Dependencies

It's required to install [shellcheck](https://shellcheck.net) 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](https://github.com/shellcheck-py/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](https://github.com/pre-commit/pre-commit-hooks#check-yaml) and [valid](https://github.com/emmeowzing/gitlabci-lint-pre-commit-hook).

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

```yaml
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](https://pypi.org/project/glscpc) (only tagged versions / releases are pushed) or the [GitLab package registry](https://gitlab.com/Qteal/oss/gitlabci-shellcheck-precommit/-/packages) (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.**
