Skip to main content

A tool to validate and simulate GitLab CI pipelines

Project description

Cimulator

A tool to validate and simulate GitLab CI pipelines without running them.

Overview

Cimulator is a Python tool designed to validate and simulate GitLab CI pipelines. It addresses the challenge of testing and validating complex CI/CD configurations without having to commit changes to a repository and wait for actual pipeline runs.

Features

  • Configuration Validation: Validates GitLab CI YAML files for non-existent jobs
  • Include Resolution: Recursively processes all included YAML files
  • Job Expansion: Properly expands jobs according to the extends mechanism
  • Rule Evaluation: Evaluates workflow and job rules to determine which jobs would run
  • Variable Interpolation: Simulates how variables are expanded in different contexts
  • Pipeline Simulation: Provides a "dry run" of what a pipeline would look like

Limitations

  • YAML correctness check is pretty basic: cimulator checks only for the references jobs that don't exist. YAML syntax correctness shall be done using the proper tools.
  • It's design to be 100% offline. It means the references to the files and jobs from other repositories are not resolved. They don't prevent cimulator from running, though.
  • In some cases you can still see incorrect variable expansion in the simulation output file. This is WIP.

Installation

pip install cimulator

Or with Poetry:

poetry add cimulator

Basic Usage

There are to commands: validate and simulate. Validation checks that all jobs references in needs and extends exist. Simulation is a more in-depth action, that considers the variables that the pipeline will be run upon, including the built-in Gitlab CI variables, resolves the rules and produces an output simulations file that contains:

  • List of jobs that will be run
  • Jobs seen as by Gitlab, i.e. with resolved extensions and variables.
# Validate a CI configuration file
cimulator validate path/to/your/.gitlab-ci.yml

# Simulate a pipeline run for the default branch
cimulator simulate path/to/your/.gitlab-ci.yml ci-config.yml profile

To simulate you will need a CI config file, which contains profiles for your CI. Typically you need to specify there the source of the pipeline and additional variables that you set in Gitlab CI.

Example

Consider the example CI in examples/complete.

You can validate and simulate this pipeline:

cimulator simulate examples/complete/.gitlab-ci.yml examples/complete/ci-config.yml MR
Root file: /Users/ibarkov/workspace/cimulator/examples/complete/.gitlab-ci.yml
Base path: /Users/ibarkov/workspace/cimulator/examples/complete

Warnings about job dependencies:
  - Job 'integration_test' needs job 'test_windows' which will not run in this pipeline
  - [Optional] Job 'test_mixed' needs job 'build_optnotrun' which will not run in this pipeline
Simulation successful. Output saved to /Users/ibarkov/workspace/cimulator/simulation_output.yml

License

MIT License - see the LICENSE file for details.

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

cimulator-0.1.2.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

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

cimulator-0.1.2-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file cimulator-0.1.2.tar.gz.

File metadata

  • Download URL: cimulator-0.1.2.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Darwin/24.5.0

File hashes

Hashes for cimulator-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1ea78af225cc140715855d387450fa5fb0302cf50d674bebe6e82e0b89d19779
MD5 fcc5d1fc21c2af8578cfbb4cba47d659
BLAKE2b-256 22d4647e341b12c9f304548537b0953cf5d4fdee260022abdc30787b5c34ac5d

See more details on using hashes here.

File details

Details for the file cimulator-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: cimulator-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Darwin/24.5.0

File hashes

Hashes for cimulator-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5d4d6aa0862d218fa828b51e5e9ac01d9e3f74a2d08f3e73dd44332efd5c9fc8
MD5 799f192cb1e38544bc0a82e882cc9485
BLAKE2b-256 5bc45c78606e61636918320da0080591a1610b8565282f9075aad31636b316e5

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