Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: CI/CD Pipeline

on:
pull_request:
branches: [ main, master ]
push:
branches: [ main, master ]
workflow_dispatch:

jobs:
# Quick checks for PRs - runs first and fast
quick-checks:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Install PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: "3.12"

- name: Install dependencies
run: |
pdm sync --group dev
pdm list

- name: Run Ruff check
run: pdm run ruff check

- name: Run Black check
run: pdm run black --check .

- name: Run tests (excluding OpenAI API test)
run: |
INFERENCE_API_TOKEN=dummy_token pdm run pytest -k "not test_receipt_analysis_with_chat"
env:
INFERENCE_API_TOKEN: dummy_token

# Comprehensive testing and quality checks
test:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python-version }}

- name: Cache PDM dependencies
uses: actions/cache@v3
with:
path: |
.pdm.toml
.venv
key: ${{ runner.os }}-pdm-${{ hashFiles('**/pdm.lock') }}
restore-keys: |
${{ runner.os }}-pdm-

- name: Install dependencies
run: |
pdm sync --group dev
pdm list

- name: Run tests with coverage
run: |
INFERENCE_API_TOKEN=dummy_token pdm run pytest --cov=src --cov-report=xml --cov-report=term-missing
env:
INFERENCE_API_TOKEN: dummy_token

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
fail_ci_if_error: false
continue-on-error: true
69 changes: 69 additions & 0 deletions .github/workflows/lint-format-write.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Lint and Format (Write Mode)

on:
workflow_dispatch:
inputs:
commit_message:
description: 'Commit message for formatting changes'
required: false
default: 'style: apply automatic formatting and linting fixes'
type: string

jobs:
lint-format-write:
# Only run on manual trigger, not on main/master branches
if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Need to fetch all history for git operations
fetch-depth: 0
# Need write permissions to push commits
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Install PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: "3.12"

- name: Install dependencies
run: |
pdm sync --group dev
pdm list

- name: Configure Git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"

- name: Run Ruff check and fix
run: pdm run ruff check --fix

- name: Run Black formatting
run: pdm run black .

- name: Check for changes
id: check_changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
echo "Files were modified by linting/formatting"
else
echo "changes=false" >> $GITHUB_OUTPUT
echo "No files were modified"
fi

- name: Commit and push changes
if: steps.check_changes.outputs.changes == 'true'
run: |
git add -A
git commit -m "${{ github.event.inputs.commit_message }}"
git push origin ${{ github.ref }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ cython_debug/
**/*.ipynb
*.jpg
*.png
!bin/*.jpg
bill.env
bin/export-tokens.sh
bin/docker-up.sh
Expand Down
Binary file added bin/20241128_183627.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading