GenAI Stack’s CI/CD: Automating Testing, Building, and Deployment

Overview

The GenAI Stack is an open-source project on GitHub (https://github.com/docker/genai-stack) that utilizes Continuous Integration (CI) and Continuous Deployment (CD) processes to ensure the quality and reliability of its codebase. In this documentation, we’ll cover the CI/CD tools and workflows used in the GenAI Stack, focusing on automating testing, building, and deployment.

What is CI/CD?

CI/CD is a software development practice that automates the building, testing, and deployment of code changes. CI refers to the continuous integration of code changes into a shared repository, where automated tests are run to ensure the codebase’s quality. CD, on the other hand, refers to the continuous deployment of tested code changes to production environments.

Why is CI/CD important?

CI/CD is essential for several reasons:

  1. Faster feedback: Automated testing and deployment reduce the time it takes to identify and address issues, allowing developers to focus on new features and improvements.
  2. Improved code quality: Continuous integration ensures that code changes are tested and merged frequently, reducing the likelihood of introducing bugs and improving overall code quality.
  3. Reduced risk: By automating the deployment process, CI/CD minimizes the risk of human error and ensures that only tested and validated code is released to production.

Tools and Workflows

GitHub Actions

The GenAI Stack uses GitHub Actions (https://github.com/features/actions) for its CI/CD workflows. GitHub Actions is a continuous integration, continuous delivery, and continuous deployment platform that allows developers to automate workflows directly in their GitHub repository.

Workflows

The GenAI Stack has several workflows defined in its .github/workflows directory, including:

  1. .github/workflows/build.yml: This workflow is responsible for building the Docker images used by the GenAI Stack. It is triggered whenever there is a push event to the main branch.
  2. .github/workflows/test.yml: This workflow runs the unit tests and integration tests for the GenAI Stack whenever there is a push event to any branch.
  3. .github/workflows/deploy.yml: This workflow is responsible for deploying the tested code changes to the production environment whenever there is a release on GitHub.

Examples

Here’s an example of how the test.yml workflow is defined:

name: Test
          
          on:
            push:
              branches: [ main, develop ]
          
          jobs:
            test:
              runs-on: ubuntu-latest
          
              steps:
              - uses: actions/checkout@v2
          
              - name: Set up JDK 11
                uses: actions/setup-java@v1
                with:
                  java-version: '11'
                  distribution: 'adopt'
          
              - name: Install dependencies
                run: |
                  npm install
                  mvn install
          
              - name: Run tests
                run: |
                  mvn test
          

This workflow runs the unit and integration tests whenever there is a push event to the main or develop branches. It sets up JDK 11, installs dependencies using npm and Maven, and then runs the tests.

For more information on GitHub Actions and its workflows, please refer to the official documentation.