A quick reference guide to configuring CI/CD build environments and automated deployment jobs with CircleCI.
Pipeline Lifecycle Stages
machine: Configure base VM runtime, operating system, and language version.checkout: Clone git repositories and initialize submodules.dependencies: Restore cached libraries and install language dependencies.database: Provision test database tables and load schemas.test: Run unit, functional, and integration test suites.deployment: Push passing artifacts to staging or production targets.
Configuration Example
version: 2.1
executors:
node-executor:
docker:
- image: cimg/node:18.16.0
- image: cimg/postgres:14.2
environment:
POSTGRES_USER: ubuntu
POSTGRES_DB: app_test
POSTGRES_PASSWORD: ""
jobs:
build-and-test:
executor: node-executor
steps:
- checkout
- restore_cache:
keys:
- v1-deps-{{ checksum "package-lock.json" }}
- v1-deps-
- run:
name: Install Dependencies
command: npm ci
- save_cache:
key: v1-deps-{{ checksum "package-lock.json" }}
paths:
- ~/.npm
- run:
name: Run Unit Tests
command: npm test
workflows:
build-pipeline:
jobs:
- build-and-test