Update react monorepo #1106
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: Pytest | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
permissions: | |
contents: read | |
jobs: | |
pytest: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./backend | |
services: | |
postgres: | |
image: timescale/timescaledb:latest-pg14 | |
env: | |
POSTGRES_USER: lotus | |
POSTGRES_PASSWORD: lotus | |
SSLMODE: PREFER | |
ports: | |
- 5432:5432 | |
# needed because the postgres container does not provide a healthcheck | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
redis: | |
image: redis | |
ports: | |
- 6379:6379 | |
# Set health checks to wait until redis has started | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
environment: Development | |
env: | |
DJANGO_SETTINGS_MODULE: "lotus.settings" | |
PYTHONPATH: "." | |
SECRET_KEY: "${{ secrets.SECRET_KEY }}" | |
STRIPE_LIVE_SECRET_KEY: "${{ secrets.STRIPE_LIVE_SECRET_KEY }}" | |
STRIPE_TEST_SECRET_KEY: "${{ secrets.STRIPE_TEST_SECRET_KEY }}" | |
DEBUG: False | |
KAFKA_URL: "localhost:9092" | |
PYTHONDONTWRITEBYTECODE: 1 | |
SELF_HOSTED: "${{ secrets.SELF_HOSTED }}" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: start redpanda | |
uses: redpanda-data/[email protected] | |
with: | |
version: "latest" | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.9" | |
- name: Install poetry | |
run: | | |
python -m pip install --upgrade poetry wheel | |
- id: cache-poetry | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pypoetry | |
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} | |
- name: Install dependencies | |
if: steps.cache-poetry.outputs.cache-hit != 'true' | |
run: | | |
poetry install | |
- name: Migrate | |
run: | | |
poetry run python manage.py migrate --noinput | |
- name: Run tests with coverage | |
run: | | |
for i in 1 2 3; do | |
if poetry run pytest -x --cov=. --cov-report term-missing --cov-fail-under=30; then | |
export PYTEST_COVERAGE_SUCCEEDED=true | |
break | |
else | |
export PYTEST_COVERAGE_SUCCEEDED=false | |
fi | |
sleep 5s | |
done | |
if [[ "${PYTEST_COVERAGE_SUCCEEDED}" == "true" ]]; then | |
echo "Pytest succeeded" | |
else | |
echo "Pytest failed" | |
exit 1 | |
fi | |
env: | |
RETRY_DESCRIPTION: "Running tests with coverage" | |
- name: Test Setup Tasks | |
run: | | |
poetry run python manage.py setup_tasks |