네이버 지하철 DB 버전 갱신 #718
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
- push | |
- pull_request | |
jobs: | |
check-coding-convention: | |
name: Check Coding Convention | |
runs-on: ubuntu-latest | |
steps: | |
# Set-up | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
# Install Dependencies | |
- name: Install Checkers | |
run: pip install black ruff | |
# Lint | |
- name: Check coding convention | |
run: ruff check yui tests | |
- name: Check missing autofix | |
run: black --check . | |
test-program: | |
name: Test Program | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:16 | |
env: | |
POSTGRES_USER: kirito | |
POSTGRES_PASSWORD: eugeo | |
POSTGRES_DB: test | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
valkey: | |
image: valkey/valkey:latest | |
ports: | |
- 6379:6379 | |
steps: | |
# Set-up | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
- name: Setup Poetry | |
run: | | |
pipx install --python $(which python) poetry | |
poetry config virtualenvs.create true | |
poetry config virtualenvs.in-project true | |
- name: Install dependencies | |
run: | | |
python -m venv .venv | |
.venv/bin/pip install --upgrade pip setuptools wheel | |
poetry install --all-extras | |
echo "$(pwd)/.venv/bin" >> $GITHUB_PATH | |
# Type Check | |
- name: Check static types | |
run: mypy yui | |
# Test | |
- name: Run test cases | |
run: pytest -W always::DeprecationWarning -v --cov=yui --cov-report=xml --junitxml=junit.xml tests | |
env: | |
SQLALCHEMY_WARN_20: 1 | |
YUI_TEST_DATABASE_URL: postgresql+psycopg://kirito:eugeo@localhost/test | |
GOOGLE_API_KEY: ${{ secrets.TEST_GOOGLE_API_KEY }} | |
NAVER_CLIENT_ID: ${{ secrets.TEST_NAVER_CLIENT_ID }} | |
NAVER_CLIENT_SECRET: ${{ secrets.TEST_NAVER_CLIENT_SECRET }} | |
# After jobs | |
- name: Export requirements.txt for docker build | |
run: | | |
poetry export -f requirements.txt --output requirements.txt --without-hashes | |
- name: Archive requirements.txt file | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-deps | |
path: requirements.txt | |
- name: Upload coverage | |
if: ${{ !cancelled() }} | |
uses: codecov/codecov-action@v5 | |
with: | |
files: ./coverage.xml | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Upload test results to Codecov | |
if: ${{ !cancelled() }} | |
uses: codecov/test-results-action@v1 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: [check-coding-convention, test-program] | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker BuildX | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: item4 | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Fetch stored requirements.txt | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-deps | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: item4/yui:latest | |
cache-from: type=registry,ref=item4/yui:latest | |
cache-to: type=inline |