@fukukei23
CI/CD Super Introduction — Automatic Testing and Deployment by Just Writing Code
- AI
- VibeCoding
- LLM
0
Last updated at 2026-11-12Posted at 2026-11-12
What is CI/CD?
CI/CD is a mechanism that automatically runs tests, Lint, and deployment when code is pushed.
CI — Continuous Integration (Continuous Integration)
Write code → push → [Automatic] test execution → [Automatic] Lint → result notification
CD — Continuous Deployment (Continuous Deployment)
CI passes → [Automatic] staging/production deployment
Why do CI/CD?
| Benefits | Explanation |
|---|---|
| Early bug detection | Tests are executed every time you push |
| Reduction of manual work | Tests and deployments are automated |
| Safe refactoring | You can feel safe if CI passes |
Set up CI with GitHub Actions
GitHub Actions is a free CI/CD service provided by GitHub.
Python example
# .github/workflows/ci.yml
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pytest ruff mypy
run:ruff check .
- name:Type check
run:mypy src/ --ignore-missing-imports
- name:Test
run:pytest tests/ -v
TypeScript example
# .github/workflows/ci.yml
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20, 22]
steps:
- uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Lint
run: npx biome check src/
- name: Type check
run: npx tsc --noEmit
- name: Test
run: npx vitest run
Auto publish (CD) on tag push
Example of automatically publishing an npm package:
# .github/workflows/publish.yml
name: Publish
on:
push:
tags: ["v*"] # trigger tags like v1.0.0 via push
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: "https://registry.npmjs.org"
- run: npm ci
- run: npm test
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Trunk-Based Development
To effectively utilize CI/CD, Trunk-Based Development (mainline-based development) is also important.
| Principles | Content |
|---|---|
| main is always deployable | Do not merge broken code into main |
| For personal development, push directly to main | No need for feature branches |
Summary
| Item | Content |
|---|---|
| CI | Automatically run tests and Lint when pushing |
| CD | Automatically deploy if CI passes |
| Configuration file | .github/workflows/ci.yml |
| Trunk-Based | Main is always kept in a deployable state |
By introducing CI/CD, a world where 'code is written and pushed, and tests are run and deployed automatically' awaits.
This article is also published on personal Zenn .
0
Go to list of users who liked
0
0
Go to list of comments
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
Sign upLogin