$ git push origin main # and the pipeline takes it from here

CI/CD

CI/CD is the practice of letting automation build, test and release every change. Continuous Integration (CI) means everyone merges small changes into the main branch often, and each change is automatically built and tested so breakage is caught within minutes. Continuous Delivery (CD) means every change that passes CI is packaged and deployable at the push of a button; Continuous Deployment goes one step further and ships it to production with no human gate.

For data teams the “code” includes SQL models, DAGs, schemas and infrastructure, and a broken change does not just crash: it can silently write wrong numbers into a dashboard. CI/CD is how you catch that before it reaches production data.

A pipeline, step by step

$ cat .github/workflows/etl.yml
Two runs of the same pipeline: one stopped by a test, one shipped
COMMITBUILDTEST PACKAGESTAGINGPROD RUN #41RUN #42 a1f3e2new join PASSlint, compile FAILdup order_id skippedskippedskipped b7c9d0fix join key PASSlint, compile PASS212 tests etl:b7c9d0image pushed PASSsmoke test LIVEafter approval
  1. Every push runs the same stages, left to right. A stage only starts if the one before it passed.
  2. Run #41: a commit changes a join. Build passes: the code lints and the SQL compiles.
  3. The test stage builds the models on sample data and a uniqueness test finds duplicate order_ids. The pipeline stops; nothing is deployed. This is CI doing its job.
  4. Run #42 fixes the join key. Build and all 212 tests pass.
  5. The change is packaged once (an image tagged with the commit) and that same artifact is deployed to staging, where a smoke test runs against realistic data.
  6. The same artifact goes to prod. With a manual approval this is continuous delivery; without one it is continuous deployment.

Typical stages

Stage Purpose Data examples
Lint and format Fail fast on style and obvious errors ruff, sqlfluff, yamllint
Build Compile, resolve dependencies, parse dbt compile, Airflow DAG import test, terraform validate
Unit tests Test functions in isolation pytest for transforms, dbt unit tests
Data tests Run models on a sample or a clone and check the output dbt unique / not_null tests, Great Expectations, Soda
Package Produce one versioned artifact Docker image, wheel, dbt manifest
Deploy Release the artifact to an environment Push DAGs, dbt build in prod, helm upgrade, Argo CD sync

CI/CD for data pipelines

Data adds problems that application CI does not have:

  • You need data to test. Use small fixture datasets for unit tests, and a zero-copy clone or a sample of production for integration tests (Snowflake and BigQuery clones, Iceberg/Delta branches, lakeFS).
  • Only build what changed. dbt’s slim CI (dbt build --select state:modified+ --defer --state prod-manifest/) builds just the modified models and their children against production references.
  • Schema changes are deploys too. Run migrations (Flyway, Liquibase, Alembic) in the pipeline, and check backward compatibility of event schemas in a schema registry.
  • Write-Audit-Publish. In production, write new data to a staging location, audit it with tests, then publish atomically. It is CI for data itself, not just for code.
  • Infrastructure in the same flow. Run terraform plan on every pull request and apply on merge; see Infrastructure as Code.

Tools

Tool Where it runs Config Notes
GitHub Actions GitHub-hosted or self-hosted runners .github/workflows/*.yml Huge marketplace of reusable actions; default choice on GitHub
GitLab CI/CD GitLab runners .gitlab-ci.yml Built into GitLab, strong for self-hosted setups
Jenkins Your servers Jenkinsfile (Groovy) Most flexible, most maintenance; common in older enterprises
CircleCI, Buildkite SaaS or hybrid YAML Fast, good caching and parallelism
Argo CD, Flux Inside Kubernetes Git repo of manifests GitOps: the cluster pulls and reconciles whatever is in Git
Bitbucket Pipelines Atlassian cloud bitbucket-pipelines.yml Natural fit for Jira/Bitbucket shops

A minimal GitHub Actions workflow for a dbt project:

name: dbt-ci
on: pull_request
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: astral-sh/setup-uv@v6
      - run: uv sync
      - run: uv run sqlfluff lint models/
      # ./prod-manifest must hold manifest.json from the last production run,
      # e.g. downloaded from object storage in an earlier step
      - run: uv run dbt build --target ci --select state:modified+ --defer --state ./prod-manifest

Common mistakes

  • Rebuilding per environment. Build the artifact once and promote the same one through staging and prod; otherwise you test one thing and ship another.
  • Flaky tests that everyone ignores. A red pipeline that is “usually fine” trains people to merge on red. Fix or delete flaky tests.
  • Production credentials in CI. Use short-lived credentials (OIDC federation to your cloud) and read-only roles for test stages.
  • Testing only code, never data. A pipeline that compiles but doubles revenue is still broken. Add data tests.
  • Slow pipelines. Over 10–15 minutes and people stop waiting for them. Cache dependencies, run tests in parallel, and build only what changed.

Learning Resources

Foundations

Tool documentation

Courses