gitlab-ci-verify

command module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

README

[IN IMPLEMENTATION] gitlab-ci-verify

GitHub Release CircleCI codecov Renovate Quality Gate Status Maintainability Rating Go Report Card Security Rating


Validate and lint your gitlab ci files using ShellCheck, the Gitlab API and curated checks

Features

  • ShellCheck for scripts
  • Validation against Pipeline Editor API for project
  • Automatic detection of the current gitlab project
  • Available as pre-commit hook

Installation

Manual
Linux (64-bit)
curl -LO https://github.com/timo-reymann/gitlab-ci-verify/releases/download/$(curl -Lso /dev/null -w %{url_effective} https://github.com/timo-reymann/gitlab-ci-verify/releases/latest | grep -o '[^/]*$')/gitlab-ci-verify_linux-amd64 && \
chmod +x gitlab-ci-verify_linux-amd64 && \
sudo mv gitlab-ci-verify_linux-amd64 /usr/local/bin/gitlab-ci-verify
Darwin (Intel)
brew
brew tap timo-reymann/gitlab-ci-verify
brew install gitlab-ci-verify
manual
curl -LO https://github.com/timo-reymann/gitlab-ci-verify/releases/download/$(curl -Lso /dev/null -w %{url_effective} https://github.com/timo-reymann/gitlab-ci-verify/releases/latest | grep -o '[^/]*$')/gitlab-ci-verify_darwin-amd64 && \
chmod +x gitlab-ci-verify_darwin-amd64 && \
sudo mv gitlab-ci-verify_darwin-amd64 /usr/local/bin/gitlab-ci-verify
Install with go
go install github.com/timo-reymann/gitlab-ci-verify@latest
Install with pip(x)

Using pipx you can just use the following command use gitlab-ci-verify as it is:

pipx install gitlab-ci-verify

If you want to use it directly using the subprocess module you can install it with pip:

pip install gitlab-ci-verify

And use the package like this:

from gitlab_ci_verify import verify

valid, findings = verify("/path/to/file")

print(f"Valid:    {valid}")
print(f"Findings: {findings}")
Supported platforms

The following platforms are supported (and have prebuilt binaries / ready to use integration):

  • Linux
    • 64-bit
    • ARM 64-bit
  • Darwin
    • 64-bit
    • ARM (M1/M2)
  • Windows
    • 64-bit
  • pre-commit (x86 & ARM)
  • Docker (x86 & ARM)
Where to find the latest release for your platform
Binaries

Binaries for all of these can be found on the latest release page.

Docker

For the docker image check the docker hub.

Usage

Command Line
gitlab-ci-verify --help
Containerized
docker run --rm -it -v $PWD:/workspace -e GITLAB_TOKEN="your token" timoreymann/gitlab-ci-verify
pre-commit
- repo: https://github.com/timo-reymann/gitlab-ci-verify
  rev: main
  hooks:
    - id: gitlab-ci-verify

Motivation

Unfortunately, GitLab didn't provide a tool to validate CI configuration for quite a while. Now that changed with the glab CLI providing glab ci lint but it is quite limited and under the hood just calls the new CI Lint API.

Throughout the years quite some tools evolved, but most of them are either outdated, painful to use or install, and basically also provide the lint functionality from the API.

As most of the logic in pipelines is written in shell scripts via the *script attributes these are lacking completely from all tools out there as well as the official lint API.

The goal of gitlab-ci-verify is to provide the stock CI Lint functionality plus shellcheck. Completed in the future some rules to lint that common patterns are working as intended by GitLab and void them from being pushed and leading to unexpected behavior.

Contributing

I love your input! I want to make contributing to this project as easy and transparent as possible, whether it's:

  • Reporting a bug
  • Discussing the current state of the configuration
  • Submitting a fix
  • Proposing new features
  • Becoming a maintainer

To get started please read the Contribution Guidelines.

Development

Requirements
Test
make test-coverage-report
Build
make build

Credits

This whole project wouldn't be possible with the great work of the following libraries/tools:

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
pkg
cli
git

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL