Skip to content

Run tests

Run tests #110

Workflow file for this run

name: Run tests
on:
schedule:
# Weekly: once with local worker, once with cloud worker
- cron: '0 0 * * 0' # local worker
- cron: '0 1 * * 0' # cloud worker
workflow_dispatch:
inputs:
environment:
type: choice
description: 'Environment'
default: 'prod'
options:
- prod
- dev
- local
gpu:
type: boolean
description: 'Run job(s) with GPU (only supported in non-local environments)'
default: false
cloud:
type: boolean
description: 'Run job(s) with cloud worker'
default: false
userfacing_api_branch:
type: string
description: 'User-facing API branch (if environment==local)'
default: 'main'
workerfacing_api_branch:
type: string
description: 'Worker-facing API branch (if environment==local)'
default: 'main'
jobfetcher_branch:
type: string
description: 'Jobfetcher branch (if environment==local)'
default: 'main'
frontend_branch:
type: string
description: 'Frontend branch (if environment==local)'
default: 'main'
jobs:
run_tests:
runs-on: ubuntu-latest
timeout-minutes: 240
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11.10'
- name: Install poetry
run: |
POETRY_VERSION=$(grep -E '^requires-poetry = ' pyproject.toml | sed -E 's/requires-poetry = "(.*)"/\1/')
pip install poetry==$POETRY_VERSION
- name: Install dependencies
run: poetry install
- name: Clone repositories and checkout branches
if: ${{ github.event.inputs.environment == 'local' }}
run: |
PWD=$(pwd)
git clone https://github.com/ries-lab/DECODE_Cloud_UserAPI.git ../DECODE_Cloud_UserAPI
git clone https://github.com/ries-lab/DECODE_Cloud_WorkerAPI.git ../DECODE_Cloud_WorkerAPI
git clone https://github.com/ries-lab/DECODE_Cloud_JobFetcher.git ../DECODE_Cloud_JobFetcher
git clone https://github.com/ries-lab/DECODE_Cloud_UserFrontend.git ../DECODE_Cloud_UserFrontend
cd ../DECODE_Cloud_UserAPI
git checkout ${{ github.event.inputs.userfacing_api_branch }}
cd ../DECODE_Cloud_WorkerAPI
git checkout ${{ github.event.inputs.workerfacing_api_branch }}
cd ../DECODE_Cloud_JobFetcher
git checkout ${{ github.event.inputs.jobfetcher_branch }}
cd ../DECODE_Cloud_UserFrontend
git checkout ${{ github.event.inputs.frontend_branch }}
cd $PWD
mkdir ~/.aws
mkdir ./job_fetcher_data
- name: Run tests
env:
AWS_ACCESS_KEY_ID: ${{ secrets.TESTS_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.TESTS_AWS_SECRET_ACCESS_KEY }}
COGNITO_USER_POOL_ID: ${{ secrets.COGNITO_USER_POOL_ID }}
COGNITO_REGION: ${{ secrets.COGNITO_REGION }}
COGNITO_CLIENT_ID: ${{ secrets.COGNITO_CLIENT_ID }}
COGNITO_SECRET: ${{ secrets.COGNITO_SECRET }}
EMAIL: ${{ secrets.EMAIL }}
PASSWORD: ${{ secrets.PASSWORD }}
TEST_EMAIL: ${{ secrets.EMAIL }}
TEST_PASSWORD: ${{ secrets.PASSWORD }}
run: |
touch .env
CLOUD=""
CLOUD_ENABLED=false
GPU=""
GPU_ENABLED=false
if [ "${{ github.event_name }}" = "schedule" ]; then
if [ $((${{ github.run_number }} % 2)) -eq 1 ]; then
CLOUD="--cloud"
CLOUD_ENABLED=true
fi
GPU="--gpu"
GPU_ENABLED=true
fi
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
if [ "${{ github.event.inputs.cloud }}" = "true" ]; then
CLOUD=--cloud
CLOUD_ENABLED=true
fi
if [ "${{ github.event.inputs.gpu }}" = "true" ]; then
GPU=--gpu
GPU_ENABLED=true
fi
fi
ENVIRONMENT=--${{ github.event.inputs.environment || 'prod' }}
echo "## 🧪 Test Configuration" >> $GITHUB_STEP_SUMMARY
echo "**Environment**: \`${{ github.event.inputs.environment || 'prod' }}\`" >> $GITHUB_STEP_SUMMARY
echo "**GPU enabled**: \`$GPU_ENABLED\`" >> $GITHUB_STEP_SUMMARY
echo "**Cloud worker**: \`$CLOUD_ENABLED\`" >> $GITHUB_STEP_SUMMARY
poetry run pytest tests/ $ENVIRONMENT $CLOUD $GPU