Pipeline
Pipeline
An automated workflow. CI/CD pipelines are a typical example.
Pipeline
An automated workflow. CI/CD pipelines are a typical example.
A pipeline is a series of automated steps in software development, from the time code is written until it is deployed to the production environment. The steps run sequentially or in parallel, and if one step fails, the entire pipeline stops.
A typical CI/CD pipeline consists of the stages Build, Test, Static Analysis (Lint), Security Scan, Deploy to Staging, Integration Test, and Deploy to Production. On average, it goes through 7 to 10 stages, and the total execution time is about 10 to 30 minutes.
A pipeline can be designed as a DAG (Directed Acyclic Graph) structure, so independent tasks can run in parallel to shorten the total time. For example, unit tests, lint, and security scans can run at the same time.
Major pipeline tools include GitHub Actions, GitLab CI, Jenkins, CircleCI, and ArgoCD. The latest trend is the declarative pipeline, in which the entire workflow is defined as code in a YAML file, then version-controlled and reused.
# GitHub Actions CI/CD Pipeline
name: Production Deploy Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# 1λ¨κ³: λΉλ λ° ν
μ€νΈ (λ³λ ¬ μ€ν)
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: build
path: dist/
test:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
test-type: [unit, integration]
steps:
- uses: actions/checkout@v4
- name: Run ${{ matrix.test-type }} tests
run: npm run test:${{ matrix.test-type }}
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npm run lint
security-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
severity: 'CRITICAL,HIGH'
# 2λ¨κ³: Docker μ΄λ―Έμ§ λΉλ
docker-build:
runs-on: ubuntu-latest
needs: [test, lint, security-scan]
outputs:
image-tag: ${{ steps.meta.outputs.tags }}
steps:
- uses: actions/checkout@v4
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
# 3λ¨κ³: μ€ν
μ΄μ§ λ°°ν¬
deploy-staging:
runs-on: ubuntu-latest
needs: docker-build
environment: staging
steps:
- name: Deploy to staging
run: |
kubectl set image deployment/app \
app=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} \
--namespace=staging
# 4λ¨κ³: νλ‘λμ
λ°°ν¬ (μλ μΉμΈ νμ)
deploy-production:
runs-on: ubuntu-latest
needs: deploy-staging
environment:
name: production
url: https://app.example.com
steps:
- name: Deploy to production
run: |
kubectl set image deployment/app \
app=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} \
--namespace=production
Senior: "This release pipeline takes 45 minutes to run. Shall we check whether there are any steps that can be parallelized?"
Junior: "I analyzed it, and lint, unit test, and security scan were running sequentially. If we switch them to run in parallel, it looks like we could save about 15 minutes."
Interviewer: "Do you have experience building CI/CD pipelines?"
Candidate: "I built a build-test-deploy pipeline with GitHub Actions. I implemented simultaneous testing of Node 18/20 versions with a test matrix, a 50% reduction in build time through caching, and automatic deployment per environment."
Take a mock interview on this topic β WIA SOOM AI Interview Β· Start for free
Reviewer: "This pipeline has no needs dependency, so the production deployment could run before the tests are complete."
Developer: "Ah, I missed that. I'll add needs: [test, security-scan] to deploy-production."