Skip to content
Snippets Groups Projects

Gonrg 10105 regular release check pipeline

Merged Danylo Vanin (EPAM) requested to merge GONRG-10105-Regular-Release-Check-Pipeline into master
Files
5
+ 65
0
# Version Check Script for Helm Chart Dependencies
This Python script checks if the versions of dependencies in a Helm `Chart.yaml` file are up-to-date with the latest available tags from a GitLab repository. It also supports ignoring specific dependencies during version checks based on an environment variable.
## Features
- **Fetch Latest Tags from GitLab**: The script fetches the latest tags for Helm dependencies stored in a GitLab repository.
- **Version Comparison**: Compares the version specified in `Chart.yaml` with the latest tag in the GitLab repository.
- **Skip Certain Dependencies**: You can specify dependencies to ignore during the version check using the `IGNORE_VERSIONS` environment variable.
- **Supports Multiple GitLab Repositories**: Can work with repositories under different domains.
- **Error Handling**: Logs errors for missing environment variables, inaccessible GitLab repositories, and invalid tags.
## How It Works
1. **Load the Helm Chart**: The script loads the `Chart.yaml` file from the path specified by the `CHART_YAML_PATH` environment variable.
2. **Fetch Latest GitLab Tags**: For each dependency, the script fetches the latest tag from the corresponding GitLab repository.
3. **Version Comparison**: Compares the version of the dependency from `Chart.yaml` with the latest GitLab tag.
4. **Skip Version Check for Ignored Dependencies**: Dependencies listed in the `IGNORE_VERSIONS` environment variable are skipped during the version check.
5. **Output**: Logs and prints mismatched versions in red, and at the end, provides a summary of all services where mismatches were found.
## Requirements
- Python 3.x
- Python libraries: `gitlab`, `pyyaml`, `termcolor`
You can install the required libraries using the following command:
```bash
pip install python-gitlab pyyaml termcolor
```
## Environment Variables
The script relies on the following environment variables:
1. **`CI_JOB_TOKEN`** (required): Used to authenticate with the GitLab API.
2. **`CHART_YAML_PATH`** (required): Path to the `Chart.yaml` file that defines the dependencies.
3. **`IGNORE_VERSIONS`** (optional): A comma-separated list of dependency names to skip during version checks (e.g., `elasticsearch,gc-infra-bootstrap`).
## Usage
1. Set up the required environment variables:
- `CI_JOB_TOKEN`: GitLab job token for API authentication.
- `CHART_YAML_PATH`: Full path to the `Chart.yaml` file.
- `IGNORE_VERSIONS` (optional): List of dependency names to skip version checks.
2. Run the script:
```bash
python script.py
```
### Output
If there are version mismatches, the output will look like this:
```bash
Version mismatch for elasticsearch: Chart version = 17.9.29, Latest tag = 18.0.0
Version mismatch for airflow: Chart version = 0.0.7-latest, Latest tag = 0.0.8-latest
Summary of version mismatches:
elasticsearch: Chart version = 17.9.29, Latest tag = 18.0.0
airflow: Chart version = 0.0.7-latest, Latest tag = 0.0.8-latest
```
Loading