CI/CD: Continuous Integration and Deployment

Table of Contents

Background

CI/CD automates the software delivery process:

  • Continuous Integration: Automatically build and test on every commit
  • Continuous Delivery: Automated deployment to staging
  • Continuous Deployment: Automated deployment to production

Providers

Provider Type Key Features
GitHub Actions Cloud Native GitHub integration, YAML
GitLab CI Cloud/OSS Built into GitLab, Auto DevOps
CircleCI Cloud Docker-first, parallelism
Jenkins OSS Extensible, self-hosted
AWS CodeBuild Cloud AWS integration, pay-per-build
Buildkite Hybrid Self-hosted agents, cloud dashboard

GitHub Actions Example

# .github/workflows/ci.yml
name: CI

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

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - name: Install dependencies
        run: pip install -e ".[dev]"

      - name: Run tests
        run: pytest --cov

      - name: Lint
        run: ruff check .

GitLab CI Example

# .gitlab-ci.yml
stages:
  - test
  - build
  - deploy

test:
  stage: test
  image: python:3.12
  script:
    - pip install -e ".[dev]"
    - pytest --cov

build:
  stage: build
  image: docker:latest
  services:
    - docker:dind
  script:
    - docker build -t myapp .

deploy:
  stage: deploy
  only:
    - main
  script:
    - ./deploy.sh

Best Practices

  • Keep pipelines fast (< 10 minutes)
  • Cache dependencies between runs
  • Run tests in parallel when possible
  • Use matrix builds for multiple versions
  • Separate build and deploy stages
  • Use environment-specific secrets

Key Features

Feature Description
Caching Speed up builds with dependency caching
Parallelism Run jobs concurrently
Matrix builds Test across multiple environments
Secrets Secure credential storage
Artifacts Share files between jobs
Environments Deploy to staging/production

Resources

Author: Jason Walsh

j@wal.sh

Last Updated: 2025-12-21 23:01:48

build: 2025-12-29 20:02 | sha: 3c17632