Skip to content
BOHYEON SEO edited this page Nov 14, 2019 · 1 revision

CI / CD λ¦¬μ„œμΉ˜

CI

  • κ°œλ°œμžκ°€ 각각 κ°œλ°œν•œ μ†ŒμŠ€μ½”λ“œλ₯Ό λͺ¨μ•„μ„œ ν•œκΊΌλ²ˆμ— λΉŒλ“œν•˜λŠ” 톡합 λΉŒλ“œμ˜ 과정을 νŠΉμ • μ‹œμ μ΄ μ•„λ‹ˆλΌ 주기적으둜 μˆ˜ν–‰ν•¨μœΌλ‘œμ¨ ν†΅ν•©μ—μ„œ λ°œμƒν•˜λŠ” 였λ₯˜λ₯Ό 사전에 ν•΄κ²°ν•˜κ³  이런 과정듀에 μ†Œμš”λ˜λŠ” μ‹œκ°„μ„ 쀄이기 μœ„ν•œ 기법
  • λ³΄ν˜„ 첨삭 : 멀버십 κ³Όμ • 쀑 μžλ™ 배포 μ˜μ—­μœΌλ‘œ λ³΄μž„, 거기에 ν…ŒμŠ€νŠΈ 등도 λ”ν•œ 것

λΉŒλ“œ 슀크립트λ₯Ό ν†΅ν•œ CI μžλ™ν™” μˆ˜ν–‰ 절차

μ˜ˆμ‹œ

  1. μ†ŒμŠ€μ½”λ“œλ₯Ό λ°”μ΄λ„ˆλ¦¬ 파일둜 컴파일 ν•œλ‹€.
  2. λ°”μ΄λ„ˆλ¦¬ νŒŒμΌμ„ 배포 ν˜•νƒœλ‘œ νŒ¨ν‚€μ§• ν•œλ‹€.
  3. λ‹¨μœ„ ν…ŒμŠ€νŠΈλ₯Ό μˆ˜ν–‰ν•œλ‹€.
  4. 정적 뢄석을 μˆ˜ν–‰ν•œλ‹€.
  5. 뢄석 κ²°κ³Όλ₯Ό λ¦¬ν¬νŒ… ν•œλ‹€.
  6. νŒ¨ν‚€μ§•ν•œ νŒŒμΌμ„ ν…ŒμŠ€νŠΈ μ„œλ²„μ— λ°°ν¬ν•œλ‹€.

μ˜ˆμ‹œ2

  1. featureν•˜λ‚˜ μ™„μ„±, develop branch에 push
  2. fetch ν›„
  3. mergeκ°€ 됐닀고 κ°€μ •ν•œ ν›„ npm i, npm build, npm start
  4. 였λ₯˜ μ—†μœΌλ©΄ merge μˆ˜ν–‰
    • 좩돌 μˆ˜μ •λ“±μ€ μ–΄λ–»κ²Œ?
  5. netlifyμ—μ„œ merge된 μ†ŒμŠ€λ₯Ό 가지고 μœ„ κ³Όμ • ν•œλ²ˆ λ°˜λ³΅ν•œ λ’€ 배포 적용.

travis (vs jenkins)

  • 무료. jenkins와 λ‹€λ₯΄κ²Œ μ„œλ²„κ°€ λ”°λ‘œ ν•„μš”μ—†λ‹€.

    • private projectμ—μ„œ μ‚¬μš©ν•  λ•Œ λΉ„μš©μ΄ ν•„μš”
    • TravisμΈ‘μ—μ„œ μ„œλ²„λ₯Ό κ΄€λ¦¬ν•˜κΈ° λ•Œλ¬Έμ— μ„œλ²„κ΄€λ¦¬κ°€ λ³„λ„λ‘œ ν•„μš” μ—†μŒ
  • cloudν™˜κ²½μ—μ„œ μ‹€ν–‰λ˜κΈ° λ•Œλ¬Έμ— μ—¬λŸ¬ ν™˜κ²½μ—μ„œ ν”„λ‘œμ νŠΈλ₯Ό ν…ŒμŠ€νŠΈν•˜κΈ°μ— μ’‹λ‹€. device, os λ“±

  • Docker와 μ—¬λŸ¬ 언어듀을 μ§€μ›ν•˜μ§€λ§Œ Jenkins와 λΉ„κ΅ν•˜λ©΄ customization μ˜΅μ…˜μ΄ 적닀. (μ–΄λ–€ customization인지에 λŒ€ν•œ 언급은 본문에 μ—†μŒ)

  • jenkins와 비ꡐ ν•΄μ„œ κΈ°λŠ₯도 더 적닀. (μ–΄λ–€ κΈ°λŠ₯인지 λͺ…μ‹œ μ—†μŒ)

  • configureκ°€ 훨씬 쉽닀.

  • build matrix λΌλŠ” κΈ°λŠ₯이 μžˆλ‹€. test processλ₯Ό μ—¬λŸ¬ 파트둜 λ‚˜λˆ μ„œ μ‹€ν–‰ν•˜κ²Œ μ„€μ •ν•  수 μžˆλŠ” 것. 예λ₯Όλ“€μ–΄μ„œ, unit test와 integration testλ₯Ό λ‚˜λˆ μ„œ μˆ˜ν–‰ν•΄μ„œ build capacityλ₯Ό μ˜¨μ „νžˆ ν™œμš©ν•  수 있음

    • 또, λ‹€μ–‘ν•œ λ²„μ „μ˜ ν™˜κ²½μ—μ„œ test같은 λ‚΄μš©μ„ λͺ…μ‹œμ μœΌλ‘œ λͺ…λ Ήν•  수 μžˆλŠ” λ“―
    language: python
    jobs:
      include:
      - python: "2.7"
        env: TEST_SUITE=suite_2_7
      - python: "3.3"
        env: TEST_SUITE=suite_3_3
      - python: "pypy"
        env: TEST_SUITE=suite_pypy
    script: ./test.py $TEST_SUITE
  • κ²°λ‘  : travis

(advanced or main) test

  • reactλ₯Ό μ‚¬μš©ν•  κ²ƒμ΄λ―€λ‘œ, webpack등을 μ΄μš©ν•΄μ„œ buildλ₯Ό ν•  것인데, build 였λ₯˜ 말고도 UI 및 μ‚¬μš©μž λͺ…λ Ή, κ²Œμž„ 둜직 λ“± testκ°€ μžˆμ–΄λ„ 쒋을듯 ν•˜λ‹€.
    • 이λ₯Όν…Œλ©΄, λ°©ν–₯ν‚€λ₯Ό λˆŒλŸ¬μ„œ canvasλ‚΄μ—μ„œ 캐릭터 이동
    • url둜 μ ‘μ†ν–ˆμ„ λ•Œ, socket연결이 λ˜λŠ”μ§€ λ“±

(optional) slack notification

$ curl -X POST -H 'Content-type: application/json' --data '{"text":"integration Complete"}' https://hooks.slack.com/services/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
  • CI / CD μ™„λ£Œ ν›„ 둜그λ₯Ό μŠ¬λž™ 채널에 μ•Œλ €μ£Όλ©΄ 쒋을듯 (μ—λŸ¬ 둜그 λ“±)

(boss) 직접 μ„œλ²„ ꡬ좕

  • λ―Έμ…˜ 쀑 μžˆμ—ˆμ§€λ§Œ.. travis CI tool을 μ΅νžˆλŠ” 것이 더 λΉ λ₯΄κ³ , 더 λ§Žμ€ κΈ°λŠ₯을 μ΄μš©ν•  수 μžˆμ„ 것이닀.
  • ν•™μŠ΅μ— κ΄€ν•œ 면은?
  • DevOpsλ₯Ό μ§€μ›ν•˜κ³  μ‹ΆμœΌλ©΄ κ΅¬ν˜„ν•΄λ³Όλ§Œ ν• λ“―ν•˜λ‹€.

CD

  • herokuλ‚˜ netlify등을 μ΄μš©ν•΄μ„œ 배포할 수 μžˆμ„ 것 κ°™λ‹€.
  • 였λ₯˜ 없이 merge됐을 λ•ŒλΌλ©΄ netlifyκ°€ CDλ₯Ό μˆ˜ν–‰ν•΄μ£ΌλŠ” 것 κ°™μŒ

μ–˜κΈ°ν•΄λ³Ό 것듀

  • test
  • https 톡신
  • CI / CD μž‘λ™ μ‹œκΈ°λŠ”? (브랜치 κΈ°μ€€)

μ°Έκ³ 

Travis CI λ¦¬μ„œμΉ˜ 및 μ‹€μŠ΅

Core Concepts for Beginners

  • buildλ₯Ό μ‹€ν–‰ν•˜λ©΄, TravisλŠ” μƒˆλ‘œμš΄ 가상 ν™˜κ²½μ— repositoryλ₯Ό 볡사해 build와 test 일련의 과정을 κ±°μΉœλ‹€. κ³Όμ • 쀑 ν•˜λ‚˜λΌλ„ μ‹€νŒ¨ν•˜λ©΄ broken, fail이 μ—†μœΌλ©΄ passed.

  • 자주 μ“°μ΄λŠ” μš©μ–΄λ“€

    • phase : installphase, scriptphase, deployphase λ“± job의 μˆœμ„œλŒ€λ‘œμ˜ step을 의미
    • job: repoλ₯Ό cloneν•˜κ³  μ—¬λŸ¬ phaseλ₯Ό κ±°μΉ˜λŠ” λ“± μžλ™ν™”λœ process. script phaseμ—μ„œ return이 zeroκ°€ μ•„λ‹ˆλ©΄ μ‹€νŒ¨ν•œλ‹€.
    • build: a group of jobs. 예λ₯Όλ“€μ–΄μ„œ ν•œ buildλŠ” 두 개의 job으둜 ꡬ성될 수 μžˆλ‹€. job은 각기 λ‹€λ₯Έ λ²„μ „μ˜ μ–Έμ–΄λ‘œ μ‹€ν–‰λ˜λŠ” 것. 두 job이 λͺ¨λ‘ μ„±κ³΅ν•˜λ©΄ buildκ°€ μ™„λ£Œλœλ‹€.
    • stage: ?, a group of jobs that run in parallel as part of a sequential build process composed of multiple stages.
  • Build μ‹€νŒ¨

    • errored : before_install, install, before_script phase μ—μ„œ non-zero exit codeκ°€ λ°˜ν™˜λ˜λ©΄ job은 λ°”λ‘œ λ©ˆμΆ˜λ‹€.
    • failed : script phaseμ—μ„œ non-zero exit codeκ°€ λ°˜ν™˜λ˜λ©΄ λ°œμƒ. job은 μ™„λ£Œμ „κΉŒμ§€ μ‹€ν–‰λœλ‹€.(?)
    • canceled : userκ°€ μ™„λ£Œ 전에 job을 멈좀
  • infrastructure and environment notes

    • linux
    • macOS
    • windows

slackμ—μ„œ travis api κ΄€λ ¨ λ‚΄μš© μ„€μ • μ£Όμ†Œ

μ‹€μ œ

μ˜ˆμ‹œ .travis.yml

language: node_js
notifications:
    webhooks:
        - https://hooks.slack.com/services/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
    on_success: change # default: always
    on_failure: always # default: always
    on_start: change # default: never
    on_cancel: always # default: always
    on_error: always # default: always
cache:
    directories:
        - node_modules
script:
    - npm run build
    - npm test

기타

Clone this wiki locally