Skip to main content

Validate your GitLab CI with GitLab's API endpoint.

Project description

GitLab CI validation pre-commit-hook

This is a pre-commit hook that uses GitLab's /api/v4/ci/lint lint endpoint to validate the contents of .gitlab-ci.yml files. This is similar in fashion to how CircleCI pre-commit hooks validate that product's required configs, which is by uploading your config to an endpoint.

By default, this tool sends your configuration to https://gitlab.com, though this can be overridden (see below).

This tool has been extended and adapted from kadrach's implementation (cf. the license).

Usage

GitLab Lint API now requires authorization.

  1. Create Access Token with api scope.
  2. Set access token value as GITLAB_TOKEN environment variable.
  3. Ensure Python version available is 3.10.x or later.

Warning Please note the token should not be shared and if leaked can cause significant harm.

An example .pre-commit-config.yaml:

---
repos:
  - repo: https://github.com/bjd2385/pre-commit-gitlabci-lint
    rev: <latest release>
    hooks:
      - id: gitlabci-lint
      # args: ["https://custom.gitlab.host.com"]

Development

Install dependencies by running ./scripts/dependencies.sh. Or, if you already have yarn in your path, yarn install:deps.

Releases

Update src/gitlabci_lint/validate.py/__version__, setup.py/version-string, and tag this repo's master branch with the same version string (prefixed by 'v.)

TODOs:

  • Allow passing multiple config files for validation in template repositories.

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

pre-commit-gitlabci-lint-0.0.5.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

pre_commit_gitlabci_lint-0.0.5-py3-none-any.whl (5.3 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