Add ML CI Pipeline workflow configuration #7
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: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.11.3" | |
| - name: Install Python Virtual Environment | |
| run: pip3 install virtualenv | |
| # Cache Virtual Envrionment step | |
| - name: Virtual Environment | |
| uses: actions/cache@v3 | |
| id: cache-venv | |
| with: | |
| path: .venv | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install Dependencies | |
| run: | | |
| if [ ! -d ".venv" ]; then | |
| python3 -m venv .venv | |
| fi | |
| source .venv/bin/activate | |
| pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Lint with flake8 | |
| run: | | |
| flake8 . --max-line-length=150 --exclude .venv,venv,__pycache__,Models | |
| - name: Run pytest | |
| run: | | |
| if [ -d tests ] || ls -1 test_*.py 2>/dev/null | grep -q . ; then | |
| pytest -q | |
| else | |
| echo "No tests found, skipping pytest" | |
| fi | |