Refactor Code #290
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 Django Tests | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
pull_request: | |
branches: | |
- main | |
- develop | |
jobs: | |
test: | |
name: Run Django Tests | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:13.4 | |
env: | |
POSTGRES_DB: github_actions | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
ports: | |
- "5432:5432" | |
options: | |
--mount type=tmpfs,destination=/var/lib/postgresql/data/ | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
- name: Set up Python 3.10.8 | |
uses: actions/setup-python@v1 | |
with: | |
python-version: 3.10.8 | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: latest | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v2 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --no-root | |
- name: Install library | |
run: poetry install --no-interaction | |
- name: Run tests | |
run: | | |
source .venv/bin/activate | |
pytest --runslow --cache-clear --durations 20 --cov=./ --cov-report=xml | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_BASE_BUCKET_ADDRESS: ${{ secrets.AWS_BASE_BUCKET_ADDRESS }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_STORAGE_BUCKET_NAME: ${{ secrets.AWS_STORAGE_BUCKET_NAME }} | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
DEFAULT_FROM_EMAIL_SES: ${{ secrets.DEFAULT_FROM_EMAIL_SES }} | |
DJANGO_ADMIN_LOGIN_PATH: ${{ secrets.DJANGO_ADMIN_LOGIN_PATH }} | |
EMAIL_HOST_PASSWORD_SES: ${{ secrets.EMAIL_HOST_PASSWORD_SES }} | |
EMAIL_HOST_SES: ${{ secrets.EMAIL_HOST_SES }} | |
EMAIL_HOST_USER_SES: ${{ secrets.EMAIL_HOST_USER_SES }} | |
FIELD_ENCRYPTION_KEY: ${{ secrets.FIELD_ENCRYPTION_KEY }} | |
OD_API_BASE_URL: ${{ secrets.OD_API_BASE_URL }} | |
OD_APPLICATION_ID: ${{ secrets.OD_APPLICATION_ID }} | |
OD_APPLICATION_KEY_1: ${{ secrets.OD_APPLICATION_KEY_1 }} | |
PYTEST_TEST_PASSWORD: ${{ secrets.PYTEST_TEST_PASSWORD }} | |
RECAPTCHA_PRIVATE_KEY: ${{ secrets.RECAPTCHA_PRIVATE_KEY }} | |
RECAPTCHA_PUBLIC_KEY: ${{ secrets.RECAPTCHA_PUBLIC_KEY }} | |
REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }} | |
REDIS_URL: ${{ secrets.REDIS_URL }} | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
SES_ACCESS_KEY: ${{ secrets.SES_ACCESS_KEY }} | |
SES_SECRET_KEY: ${{ secrets.SES_SECRET_KEY }} | |
DJANGO_SETTINGS_MODULE: ${{ secrets.DJANGO_SETTINGS_MODULE }} | |
SYSTEM_ENV: GITHUB_RUN_ID | |
- name: Upload Coverage Report to Codecov.io | |
uses: codecov/codecov-action@v1 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: ./coverage.xml | |
flags: unittests |