Skip to content

CircleCI ‐ Continuous Integration Testing Tool

Mahfuz Anam edited this page Nov 10, 2024 · 1 revision

CircleCI Documentation


1. Overview of CircleCI

CircleCI is a popular Continuous Integration and Continuous Delivery (CI/CD) platform that automates the software development process, allowing teams to build, test, and deploy code more efficiently. It integrates with version control systems like GitHub, Bitbucket, and GitLab, making it easy to automate workflows. CircleCI offers both cloud-based and self-hosted options, allowing developers to automate their pipelines on their preferred infrastructure.

Key features of CircleCI include:

  • Automating the build, test, and deployment stages of a project.
  • Configuring workflows with a simple YAML file.
  • Extensive support for parallel job execution and caching for faster builds.
  • Deep integration with Docker, Kubernetes, and cloud platforms (AWS, GCP, etc.).

2. How to Use CircleCI

Step-by-Step Guide to Setting Up CircleCI:

1. Prerequisites

  • A code repository hosted on a supported VCS (GitHub, GitLab, Bitbucket).
  • Administrator access to the repository.

2. Signing Up and Integrating Your Repository

  • Go to the CircleCI website and sign up using your GitHub or Bitbucket account.
  • Once logged in, select your repository from the CircleCI dashboard to set up your first project.
  • CircleCI will automatically detect the repository and ask for permissions to access it.

3. Creating a .circleci/config.yml File

  • The core of a CircleCI pipeline is the config.yml file, which defines the steps for building, testing, and deploying your project.
  • Create a .circleci directory at the root of your project, then add a config.yml file inside it.

Basic Example of a CircleCI Config File:

version: 2.1  # CircleCI configuration version

jobs:
  build:  # Define a job called 'build'
    docker:  # Use Docker image for the build
      - image: circleci/python:3.8
    steps:
      - checkout  # Pull the code from your repository
      - run: 
          name: Install Dependencies
          command: pip install -r requirements.txt
      - run:
          name: Run Tests
          command: pytest

workflows:
  version: 2
  build_and_test:
    jobs:
      - build

4. Committing and Pushing the Configuration

  • After creating the .circleci/config.yml, commit and push this file to the main branch of your repository.
  • CircleCI will automatically trigger the pipeline and start running the defined jobs (build, test, etc.).

5. Viewing the Build Process

  • Navigate to the CircleCI dashboard, where you can see your project's pipeline execution.
  • Each job and step of the pipeline will be visualized, and you can check logs for debugging.