# 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
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": "",
"docs_url": null,
"requires_python": ">=3.7,<4.0",
"maintainer_email": "",
"keywords": "gitlab,ci,pipeline",
"author": "Lorenzo Maffioli",
"author_email": "lorenzo.maffioli@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/c8/91/88b621ebb3546402fa600c538a66573386c25f37083b4558a1f8f4ab78d7/gitlabci_checker-0.1.1.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\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": "",
"summary": "Checks if your gitlab-ci pipeline compiles correctly.",
"version": "0.1.1",
"split_keywords": [
"gitlab",
"ci",
"pipeline"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8ae231544bb152b44293a2b98238b16d823dc351a3391691ccc277a3f4e5a5ad",
"md5": "583dc9170d58c37983ab965119c552d8",
"sha256": "76a640e9bbb121be59d7f1209c91592385d758e0f2a767a36b7453eebadb5e0e"
},
"downloads": -1,
"filename": "gitlabci_checker-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "583dc9170d58c37983ab965119c552d8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7,<4.0",
"size": 5816,
"upload_time": "2023-01-14T17:26:38",
"upload_time_iso_8601": "2023-01-14T17:26:38.147966Z",
"url": "https://files.pythonhosted.org/packages/8a/e2/31544bb152b44293a2b98238b16d823dc351a3391691ccc277a3f4e5a5ad/gitlabci_checker-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c89188b621ebb3546402fa600c538a66573386c25f37083b4558a1f8f4ab78d7",
"md5": "fdce91da2b77ff607181c9f1c652d502",
"sha256": "0c5a2623c54a684661fe03676d93844aeac9ea0ebe703ccd7da121e8b9b0ef50"
},
"downloads": -1,
"filename": "gitlabci_checker-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "fdce91da2b77ff607181c9f1c652d502",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7,<4.0",
"size": 5313,
"upload_time": "2023-01-14T17:26:39",
"upload_time_iso_8601": "2023-01-14T17:26:39.561632Z",
"url": "https://files.pythonhosted.org/packages/c8/91/88b621ebb3546402fa600c538a66573386c25f37083b4558a1f8f4ab78d7/gitlabci_checker-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-14 17:26:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "lorenzophys",
"github_project": "gitlabci-checker",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "gitlabci-checker"
}