
๐ฏ ํ๋ก ํธ์๋ยท๋ฐฑ์๋ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋น๋, ํ ์คํธ, ํจํค์ง, ๋ฐฐํฌ, ๊ฒ์ฆํ๋ CI/CD ํ์ดํ๋ผ์ธ ๊ตฌ์ถ์ ์ ๋ฆฌํฉ๋๋ค.

Code Checkout
Jenkins๊ฐ GitHub์์ git clone ํ๊ธฐ ์ํ credentials ์ค์ ํ์
๊ฐ์์ Private Repository์์ ์์ค์ฝ๋๋ฅผ ๊ฐ์ ธ์ ๋น๋
Unit Test
builder ์์ด์ ํธ์์ Node.js v18 ํ๊ฒฝ์ผ๋ก npm test ์คํ
Coverage Report๋ฅผ ์ํ ์ค์ ์ถ๊ฐ ์์
Build
๋์ผํ builder ์์ด์ ํธ์์ npm run build
๊ฒฐ๊ณผ๋ฌผ:
frontend/build
backend/build
Packaging
JNLP ์์ด์ ํธ์์ docker build ๋ฐ docker push
ECR ์ ๊ทผ์ ์ํด Jenkins์ AWS credentials ๋ฐ ๊ด๋ จ ํ๋ฌ๊ทธ์ธ ์ค์ ํ์
Staging
Terraform ์ฌ์ฉ โ EC2์ ๋์ด Minikube ํด๋ฌ์คํฐ์ ์ปจํ ์ด๋ ๋ฐฐํฌ
ECR ์ ๊ทผ ๋ฐ S3 ์ํ ์ ์ฅ์ ์ํด AWS ์ธ์ฆ ํ์
Acceptance Test
Selenium Standalone ์ธ์คํด์ค๋ฅผ ๋ก์ปฌ ํด๋ฌ์คํฐ์ ๋์ (WD ํ๋ธ๋ก ์ฌ์ฉ)
tester ์์ด์ ํธ์์ Python ๊ธฐ๋ฐ E2E ํ ์คํธ ์คํ
pytest, selenium ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฌ์ฉ
Selenium Grid ๊ธฐ๋ฐ ๋ธ๋ผ์ฐ์ ์๋ํ ํ ์คํธ
Release
Staging๊ณผ ๋์ผ ๋ฐฉ์์ผ๋ก ํ๋ก๋์ ๋ฐฐํฌ
Terraform ๋ฐ ์ปจํ ์ด๋ ํ๊ฒฝ ๋ณ์๋ง ๋ณ๊ฒฝํ์ฌ ์ ์ฉ
Smoke Test
๋ฐฐํฌ๋ ์ฑ์ด โ์ ์ ๋ฐฐํฌ๋์๋์งโ ํ์ธ
์ค์ ๊ธฐ๋ฅ ํ ์คํธ๋ ์๋
Staging ์๋ฒ ์์ ํด์
terraform destroy๋ก k8s ์ค๋ธ์ ํธ ์ ๊ฑฐ
EC2๋ ๋์ ์ผ๋ก ๊ด๋ฆฌ ๊ฐ๋ฅ
Selenium ์ธ์คํด์ค ํด์
ํ
์คํธ ๋๊ตฌ: npm test
์ปค๋ฒ๋ฆฌ์ง ๋๊ตฌ: c8
์ ์ธ ์ค์ (tsconfig.json, c8 ์ค์ )
"exclude": ["src/**/*.test.ts", "src/**/__mocks__/*.ts"]
ํ๋ก ํธ์๋: ${PROJECT_ROOT}/frontend/coverage/index.html
๋ฐฑ์๋: ${PROJECT_ROOT}/backend/coverage/index.html
frontend/Makefile , backend/Makefiletest:
npm ci
c8 -r html -o coverage --all npm test -- --watchAll=false
FROM ubuntu:22.04
RUN apt update && apt upgrade -y
RUN apt install -y curl make
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
RUN apt install -y nodejs
RUN npm i -g c8
์์ฑํ ์ด๋ฏธ์ง๋ sheayun/jenkins-agent-node-18 ๋ก ๋ฑ๋ก
Jenkins๊ฐ ์ด ์ด๋ฏธ์ง๋ฅผ ์ด์ฉํด ํ ์คํธ ์คํ
Pipeline ์ด๋ฆ: lecture
Jenkins Credentials: github-credentials (SSH private key ์ฌ์ฉ
pipeline {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: builder
image: sheayun/jenkins-agent-node-18
command:
- cat
tty: true
'''
}
}
stage("Checkout") {
steps {
git url: "git@github.com:sheayun/lecture.git",
branch: "main",
credentialsId: "github-credentials"
}
}
stage("UT") {
steps {
script {
container("builder") {
sh '''
(cd backend && make test)
(cd frontend && make test)
chmod -R 777 backend/coverage
chmod -R 777 frontend/coverage
'''
}
}
}
}
stage("Code Coverage") {
steps {
publishHTML(target: [
reportDir: 'backend/coverage',
reportFiles: 'index.html',
reportName: 'Backend Coverage'
])
publishHTML(target: [
reportDir: 'frontend/coverage',
reportFiles: 'index.html',
reportName: 'Frontend Coverage'
])
}
}