Skip to main content

No project description provided

Project description

T4-CICD Project

This project is a CI/CD system designed to work on Python, Java, and JavaScript programs.

About This README

This README is divided into two main sections:

  1. User Section:

    • For those who want to use the application, this section provides setup instructions, requirements for external services, and basic usage commands.
  2. Developer Section:

    • For contributors or developers working on this project, this section includes instructions for setting up the development environment, managing dependencies, running tests, and generating documentation.

User Setup Instructions For Using The Application

The t4-cicd CLI application requires the following external services:

  • MongoDB service
  • Docker Engine service
  • AWS S3 Service (user must use their own AWS account)

Setting Up the Docker Engine Service

Install Docker Desktop from the official website. Docker Engine is included in the Docker Desktop installation.

On macOS or Windows: Ensure Docker Desktop is open and running before using the t4-cicd CLI application.

On Linux: Install Docker Engine directly via your package manager and ensure the Docker service (dockerd) is running.

The t4-cicd CLI uses the Docker Engine to perform its operations.

Setting Up the MongoDB Service

You can use a local or remote MongoDB Service. You will need to save the URL to the MongoDB service into a .env file in your project folder, or as an environment variable in your shell configuration file i.e., ~/.bashrc or ~/.zshrc.

The example below shows how to set up the MONGO_DB_URL for a local and remote MongoDB service.

# Local
export MONGO_DB_URL="mongodb://localhost:27017/"

# Remote, replace the <db_username>, <db_password> and <cluster_address>
export MONGO_DB_URL="mongodb+srv://<db_username>:<db_password>@<cluster_address>/"

Follow these instructions for setting up local MongoDB service. Download the MongoDB Community Server from https://www.mongodb.com/try/download/community-kubernetes-operator

Follow the instructions for self-managed deployments https://www.mongodb.com/docs/manual/administration/install-community/

To view the database, use MongoDB Compass (comes together with MongoDB installation)

Setting Up the AWS S3 Service

S3 bucket names must be globally unique across all AWS accounts. In order for Upload Artifact feature to work, user/developer needs to specify a unique name in their configuration file artifact_upload_path: "<UNIQUE_BUCKET_NAME>".

global:
  pipeline_name: "cicd_pipeline"
  docker: #...
  artifact_upload_path: <UNIQUE_BUCKET_NAME>

You need to copy and paste the following AWS credentials into ~/.aws/credentials file. The credentials you provided must be able to create a bucket and upload into S3.

aws_access_key_id=<your_id>
aws_secret_access_key=<your_secret_access_key>
aws_session_token=<your_session_token> #if applicable

You also need to set up the target region in your .env file or set it as environment variable.

DEFAULT_S3_LOC=<AWS_REGION>
# example set to us-west-2
DEFAULT_S3_LOC='us-west-2'

Installing the Program

You can install directly from PyPI using pip. It is recommended to install it under a virtual environment. See the section under Developer set up for how to activate a virtual environment.

pip install t4-cicd

Basic usage

There are 2 options for running the application:

  1. Run the command in a Git repository’s root directory to target that repository.
  2. Run the command in an empty directory and specify the target repository, which can be either local or remote.

Note: The target repository must contain a .cicd-pipelines folder with a pipelines.yml file. These files will be used as the default configuration if not explicitly specified in the command.

Check here for the syntax required to write the YML file, check here for sample pipeline configuration.

The main commands of the CLI you can run are listed below. Use the --help flag for detailed information about each command.

# Checking pipeline configuration file,
# only work within a git repository
cid config

# Setting up repository
cid config set-repo

# Getting repository info
cid config get-repo

# Override pipeline configuration value in Datastore (MongoDB)
# only work within a git repository
cid config override

# Running a pipeline run
cid pipeline run

# Retrieve pipeline report
cid pipeline report

Errors and Debug Information

  • When errors occur, the program stdout and stderr will give a brief summary of the error message.

  • For error details to help in debugging, you can look for the debug.log file created:

    • By default, a debug.log file will be created at the parent directory where the command was executed.
    • i.e., command is executed in directory /temp/t4-cicd, a debug.log will be at /temp

Developer Setup Instructions

First, follow the User Setup Instructions to set the Docker Engine service, MongoDB service and AWS S3 service.

Installation Instruction from Project GitHub Folder

Reference for Poetry and Click here

Prerequisites:

  1. Installed Python 3.12 from official website
  2. Installed pipx and poetry
# Install pipx
python -m pip install --user pipx
python -m pipx ensurepath

# Then go to your environment variable on windows/OS, check the path added and
# update lowercase to uppercase if necessary
# restart your window/OS.

# Installation of poetry using pipx
pipx install poetry
  1. Activated Virtual Environment
# Navigate to the project directory
# First create your virtual environment using venv,
# Give it a name like myenv, if you use other name, add it to the .gitignore file
# venv come with standard python package
python -m venv myenv

# Activate your virtual environment. For bash terminal
source <your_venv_dir>/Scripts/activate

# Example when you name venv as myenv
# For Windows
source myenv/Scripts/activate
# For Mac / Unix
source myenv/bin/activate

The alternative way to activate the virtual environment is to run poetry shell. This is less recommended as the downside of this approach is any command not starting with poetry will run using your background environment package instead from the virtual environment.

poetry shell

Installation, Lint & Test

# This will install all dependencies, and the project itself into your venv
poetry install

# Run pylint for src directory, --fail-under score to be 9.5
poetry run pylint ./src --fail-under=9.5

# Run pytest with coverage, note current passing coverage score is set at 50%
poetry run pytest

# Run pydoctor to generate the API documentation. This will generate a folder name 'apidocs/'
# in the repository.
# This required Administrative right. To link the file
poetry run pydoctor

# To test if you can run the command
poetry run cid --help
# Or
cid --help

Development - Managing Dependencies

Reference for dependencies management.

Please check the pyproject.toml file to ensure the dependency is added/removed

# Adding new dependency for general
poetry add <dependency/lib/package>

# Adding new dependency for development environment only
poetry add <dependency/lib/package> --group dev

# Remove dependencies
poetry remove <dependency/lib/package>
# Remove dependencies from development environment
poetry remove <dependency/lib/package> --group dev

Development - Using Logging

Steps:

  • Use the get_logger() function from util.common_utils
  • Provide arguments to change the logging level and/or directory
  • By default, a debug.log file will be created at a parent directory where you run the command. You can change its location. i.e., if you run the command under directory /temp/t4-cicd, a debug.log will be at /temp

Development Documentation:

Check out the list of documents under dev-docs/design-docs folder for the following:

  • CLI Documentation
  • Component Design
  • Configuration File Documentation
  • Data Store Documentation
  • System Design
  • Testing Documentation

For API Documentations, you can look for the artifact generated by the last GitHub workflow action step, with name api-documentations. The backup API Documentations are available in the following share location here. Look for index.html to start.

Contributions

Please fork the repository, create a branch for your changes, and submit a pull request.

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

t4_cicd-0.2.0.tar.gz (52.7 kB view details)

Uploaded Source

Built Distribution

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

t4_cicd-0.2.0-py3-none-any.whl (56.4 kB view details)

Uploaded Python 3

File details

Details for the file t4_cicd-0.2.0.tar.gz.

File metadata

  • Download URL: t4_cicd-0.2.0.tar.gz
  • Upload date:
  • Size: 52.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for t4_cicd-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9588ac35b74e3c256054517f658793157a77873002695a82fea10ac8c1e84a47
MD5 010f09876f6e8e5c6385082e95a9411f
BLAKE2b-256 41e5acdf6b5afaca42d2c9174739a7352aab95cae4f5860f62d150ec0b81d6d3

See more details on using hashes here.

File details

Details for the file t4_cicd-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: t4_cicd-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 56.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for t4_cicd-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bec88f679756f654455329cf9392778607a6044673d0c981f83c6b21f511fb03
MD5 be07fc9feb4cee0ad5132c07b8f1cbd4
BLAKE2b-256 b21ec9f9475014832505b0002775d0b5d57c5aaa915672b78e16868acb8bb3e7

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