Syed Arfan
Add GitHub Actions CI/CD pipeline
08367f3
# GitHub Actions Workflow for Sentiment API
# This runs automatically on every push and pull request
# Ensures code quality through automated testing
name: Test and Build
# When to run this workflow
on:
push:
branches: [ main ] # Run on pushes to main
pull_request:
branches: [ main ] # Run on PRs to main
# Define the jobs to run
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest # Use Ubuntu Linux environment
steps:
# Step 1: Get the code from repository
- name: Checkout code
uses: actions/checkout@v4
# Step 2: Set up Python environment
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
# Step 3: Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# Step 4: Run tests with pytest
- name: Run tests
run: |
pytest tests/ -v --tb=short
# Step 5: Verify Docker build works
- name: Test Docker build
run: |
docker build -t sentiment-api:test .