[Avg. reading time: 7 minutes]
CICD Tools
There are many CI/CD tools available. They differ mainly in hosting model and integration ecosystem.
Categories of CI/CD Tools
Self-Hosted / On-Prem
-
Jenkins
-
CircleCI (can be self-hosted, though mostly SaaS now)
-
You need full control
-
Strict security/compliance
-
Custom infrastructure
SaaS / Web-Based
-
GitHub Actions
-
GitLab CI/CD
-
You want quick setup
-
Tight integration with source control
Cloud-Native Tools
-
AWS CodeBuild / CodePipeline
-
Azure DevOps
-
Google Cloud Build
-
You’re already in that cloud
-
Need deep integration with cloud services
GitHub Actions
One of the most widely used CI/CD tools today.
- Native integration with GitHub
- Free tier available
- Huge marketplace of reusable actions
Core Five Concepts
Workflows
- Define the automation pipeline
- Stored as YAML files in .github/workflows/
- Think: entire pipeline definition
Jobs
- A workflow is made up of one or more jobs
- Jobs run independently (can be parallel)
- Each job contains multiple steps
Steps
- Individual tasks inside a job
- Example: install dependencies, run tests
Events (Triggers)
Trigger the execution of the job.
- on push / pull
- on schedule
- on workflow_dispatch (Manual Trigger)
Actions
Reusable building blocks.
Example:
- checkout repo
- setup Python
- deploy apps
https://github.com/features/actions
Runners
Remote computer that GitHub Actions uses to execute the jobs.
Github-Hosted Runners
- ubuntu-latest
- windows-latest
- macos-latest
Self-Hosted Runners
- Specific OS that Github does not offer.
- Connection to a private network/environment.
- To save costs for projects with high usage. (Enterprise plans are expensive)
YAML (Yet Another Markup Language)
- Human-readable
- Key-value structure
- Indentation matters
https://learnxinyminutes.com/docs/yaml/
Sample
name: CI Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Run tests
run: pytest
DEMO
Multiple Runners Demo
https://github.com/gchandra10/github-actions-multiple-runners-demo
https://github.com/gchandra10/python_cicd_calculator