Adding workflows for unit tests and linting #1
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
name: Run Unit Tests | |
# When the workflow will be triggered | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
test: | |
runs-on: ubuntu-latest # You can use ubuntu, macos, or windows depending on your project needs | |
services: | |
postgres: | |
image: postgres:13 # Use the latest version of PostgreSQL you need | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: pw | |
POSTGRES_DB: testdb | |
options: >- | |
--health-cmd "pg_isready -U testuser" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
# Step 1: Check out the repository | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Step 2: Set up Python | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' # Specify your Python version | |
# Step 3: Install dependencies | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
# Step 4: Wait for PostgreSQL to be ready | |
- name: Wait for PostgreSQL to be ready | |
run: | | |
until pg_isready -h localhost -p 5432 -U postgres; do | |
echo "Waiting for PostgreSQL to be ready..." | |
sleep 1 | |
done | |
# Step 5: Run the tests (you may need to adjust this depending on your test setup) | |
- name: Run unit tests | |
env: | |
MPI_DB_TYPE: postgres | |
MPI_DBNAME: testdb | |
MPI_HOST: localhost | |
MPI_PORT: 5432 | |
MPI_USER: postgres | |
MPI_PASSWORD: pw | |
run: | | |
pytest tests/unit |