수십 명이 하나의 코드베이스에서 작업을 할 때 다음과 같은 과정들을 반복하게 됩니다.
위와 같은 과정들을 작업할 때마다 반복적인 작업을 하게되면 human error 가 생길 수 있고,
이러한 반복적인 작업의 일부분을 자동화 함으로써, human error 와 같은 실수를 없앨 수 있고,
시간도 절약 할 수 있습니다.
공식 사이트: https://docs.github.com/en/actions
Github Action 을 통해서 github 에 push 할때마다 자동으로 테스트하게 만들어 보겠습니다.
root path에 .github -> workflows -> ci.yml or ci.yaml 파일을 만들어줍니다.
새로 추가한 ci.yml 파일에 아래의 코드를 삽입해 줍니다.
name: Django CI on: push: jobs: ci: runs-on: ubuntu-latest steps: - name: Check out the codes uses: actions/checkout@v2 - name: Setup python environment id: setup-python uses: actions/setup-python@v2 with: python-version: 3.9.9 - name: Install Poetry run: | curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python echo "${HOME}/.poetry/bin" >> $GITHUB_PATH - name: Install dependencies run: | ${HOME}/.poetry/bin/poetry install - name: Test python project run: | poetry run python manage.py test
name: Django CI # 액션이 언제 실행되는지를 정의합니다. # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#on on: push: # 하나의 workflow 는 여러개의 job 으로 구성됩니다. 지금은 ci 라는 이름(id)의 job 하나만 정의하여서 사용한 케이스입니다. jobs: ci: # 이 job이 어떤 머신에서 실행되는지를 정의합니다. runs-on: ubuntu-latest # 하나의 job 은 여러개의 step 으로 구성됩니다. step 은 명령을 실행하거나 다른 action 을 실행합니다. steps: # 코드를 체크아웃한다. - name: Check out the codes # 실행할 action 을 가리킵니다. uses: actions/checkout@v2 # 파이썬을 설치한다. - name: Setup python environment id: setup-python uses: actions/setup-python@v2 # action 에 전달할 parameter 변수입니다. with: python-version: 3.9.9 # poetry 를 설치한다. - name: Install Poetry # 실행할 명령어 이며 yml 파일의 경우 파이프라인(|) 을 통해 멀티라인이라는 것을 알려주어야합니다. run: | curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python echo "${HOME}/.poetry/bin" >> $GITHUB_PATH # 종속성 django 또는 django ninja 와 같은 종속성을 설치 - name: Install dependencies run: | ${HOME}/.poetry/bin/poetry install # project 의 test 를 실행합니다. - name: Test python project run: | poetry run python manage.py test