Overview

The project currently does not have a fully configured CI/CD pipeline. However, it does include automated scripts and configurations intended to facilitate CI/CD processes, particularly for testing and deployment.

Available Automation Scripts

Dockerfile

The Dockerfile is critical for creating a consistent build environment. Below is the essential content from the Dockerfile:

# syntax=docker/dockerfile:1

ARG PYTHON_VERSION=3.12
FROM python:${PYTHON_VERSION}

WORKDIR /src
COPY . .

ARG VERSION=0.0.0.dev0
RUN --mount=type=cache,target=/cache/pip \
    PIP_CACHE_DIR=/cache/pip \
    SETUPTOOLS_SCM_PRETEND_VERSION=${VERSION} \
    pip install .[ssh]

This Dockerfile defines a build process using Python as the base image, sets the working directory, copies the project files, and installs dependencies while managing a cache for pip.

Makefile

The Makefile contains several useful functions that help streamline the CI/CD tasks, particularly for testing and integrating Docker. Notably, the following functions can be found within the Makefile:

.PHONY: test, shell, integration-dind-ssh, setup-network, ruff, unit-test, build-dind-ssh, docs, integration-test, integration-dind-ssl, build, build-dind-certs, integration-dind, clean, all, build-docs

SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER ?= $(shell git describe --match '[0-9]*' --dirty='.m' --always --tags 2>/dev/null | sed -r 's/-([0-9]+)/.dev\1/' | sed 's/-/+/')
ifeq ($(SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER),)
    SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER = "0.0.0.dev0"
endif

The .PHONY directive specifies that these targets are not associated with files. Important targets include:

  • unit-test: Used for running unit tests.
  • integration-test: Intended for integration testing within a Docker environment.
  • build: Manages the Docker build process.

GitHub Actions Workflows

The .github/workflows/ directory contains YAML files that define GitHub Actions workflows to automate CI/CD processes.

Continuous Integration Configuration - ci.yml

name: CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: '3.12'

    - name: Build Docker Image
      run: docker build -t my-image .

    - name: Run Tests
      run: |
        docker run my-image pytest

This CI workflow triggers on pushes or pull requests to the main branch. It checks out the code, sets up Python, builds the Docker image, and runs tests within the container.

Continuous Release Configuration - release.yml

name: Release

on:
  push:
    tags:
      - 'v*'

jobs:
  release:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Authenticate to Docker Hub
      run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin

    - name: Build and Push Docker Image
      run: |
        docker build -t my-image:${{ github.ref }} .
        docker push my-image:${{ github.ref }}

This release workflow is triggered on version tag pushes. It handles Docker Hub authentication, builds a versioned image, and pushes it to the repository.

Next Steps

Given that the CI/CD infrastructure is partially set up, it is advisable to complete the following:

  1. Integrate Testing Frameworks: Ensure unit and integration tests are appropriately defined and run in unit-test and integration-test targets.

  2. Automate Deployment: For a complete CI/CD process, consider integrating automated deployment steps into the release workflow.

  3. Review Docker Configurations: Regularly update Dockerfile and Makefile to include any new dependencies or build configurations.

  4. Maintain GitHub Actions: Review and update the GitHub Actions workflows to ensure they align with best practices and project requirements.

By focusing on these areas, the CI/CD automation process can be effectively optimized and scaled as the project evolves.