DB and API Refactors #165
Workflow file for this run
This file contains 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
# This workflow will install Python dependencies, run tests and lint with a single version of Python | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
name: Ansari CICD | |
on: | |
push: | |
branches: [ "api-v2", "main" ] | |
pull_request: | |
branches: [ "api-v2", "main" ] | |
permissions: | |
contents: read | |
jobs: | |
ansari-container-job: | |
runs-on: ubuntu-latest | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
KALEMAT_API_KEY: ${{ secrets.KALEMAT_API_KEY }} | |
VECTARA_API_KEY: ${{ secrets.VECTARA_API_KEY }} | |
MAWSUAH_VECTARA_CORPUS_KEY: ${{ secrets.MAWSUAH_VECTARA_CORPUS_KEY }} | |
TAFSIR_VECTARA_CORPUS_KEY: ${{ secrets.TAFSIR_VECTARA_CORPUS_KEY }} | |
QURAN_DOT_COM_API_KEY: ${{ secrets.QURAN_DOT_COM_API_KEY }} | |
WHATSAPP_RECIPIENT_WAID: ${{ secrets.WHATSAPP_RECIPIENT_WAID }} | |
WHATSAPP_API_VERSION: ${{ secrets.WHATSAPP_API_VERSION }} | |
WHATSAPP_BUSINESS_PHONE_NUMBER_ID: ${{ secrets.WHATSAPP_BUSINESS_PHONE_NUMBER_ID }} | |
WHATSAPP_TEST_BUSINESS_PHONE_NUMBER_ID: ${{ secrets.WHATSAPP_TEST_BUSINESS_PHONE_NUMBER_ID }} | |
WHATSAPP_ACCESS_TOKEN_FROM_SYS_USER: ${{ secrets.WHATSAPP_ACCESS_TOKEN_FROM_SYS_USER }} | |
WHATSAPP_VERIFY_TOKEN_FOR_WEBHOOK: ${{ secrets.WHATSAPP_VERIFY_TOKEN_FOR_WEBHOOK }} | |
PYTHONPATH: src | |
container: python:3.10 | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_PASSWORD: postgres | |
PGPASSWORD: postgres | |
ports: | |
# Using non-default Postgres port to avoid conflicts between local DB and local GitHub Actions testing using `act` | |
- "5433:5432" | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
- name: Install uv | |
run: | | |
pip install uv | |
# TODO(abdullah): create a venv using uv | |
- name: Install dependencies | |
run: | | |
uv pip install --system ruff pytest pytest-asyncio pytest-cov | |
if [ -f requirements.txt ]; then uv pip install --system -r requirements.txt; fi | |
- name: Install PostgreSQL client | |
run: | | |
apt-get update | |
apt-get install --yes --no-install-recommends postgresql-client | |
- name: Create tables | |
env: | |
PGPASSWORD: postgres | |
POSTGRES_PASSWORD: postgres | |
run: | | |
for sql_file in sql/*.sql; do | |
psql -h postgres -p 5432 -U postgres -d postgres -f "$sql_file" | |
done | |
- name: Lint with ruff | |
run: | | |
# stop the build if there are lint errors | |
ruff check . --config pyproject.toml --output-format=github | |
- name: Test with pytest | |
env: | |
PGPASSWORD: postgres | |
POSTGRES_PASSWORD: postgres | |
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/postgres | |
SECRET_KEY: "secret" # This is a required field. Setting it to a random value to pass the tests. | |
run: | | |
pytest --capture=tee-sys --cov=. |