test: verify CI/PR automation #6
This file contains hidden or 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: | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - 'backend/**/*.py' | |
| - 'backend/requirements.txt' | |
| - 'Dockerfile' | |
| - 'docker-compose.yml' | |
| - '.github/workflows/**' | |
| jobs: | |
| code-check: | |
| name: Code Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| pip install -r backend/requirements.txt flake8 | |
| - name: Get changed Python files | |
| id: changed | |
| run: | | |
| FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- '*.py' 'backend/**/*.py' || true) | |
| echo "files<<EOF" >> $GITHUB_OUTPUT | |
| echo "$FILES" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Syntax check | |
| run: | | |
| FILES="${{ steps.changed.outputs.files }}" | |
| if [ -n "$FILES" ]; then | |
| for f in $FILES; do | |
| if [ -f "$f" ]; then | |
| python -m py_compile "$f" || exit 1 | |
| fi | |
| done | |
| fi | |
| - name: Flake8 (critical errors only) | |
| run: | | |
| FILES="${{ steps.changed.outputs.files }}" | |
| if [ -n "$FILES" ]; then | |
| flake8 --select=E9,F63,F7,F82 $FILES || exit 1 | |
| fi | |
| - name: Module import test | |
| run: | | |
| cd backend | |
| python -c "from main import app" | |
| docker-build: | |
| name: Docker Build | |
| runs-on: ubuntu-latest | |
| needs: code-check | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Build Docker image | |
| run: docker build -t chatraw:test . | |
| - name: Smoke test | |
| run: docker run --rm chatraw:test python -c "print('✅ Docker OK')" |