name: CI/CD Pipeline on: push: branches: [ main, develop ] pull_request: branches: [ main ] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.10' - name: Cache pip dependencies uses: actions/cache@v3 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install pytest pytest-cov - name: Run tests run: | pytest --cov=. --cov-report=xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: file: ./coverage.xml fail_ci_if_error: false lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.10' - name: Install dependencies run: | python -m pip install --upgrade pip pip install flake8 black - name: Run Black run: black --check . - name: Run Flake8 run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics build: needs: [test, lint] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.10' - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt - name: Test app import run: | python -c "import app; print('App imports successfully')" python -c "from classifier import AIPapersIntelligenceClassifier; print('Classifier imports successfully')" python -c "import ranker; print('Ranker imports successfully')" python -c "import data_fetcher; print('Data fetcher imports successfully')" python -c "import model_manager; print('Model manager imports successfully')" deploy-huggingface: needs: [build] runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' && github.event_name == 'push' steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Push to Hugging Face env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | git config --global user.email "github-actions@github.com" git config --global user.name "github-actions" git remote add hf https://huggingface.co/spaces/nellaivijay/ai-papers-intelligence-classifier git push hf main --force