Add ML CI Pipeline workflow configuration #8
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: ML CI Pipeline | |
| on: | |
| push: | |
| branches: ["test", "dev", "main"] | |
| pull_request: | |
| branches: ["test", "dev", "main"] | |
| jobs: | |
| lint-and-test: | |
| name: Lint, Format-check and Test | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: [3.10, 3.11] | |
| 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: Cache pip | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install project deps and CI tools | |
| run: | | |
| python -m pip install --upgrade pip | |
| if [ -f requirements.txt ]; then python -m pip install -r requirements.txt; fi | |
| # install tooling used by CI | |
| python -m pip install flake8 pytest black ruff | |
| - name: Verify linters installed | |
| run: | | |
| python -m pip show flake8 || true | |
| python -m flake8 --version || true | |
| python -m ruff --version || true | |
| python -m black --version || true | |
| - name: Run ruff (fast linter) | |
| run: | | |
| python -m ruff check . | |
| - name: Check formatting with black | |
| run: | | |
| python -m black --check . | |
| - name: Lint with flake8 | |
| run: | | |
| # run via python -m to avoid PATH/entrypoint issues | |
| python -m flake8 . --max-line-length=150 --exclude .venv,venv,__pycache__,Models | |
| - name: Run pytest (if tests exist) | |
| run: | | |
| if [ -d tests ] || ls -1 test_*.py 2>/dev/null | grep -q . ; then | |
| python -m pytest -q | |
| else | |
| echo "No tests found, skipping pytest" | |
| fi | |