Skip to content

๐Ÿ”ฅ CI CD ์ ์šฉ๊ธฐ with release ์ž๋™ํ™” ๐Ÿ”ฅ

Soobeen Yoon edited this page Dec 18, 2022 · 13 revisions

CI

Codecov + Jest ์ ์šฉ

typescript + jest codecov ์ ์šฉ ์‚ฌ์ „ ํ…Œ์ŠคํŠธ

๋„์ž… ๋ฐฐ๊ฒฝ

๊ทธ๋ฃน ํ”„๋กœ์ ํŠธ์—์„œ ์• ์ž์ผ ๋ฐฉ๋ฒ•๋ก ์„ ์ ์šฉํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ์•ž์œผ๋กœ release๊ฐ€ ์ตœ์†Œ 2ํšŒ ๋‚จ์•„์žˆ์—ˆ๋‹ค. ๊ทธ๋ž˜์„œ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ coverage์— ๋Œ€ํ•œ ๊ฒ€์ฆ์„ ํ•˜๊ณ  ์‹ถ์—ˆ๋‹ค.

codecov๋Š” PR Review๋ฅผ ์ง„ํ–‰ํ•  ๋•Œ๋งˆ๋‹ค _ํ•ด๋‹น PR์ด code coverage๋ฅผ ์–ผ๋งˆ๋‚˜ ๋งŒ์กฑํ–ˆ๋Š”์ง€ ์‹œ๊ฐ์ ์œผ๋กœ ํ™•์ธ_ํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์ด ๊ฐ€์žฅ ๋งค๋ ฅ์ ์ด์—ˆ๋˜ ๊ฒƒ ๊ฐ™๋‹ค.

์• ์ž์ผ ๋ฐฉ๋ฒ•๋ก ์„ ์ ์šฉํ•˜๋Š” ์šฐ๋ฆฌ ํŒ€์˜ test code coverage๋ฅผ PR๋งˆ๋‹ค ์‹œ๊ฐ์ ์œผ๋กœ ํ™•์ธํ•จ์œผ๋กœ์จ, ์œ ํšจํ•œ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ๋Š”์ง€, ๋ชฉํ‘œํ•˜๋Š” ๋งŒํผ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ ์ ˆํ•œ ๋ฒ”์œ„๋กœ ์ž˜ ์ ์šฉํ–ˆ๋Š”์ง€ ์ ๊ฒ€ํ•˜๋ ค๊ณ  ํ–ˆ๋‹ค.

๋‹ค๋งŒ, ํ˜„์žฌ ์ธํ„ฐ๋„ท์— ๋‚˜์™€ ์žˆ๋Š” ๋งŽ์€ ์ •๋ณด๋“ค์ด v1์— ๋งž์ถ”์–ด์žˆ์ง€๋งŒ, v3๊ณผ๋Š” ์กฐ๊ธˆ ์ฐจ์ด๊ฐ€ ์žˆ๋Š” ๊ฒƒ ๊ฐ™์•„ ํ˜ผ๋ž€์„ ๊ฒช๊ธด ํ–ˆ์—ˆ๋‹ค..

ํ˜„์žฌ๋Š” v1์ด deprecated๋˜์–ด, v3์„ ์‚ฌ์šฉํ•˜์˜€๋‹ค.

image
  • ์œ„์— ์‚ฌ์ „ ํ…Œ์ŠคํŠธํ•œ ๊ฒฐ๊ณผ๋ฅผ ์ฐธ๊ณ ํ•˜์—ฌ ์ง„ํ–‰ํ•˜๋˜, ํ˜„์žฌ OAO Project์—์„œ๋Š” Client ํŒŒ์ผ์— ์•Œ๊ณ ๋ฆฌ์ฆ˜ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๊ฐ€ ๋“ค์–ด๊ฐ€๊ธฐ ๋•Œ๋ฌธ์— ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋ฐ”๊พธ์–ด์„œ ์ž‘์—…ํ•จ.

    • client ๋””๋ ‰ํ† ๋ฆฌ์— yarn์ด ์„ค์น˜๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— cd client๋ฅผ ํ•ด์ค˜์•ผ ํ•œ๋‹ค.
  • ๋˜ํ•œ, github actions yml ํŒŒ์ผ์— paths: client/**๋ฅผ ์ถ”๊ฐ€ํ•ด์„œ ํด๋ผ์ด์–ธํŠธ๋‹จ ์†Œ์Šค๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ๋งŒ ๋Œ์•„๊ฐ€๋„๋ก ๋งŒ๋“ค์—ˆ๋‹ค. (ํด๋ผ์ด์–ธํŠธ ํŒŒ์ผ๋งŒ Test ๋Œ€์ƒ์ด๊ธฐ ๋•Œ๋ฌธ)

CD

yarn+express docker ์ ์šฉ ํ…Œ์ŠคํŠธ

๋„์ปค + ์ž๋™๋ฐฐํฌ ์ ์šฉ ๋ฐฐ๊ฒฝ

๋ณ€๊ฒฝ์ ์ด ์ƒ๊ธธ ๋•Œ๋งˆ๋‹ค ์„œ๋ฒ„๋ฅผ ์žฌ๊ตฌ์„ฑํ•˜๋Š” ๊ฒƒ์€ ๋„ˆ๋ฌด ํž˜๋“  ์ผ์ด์—ˆ๋‹ค.. ์ถ”๊ฐ€๋กœ, ๋กœ์ปฌ์—์„œ๋Š” ์ž˜ ๋˜๋Š”๋ฐ, ์„œ๋ฒ„๋กœ ์˜ฌ๋ฆฌ๋ฉด ์ž˜ ์•ˆ ๋˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์ƒ๊ฒจ์„œ ์ด์— ๋Œ€ํ•œ ํ•ด์†Œ ๋ฐฉ์•ˆ๋„ ํ•„์š”ํ–ˆ๋‹ค. ์ด์™€ ๋”๋ถˆ์–ด, ๊ฐœ๋ฐœ ์„œ๋ฒ„์™€ release ์„œ๋ฒ„๋ฅผ ๋ถ„๋ฆฌํ•˜๊ฒŒ ๋˜๋ฉด์„œ ๋ชจ๋“  ์„œ๋ฒ„์— ์„ค์ •์„ ๋„ฃ๋Š” ๊ฒƒ์€ ๋น„ํšจ์œจ์ ์ด๋ผ ์ƒ๊ฐํ–ˆ๋‹ค.

์š”์•ฝํ•˜์ž๋ฉด, ๋‹ค์–‘ํ•œ ํ™˜๊ฒฝ(local, dev, release)์—์„œ์˜ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ํšจ์œจ์ ์œผ๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๊ณ , ์ด์— ๋”ฐ๋ผ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” side effect ๋ฐฉ์ง€ํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค!

FrontEnd ๋„์ปค ์„ค์ •

  • /dist์— ๋ฒˆ๋“ค๋ง๋œ index.html์„ ๋ฟŒ๋ ค์คŒ

๊นจ๋‹ฌ์€ ์ 

  • docker ์‹คํ–‰ ์‹œ host post:container server port๋ฅผ ๋งคํ•‘ํ•ด์•ผ๋œ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ๊ฒŒ ๋˜์—ˆ๋‹ค.
docker run -d -p [๋‚ด local port]:[container์—์„œ ์ผœ์ ธ์žˆ๋Š” port] ghcr.io/kumsil1006/oao:latest

Docker pull & run

docker pull ghcr.io/kumsil1006/oao:oao-client
docker run -d -p 8080:3000 ghcr.io/kumsil1006/oao:oao-client

BackEnd ๋„์ปค ์„ค์ •

  1. github actions์—์„œ ts build

  2. Dockerfile์—์„œ build๋œ ํŒŒ์ผ copy ๋ฐ run

  3. backend์— ์‹คํ–‰๋˜์–ด ์žˆ๋Š” express ์„œ๋ฒ„๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

image

NGINX ๋„์ปค ์„ค์ •

  • proxy์šฉ ์„œ๋ฒ„ ์‚ฌ์šฉ
  • /: frontend, /api: backend๋กœ ํ”„๋ก์‹œ

Docker Compose ์„ค์ •

  • docker compose๋Š” pull ๋ฐ›์€ container๋งŒ compose๋ฅผ ๋‹ค์‹œ ํ•ด์ค€๋‹ค.
  • ๋”ฐ๋ผ์„œ, client, server yml์— ๊ฐ๊ฐ ๋ณ€๊ฒฝ์ ์ด ์ƒ๊ฒผ์„ ๋•Œ ๋นŒ๋“œ ํ›„ pullํ•˜๋„๋ก ์„ค์ •ํ•˜์—ฌ pull๋ฐ›์€ ์ปจํ…Œ์ด๋„ˆ๋งŒ updateํ•˜๋„๋ก ์„ค์ •ํ–ˆ๋‹ค.
  • ์ด๋กœ ์ธํ•ด, client๋‹จ ์†Œ์Šค๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์„ ๋•Œ๋Š” client container๋งŒ, server ์†Œ์Šค๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์„ ๋•Œ๋Š” server container๋งŒ pull ํ•˜์—ฌ docker compose ๋ถ€ํ•˜๋ฅผ ์ค„์ด๊ณ ์ž ํ–ˆ๋‹ค. ์ถ”๊ฐ€๋กœ, github workflow yml file์„ ๋ถ„๋ฆฌํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ์‹คํ–‰ํ•˜๋Š” ๋นŒ๋“œ&๋ฐฐํฌ ๋ถ€ํ•˜์™€ ๋ฐฐํฌ๋กœ ์ธํ•œ ์„œ๋ฒ„ ์ค‘๋‹จ๊ณผ ์ด๋กœ ์ธํ•ด ์ผ์–ด๋‚˜๋Š” ๋ฌธ์ œ(์„ธ์…˜, memory db ํœ˜๋ฐœ)๋ฅผ ์ตœ์†Œํ™”ํ•˜๊ณ ์ž ํ–ˆ๋‹ค.

client node_modules caching

  • node_modules์— ๋ณ€๊ฒฝ์ด ์—†๋Š”๋ฐ๋„ ๋ถˆ๊ตฌํ•˜๊ณ  ๋งค๋ฒˆ yarn install์„ ํ•˜๋ฉด ๋น„ํšจ์œจ์ ์ด๋‹ค. ๊ทธ๋ ‡๊ธฐ๋•Œ๋ฌธ์— marketplace์— ์žˆ๋Š” cache action์„ ์ด์šฉํ•ด cachingํ•ด์ฃผ๊ธฐ๋กœ ํ–ˆ๋‹ค
  • nnode_modules์— ๋Œ€ํ•œ cache ๊ฒ€์‚ฌ๋ฅผ ํ•œ ํ›„ ๋ชจ๋“ˆ์— ๋ณ€ํ•œ ๊ฒƒ์ด ์žˆ๋‹ค๋ฉด yarn install์„ ์‹คํ–‰ํ•ด์ฃผ๊ณ , ๋ณ€ํ™”๊ฐ€ ์—†๋‹ค๋ฉด ๊ทธ ๋‹ค์Œ step์œผ๋กœ ๋„˜์–ด๊ฐ„๋‹ค.

๊ฒฐ๊ณผ๋ฌผ

backend

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2022-11-22 แ„‹แ…ฉแ„’แ…ฎ 9 54 09

frontend

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2022-11-22 แ„‹แ…ฉแ„’แ…ฎ 9 55 09

Github Action ์ˆ˜ํ–‰์‹œ slack์— ์•Œ๋ฆผ์ฃผ๊ธฐ

  • ์šฐ๋ฆฌ ํ”„๋กœ์ ํŠธ์—์„ ... main๊ณผ release์—
    • client source์— ๋ณ€ํ™”๊ฐ€ ์žˆ๋Š” PR์ด ์˜ฌ๋ผ๊ฐ€๋ฉด code coverage Action์ด ์ˆ˜ํ–‰๋œ๋‹ค.
    • client/server source ๋ณ€ํ™”๊ฐ€ ์žˆ๋Š” push๊ฐ€ ์ผ์–ด๋‚˜๋ฉด CD Action์ด ์ˆ˜ํ–‰๋œ๋‹ค.
  • ์ด Action๋“ค์— ๋Œ€ํ•ด ๋งค๋ฒˆ ์„ฑ๊ณต/์‹คํŒจ๋ฅผ ๋ณด๊ธฐ ์œ„ํ•ด์„œ๋Š” Actions์— ๋“ค์–ด๊ฐ€์„œ ํ™•์ธํ•ด์•ผํ•˜๋Š” ๋ฒˆ๊ฑฐ๋กœ์›€์ด ์žˆ์—ˆ๋‹ค. ๊ทธ๋ ‡๊ธฐ๋•Œ๋ฌธ์— slack์— ์ด๋Ÿฐ Action๋“ค์ด ์ˆ˜ํ–‰๋˜๋ฉด ๋ฉ”์„ธ์ง€๋ฅผ ๋ณด๋‚ด์ฃผ๋Š” Action์„ ๋งŒ๋“ค๊ธฐ๋กœ ํ•˜์˜€๋‹ค.
  • ์นด์นด์˜ค์›นํˆฐ์€ GitHub Actions๋ฅผ ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์„๊นŒ? ๊ธ€์˜ Composite Action ๋งŒ๋“ค์–ด๋ณด๊ธฐ๋ฅผ ์ฐธ๊ณ ํ•˜๋ฉด ์‰ฝ๊ฒŒ Action์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค.

๊ฒฐ๊ณผ๋ฌผ

image

release branch ๋ถ„๋ฆฌํ•˜๊ธฐ

github registry

dev

  1. oao-dev-client
  2. oao-dev-server
  3. oao-dev-proxy

release

  1. oao-client
  2. oao-server
  3. oao-proxy

github release ๋ฐ release note ์ž‘์„ฑ ์ž๋™ํ™”

๊ธฐ๋Šฅ ์„ค๋ช…

  • release branch์— PR ๋‚ ์•„๊ฐˆ ๋•Œ๋งˆ๋‹ค release๋˜๋„๋ก ์„ค์ •
  • body์— changelog๋ฅผ ์ถ”๊ฐ€ํ•ด์„œ ๋ณ€๊ฒฝ์ ์„ ์ถ”์ ํ•ด์ค€๋‹ค. (๊ฟ€๊ธฐ๋Šฅ)

๋„์ž… ๋ฐฐ๊ฒฝ

  • release ๋ฒ„์ „์„ ๋งค๋ฒˆ ์ˆ˜๋™์œผ๋กœ ๊ด€๋ฆฌํ•˜๊ธฐ ์–ด๋ ต๋”ฐ!
  • github registry์˜ ์ด๋ฏธ์ง€ ๋ฒ„์ „์„ tag๋กœ ๊ด€๋ฆฌํ•˜๋Š”๋ฐ, ์ž๋™์œผ๋กœ ๋ฒ„์ „์ด ๋ผ๋ฒจ๋ง๋˜๊ณ  release ์‹œ version up์„ ํ•ด์คฌ์œผ๋ฉด ์ข‹๊ฒ ๋‹ค!
  • git release ์‹œ ๋ณ€๊ฒฝ์ ์„ ๋ชจ๋‘ ๊ธฐ๋กํ•ด์ฃผ๊ณ , ๊ธฐ๋Šฅ ์ถ”๊ฐ€(feat)์ธ์ง€, ๋ฒ„๊ทธ ์ˆ˜์ •(fix)์ธ ์ง€์— ๋Œ€ํ•œ release note๋„ ์ž๋™์œผ๋กœ ์ƒ์„ฑํ•ด์ฃผ๋‹ค๋‹ˆ..!! ์ด ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š์„ ์ด์œ ๊ฐ€ ์—†๊ฒ ๊ตฐ!

๊ณ ๋ฏผ๋“ค

  • server, client์˜ ์Šคํฌ๋ฆฝํŠธ์— ๊ฐ๊ฐ Release๋ฅผ ๋„ฃ์œผ๋ฉด, client, server๊ฐ€ ๋ชจ๋‘ ๋ฐฐํฌ๋˜๋Š” ์ƒํ™ฉ์— version up์ด ๋‘ ๋ฒˆ ์ผ์–ด๋‚  ๊ฒƒ ๊ฐ™๋‹ค. ์ด๋ ‡๊ฒŒ ๋ฒ„์ „ ๊ด€๋ฆฌ๋ฅผ ํ•˜๋Š” ๊ฒƒ์ด ๊ณผ์—ฐ ๋งž์„๊นŒ์— ๋Œ€ํ•œ ๊ณ ๋ฏผ๋“ค.!

    • server, client๊ฐ€ ๋ชจ๋‘ ํ•œ repository์—์„œ ๊ด€๋ฆฌ๋˜๊ณ  ์žˆ๊ณ , ํ˜„์žฌ ๊ณ„ํš์ƒ release๋ฅผ ํ•˜๋ฉด ๊ธฐ๋Šฅ ๋‹จ์œ„๋กœ ๋ฐฐํฌํ•˜๊ธฐ ๋•Œ๋ฌธ์—, server, client๊ฐ€ ํ•œ ๋ฒˆ์— ์˜ฌ๋ผ๊ฐˆ ๊ฒƒ์ด๋‹ค. (hotfix ์ œ์™ธ)
  • ๋ฒ„์ „ ๊ด€๋ฆฌ up ์‹œ latest release๋ฅผ ๊ธฐ์ค€์œผ๋กœ version update๋ฅผ ํ•ด์ฃผ๋Š”๋ฐ, ์ด ๊ธฐ๋Šฅ์ด ๋„ˆ๋ฌด ์ข‹์•„๋ณด์˜€๋‹ค..!!

    • ์ถ”ํ›„์— minor update๋ฅผ ํ•  ๋•Œ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๊ฐ€๋‹ค๋“ฌ์œผ๋ฉด ๋ฒ„์ „ ๊ด€๋ฆฌ๋ฅผ ๋” ์ž˜ ํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™๋‹ค.
    • ๋‹ค๋งŒ, release ์ดํ›„ hotfix๋ฅผ ํ•œ๋‹ค๋ฉด ๋ฒ„์ „ ๊ด€๋ฆฌ๋ฅผ ์–ด๋–ป๊ฒŒ ํ•˜๋ฉด ์ข‹์„์ง€ ๊ณ ๋ฏผ์ด๋‹ค. (minor ๋ฐฐํฌ, major ๋ฐฐํฌ, hotfix ๋“ฑ ์ข€ ๋” ์„ธ์„ธํ•œ ์ž‘์—…๋“ค์€ ์˜คํžˆ๋ ค ์ˆ˜๋™์œผ๋กœ ํ•˜๋Š” ๊ฒŒ ๋‚ซ์ง€ ์•Š์„๊นŒ.. ๋ผ๋Š” ์ƒ๊ฐ์ด ๋“ค์—ˆ๋‹ค. ๊ณต์‹๋ฌธ์„œ๋ฅผ ๋ณด๋ฉด์„œ ์ข€ ๋” ์ž˜ ๋งŒ๋“ค ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™๋‹ค.)
  • ์ถ”๊ฐ€ ๊ณ ๋ฏผ๊ฑฐ๋ฆฌ ๋ฐ ํ”ผ๋“œ๋ฐฑ

    • 1์ฐจ release ์ดํ›„ ์กฐ์‚ฌ ์˜ˆ์ •

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2022-11-23 แ„‹แ…ฉแ„’แ…ฎ 2 52 24

name: Release Github Application Version
on:
  pull_request:
    branches:
      - release

jobs:
  release-application:
    runs-on: ubuntu-latest
    steps:
      - name: Github Release ์ตœ์‹  tag ๋ฐ›์•„์˜ค๊ธฐ
        id: tag_version
        uses: mathieudutour/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}

      - name: GitHub project release ์—…๋ฐ์ดํŠธ
        uses: ncipollo/release-action@v1
        with:
          tag: ${{ steps.tag_version.outputs.new_tag }}
          name: Release ${{ steps.tag_version.outputs.new_tag }}
          body: ${{ steps.tag_version.outputs.changelog }}

๐Ÿ’Š ๋น„ํƒ€500

๐Ÿ“Œ ํ”„๋กœ์ ํŠธ

๐Ÿพ ๊ฐœ๋ฐœ ์ผ์ง€

๐Ÿฅ‘ ๊ทธ๋ฃนํ™œ๋™

๐ŸŒด ๋ฉ˜ํ† ๋ง
๐Ÿฅ• ๋ฐ์ผ๋ฆฌ ์Šคํฌ๋Ÿผ
๐Ÿ’ ๋ฐ์ผ๋ฆฌ ๊ฐœ์ธ ํšŒ๊ณ 
๐Ÿฅ ์ฃผ๊ฐ„ ํšŒ๊ณ 
๐Ÿ‘ฏ ๋ฐœํ‘œ ์ž๋ฃŒ
Clone this wiki locally