Skip to main content

A pipeline validation tool for Concourse and GitHub Actions

Project description

BagCheck

About

bagcheck is a relatively simply command line utility developed to make validating Concourse pipelines simpler. To accomplish this, bagcheck has the following functionality:

Checking a pipeline

Concourse

To check your pipeline, simply run:

bagcheck check -f /path/to/your/concourse/pipeline.yaml

at which point bagcheck will proceed to check for the following conditions:

  • All git resources are pointed at the main branch
  • All PR resource puts in the same job have the same context
  • All PR statuses are accounted for in a job (success, failure, error, pending)
  • All jobs have a timeout set

GitHub Actions

To check your pipeline, run:

bagcheck check -f /path/to/your/github/workflow-or-action.yaml

at which point bagcheck will proceed to check for the following conditions:

  • All jobs have timeouts set
  • All jobs have the required runs-on field set
  • All workflow calls pass the required inputs
  • All action calls pass the required inputs
  • All output references reference an output that actually exists
  • All input references reference an input that actually exists
  • All needs.<job>... references reference a job that is:
    • Present in the needs block of the job referencing it
    • Actually outputs the output specified
  • All external action/workflow references use the allowed ref format
    • Defaults to checking the pattern v[0-9](\.[0-9]){0,2}"
    • To change the regex pattern, configure the config.ref_regex block as shown in the configuration below

Configuring Bagcheck

Sometimes you want to skip a check across the board (e.g. you don't want timeouts in a specific pipeline) or you only want to disable a check for a specific job/resource. To do this, you'll use a .bagcheck file.

An example file looks something like this:

config:
  ref_regex: v[0-9](\.[0-9]){0,2}
disable:
  global:
    - concourse-check-main-branch
    - ...
  local:
    - path: '$.jobs[?(@.name = "job-name-1")]'
      tests:
        - concourse-check-pr-statuses
        - ...
    - path: '$.jobs[?(@.name = "job-name-2")]'
      tests:
        - concourse-check-timeout
        - ...
    - ...
warn:
  global:
    - github-check-ref
    - ...
  local:
    - path: '$.jobs[?(@.name = "job-name-1")]'
      tests:
        - github-check-action-calls
        - ...
    - ...

with any check listed under the disable.global key being completely disabled and the tests under each path being disabled when the job meets that JSONPath criteria (the ellipsis denote that you can include as many as you want in each section).

Additionally, adding any check to warn.global will result in all errors being ignored for that check and warning statements being printed instead of errors. Additionally, you can configure the same thing locally in the same manner as the local disables

Currently the following tests are run and as a consequence can be disabled:

  • concourse-check-main-branch
  • concourse-check-timeout
  • concourse-check-pr-statuses
  • concourse-check-pr-contexts
  • github-check-timeout
  • github-check-runs-on
  • github-check-workflow-calls
  • github-check-action-calls
  • github-check-output-wiring
  • github-check-needs-wiring
  • github-check-input-wiring
  • github-check-ref

One thing to note is that bagcheck will first attempt to read a file located at ~/.bagcheck and then will attempt to read one at the current working directory, combining the values with whatever is located in your ~/.bagcheck file.

Summarizing a pipeline

Having to read through a 1000+ line YAML file can make it hard to understand what the pipeline is doing on a conceptual level as well as how everything ties together. To help with this, you can run:

bagcheck summary -f /path/to/your/pipeline.yaml

at which point bagcheck will print out a summarized version of your pipeline

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

bagcheck-0.2.7.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bagcheck-0.2.7-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file bagcheck-0.2.7.tar.gz.

File metadata

  • Download URL: bagcheck-0.2.7.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.11.1 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for bagcheck-0.2.7.tar.gz
Algorithm Hash digest
SHA256 0ed938ae13df31c46182e8c44dfff6dd1ed9b51702f2f9497b7d5527cc42f46a
MD5 17b2f2a278965d92aefa6927d8998886
BLAKE2b-256 a6c5493d2092adb73b2c6a38090a9248c5064d5f33858bd3897bba47b26f4b8e

See more details on using hashes here.

File details

Details for the file bagcheck-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: bagcheck-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.11.1 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for bagcheck-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 37fa66d63df0e4dc897dfd9500784a9babbaf06e16e837a85c9dae6bbe605677
MD5 6582fdee5fb248f724b0a7ec1715c9dd
BLAKE2b-256 6d46d94c01c6cba1434b85c91de8f2854c82928f17e3c74d3f7f4f8499529b4c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page