CI Template: Python Application
기본으로 pytest를 테스트프레임웍으로 설치
우리는 unittest로 작성힘
Python code linting tool: flake8
문법 에러와 코딩 스타일 체크
테스트 코드 실행 방법
unnittest를 사용 (pytest 라는 대안도 있음)
메인메소드 정해지지 않은 경우 vs. 메인메소드 정해진 경우
python -m unittest test.py # 혹은 python3 test.py
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python application
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with unittest
run: |
python -m unittest discover -p 'test*.py'
커밋하고 변경을 새로운 PR로 생성
PR에서 머지하고 해당 브랜치 삭제
테스트 추가
Template: Docker Image

'데브코스 데이터엔지니어링' 카테고리의 다른 글
| 라이브러리 import (0) | 2024.11.26 |
|---|---|
| Docker Hello World 프로그램 실습 (2) | 2024.11.21 |
| Hangman 웹서비스 Docker로 구동해보기 (1) | 2024.11.21 |
| Docker Network voting application 예제 프로그램 (2) compose 사용 (0) | 2024.11.19 |
| Docker Compose란? (1) | 2024.11.19 |