Project Management/Github

code academy 학습 정리 1 - Django automated testing with GitHub Actions

bluebamus 2023. 6. 6.

영상 정보 : https://www.youtube.com/watch?v=qJPLFDtEi1I 

소스 정보 : https://github.com/veryacademy/YT-Django-GitHub-Actions-Testing

 

GitHub - veryacademy/YT-Django-GitHub-Actions-Testing

Contribute to veryacademy/YT-Django-GitHub-Actions-Testing development by creating an account on GitHub.

github.com

1. flake8

- root에 setup.cfg를 만들고 검사에 예외처리를 할 파일, 폴더를 명시할 수 있음

- 이외 최대 길이와 같은 추가 옵션을 정의할 수 있음

* black을 이용해 자동 수정을 추가하는 것도 가능할 듯

2. yml 정의

- 소스 : 

name: Django Tests

on:
  push:
    branches:
      - main
  
  pull_request:
    branches:
      - main

# on:
#   schedule:
#     - cron:  '*/15 * * * *'

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python 3.7    // 파이썬 설치
      uses: actions/setup-python@v2
      with:
        python-version: 3.7
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip   // pip을 이용한 패키지 설치
        pip install -r requirements.txt
    - name: Lint with flake8
      run: |
        pip install flake8    // flake 설치
        flake8
    - name: Coverage report    // coverage 설치 및 실행
      run: |
        pip install coverage
        coverage run manage.py test
        coverage report
    - name: Django Testing    // 유닛 테스트 실행
      run: |
        python3 manage.py test

댓글