# Gitlabci checker
![release](https://img.shields.io/github/v/release/lorenzophys/gitlabci-checker)
[![codecov](https://codecov.io/gh/lorenzophys/gitlabci-checker/branch/main/graph/badge.svg?token=WEZ1UH621Y)](https://codecov.io/gh/lorenzophys/gitlabci-checker)
[![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/lorenzophys/gitlabci-checker/test-workflow.yml?branch=main&label=tests)](https://img.shields.io/github/actions/workflow/status/lorenzophys/gitlabci-checker/test-workflow.yml)
![pver](https://img.shields.io/pypi/pyversions/gitlabci-checker)
![MIT](https://img.shields.io/github/license/lorenzophys/gitlabci-checker)
## Installation
You can install `gitlabci-checker` via `pip`:
```console
user@laptop:~$ pip install gitlabci-checker
```
You can interact with the CLI via the `cicheck` comand:
```console
user@laptop:~$ cicheck
Usage: cicheck [OPTIONS] FILENAME
Check if your gitlab-ci pipeline compiles correctly.
Options:
-h, --help Show this message and exit.
-v, --version Show the version and exit.
-t, --token TEXT Your Gitlab access token: by default the content
of the GITLAB_TOKEN variable is used. [required]
-s, --gitlab-server TEXT The Gitlab server hostname. [required]
-k, --insecure Use insecure connection (http).
-w, --warnings-are-errors Force the failure if warnings are found.
```
## How it works?
`cicheck` just calls the [Gitlab CI lint API](https://docs.gitlab.com/15.7/ee/api/lint.html) with the file you pass to it.
By default it will send the request to `gitlab.com`. If you want to use your own Gitlab instance you must pass the server address:
```console
user@laptop:~$ cicheck .gitlab-ci.yaml --gitlab-server code.company.com
Everything's fine.
```
You must pass a valid token to the CLI: either as the environment variable `GITLAB_TOKEN` or via the `--token` flag.
## Usage example
If your pipeline is valid it returns a "Everything's fine." message
```console
user@laptop:~$ cicheck .gitlab-ci.yaml
Everything's fine.
```
If your configuration is invalid it returns an error message together with the response from Gitlab:
```console
user@laptop:~$ cicheck .gitlab-ci.yaml
Check failed with error(s).
{
"status": "invalid",
"errors": [
"variables config should be a hash of key value pairs"
],
"warnings": []
}
```
You can also force a failure whenever the linter returns a warning by appending `--warnings-are-errors` or `-w`:
```console
user@laptop:~$ cicheck .gitlab-ci.yaml --warnings-are-errors
Check failed with warning(s).
{
"status": "valid",
"errors": [],
"warnings": ["jobs:job may allow multiple pipelines to run for a single action due to
`rules:when` clause with no `workflow:rules` - read more:
https://docs.gitlab.com/ee/ci/troubleshooting.html#pipeline-warnings"]
}
```
## `pre-commit` hook
`gitlabci-checker` can be also used as a [pre-commit](https://pre-commit.com) hook. For example:
```yaml
repos:
- repo: https://github.com/lorenzophys/gitlabci-checker
rev: v0.1.1
hooks:
- id: gitlabci-checker
args:
- --gitlab-server code.company.com
- --warnings-are-errors
```
## License
This project is licensed under the **MIT License** - see the *LICENSE* file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/lorenzophys/gitlabci-checker",
"name": "gitlabci-checker",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "gitlab, ci, pipeline",
"author": "Lorenzo Maffioli",
"author_email": "lorenzo.maffioli@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/5f/c9/bf9ec539a9a3d8a3dac3c4e4410acfe57ab7f2a8a983266718f21be671dc/gitlabci_checker-0.1.3.tar.gz",
"platform": null,
"description": "# Gitlabci checker\n\n![release](https://img.shields.io/github/v/release/lorenzophys/gitlabci-checker)\n[![codecov](https://codecov.io/gh/lorenzophys/gitlabci-checker/branch/main/graph/badge.svg?token=WEZ1UH621Y)](https://codecov.io/gh/lorenzophys/gitlabci-checker)\n[![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/lorenzophys/gitlabci-checker/test-workflow.yml?branch=main&label=tests)](https://img.shields.io/github/actions/workflow/status/lorenzophys/gitlabci-checker/test-workflow.yml)\n![pver](https://img.shields.io/pypi/pyversions/gitlabci-checker)\n![MIT](https://img.shields.io/github/license/lorenzophys/gitlabci-checker)\n\n## Installation\n\nYou can install `gitlabci-checker` via `pip`:\n\n```console\nuser@laptop:~$ pip install gitlabci-checker\n```\n\nYou can interact with the CLI via the `cicheck` comand:\n\n```console\nuser@laptop:~$ cicheck\nUsage: cicheck [OPTIONS] FILENAME\n\n Check if your gitlab-ci pipeline compiles correctly.\n\nOptions:\n -h, --help Show this message and exit.\n -v, --version Show the version and exit.\n -t, --token TEXT Your Gitlab access token: by default the content\n of the GITLAB_TOKEN variable is used. [required]\n -s, --gitlab-server TEXT The Gitlab server hostname. [required]\n -k, --insecure Use insecure connection (http).\n -w, --warnings-are-errors Force the failure if warnings are found.\n```\n\n## How it works?\n\n`cicheck` just calls the [Gitlab CI lint API](https://docs.gitlab.com/15.7/ee/api/lint.html) with the file you pass to it.\n\nBy default it will send the request to `gitlab.com`. If you want to use your own Gitlab instance you must pass the server address:\n\n```console\nuser@laptop:~$ cicheck .gitlab-ci.yaml --gitlab-server code.company.com\nEverything's fine.\n```\n\nYou must pass a valid token to the CLI: either as the environment variable `GITLAB_TOKEN` or via the `--token` flag.\n\n## Usage example\n\nIf your pipeline is valid it returns a \"Everything's fine.\" message\n\n```console\nuser@laptop:~$ cicheck .gitlab-ci.yaml\nEverything's fine.\n```\n\nIf your configuration is invalid it returns an error message together with the response from Gitlab:\n\n```console\nuser@laptop:~$ cicheck .gitlab-ci.yaml\nCheck failed with error(s).\n{\n \"status\": \"invalid\",\n \"errors\": [\n \"variables config should be a hash of key value pairs\"\n ],\n \"warnings\": []\n}\n```\n\nYou can also force a failure whenever the linter returns a warning by appending `--warnings-are-errors` or `-w`:\n\n```console\nuser@laptop:~$ cicheck .gitlab-ci.yaml --warnings-are-errors\nCheck failed with warning(s).\n{\n \"status\": \"valid\",\n \"errors\": [],\n \"warnings\": [\"jobs:job may allow multiple pipelines to run for a single action due to\n `rules:when` clause with no `workflow:rules` - read more:\n https://docs.gitlab.com/ee/ci/troubleshooting.html#pipeline-warnings\"]\n}\n```\n\n## `pre-commit` hook\n\n`gitlabci-checker` can be also used as a [pre-commit](https://pre-commit.com) hook. For example:\n\n```yaml\nrepos:\n - repo: https://github.com/lorenzophys/gitlabci-checker\n rev: v0.1.1\n hooks:\n - id: gitlabci-checker\n args:\n - --gitlab-server code.company.com\n - --warnings-are-errors\n```\n\n## License\n\nThis project is licensed under the **MIT License** - see the *LICENSE* file for details.\n",
"bugtrack_url": null,
"license": null,
"summary": "Checks if your gitlab-ci pipeline compiles correctly.",
"version": "0.1.3",
"project_urls": {
"Homepage": "https://github.com/lorenzophys/gitlabci-checker",
"Repository": "https://github.com/lorenzophys/gitlabci-checker"
},
"split_keywords": [
"gitlab",
" ci",
" pipeline"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5da9c1683517760b68be0a2096de49152d23f08ef72b5e8c3748c11a8afb76fc",
"md5": "eaf457ae61b32d606c5a236f1b972ded",
"sha256": "64098c9b7a4c136412fae20753eeccf13f56058f1bcc64681cec0bf8e32f508d"
},
"downloads": -1,
"filename": "gitlabci_checker-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "eaf457ae61b32d606c5a236f1b972ded",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 5814,
"upload_time": "2024-05-07T10:28:37",
"upload_time_iso_8601": "2024-05-07T10:28:37.337587Z",
"url": "https://files.pythonhosted.org/packages/5d/a9/c1683517760b68be0a2096de49152d23f08ef72b5e8c3748c11a8afb76fc/gitlabci_checker-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5fc9bf9ec539a9a3d8a3dac3c4e4410acfe57ab7f2a8a983266718f21be671dc",
"md5": "4a0aada9d1325c6ce05f8aac902b3ab4",
"sha256": "1015fa35fefd626af0f608f74429c14c414b9a1cc2955916149009241e3dc8fb"
},
"downloads": -1,
"filename": "gitlabci_checker-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "4a0aada9d1325c6ce05f8aac902b3ab4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 4669,
"upload_time": "2024-05-07T10:28:38",
"upload_time_iso_8601": "2024-05-07T10:28:38.614616Z",
"url": "https://files.pythonhosted.org/packages/5f/c9/bf9ec539a9a3d8a3dac3c4e4410acfe57ab7f2a8a983266718f21be671dc/gitlabci_checker-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-07 10:28:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lorenzophys",
"github_project": "gitlabci-checker",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "gitlabci-checker"
}