Bump docker/setup-qemu-action from 2 to 3 #678
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: Django CI | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
DJANGO_FIELD_ENCRYPTION_KEY: v6AYhriFBEktgOrXXdKK0X4IU6noDCfSbqPxJ1fIoW0= | |
DJANGO_SECRET_KEY: django-insecure-@o-)qrym-cn6_*mx8dnmy#m4*$j%8wyy+l=)va&pe)9e7@o4i) | |
REDIS_URL: redis://localhost:6379 | |
TEST_DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres | |
DJANGO_SETTINGS_MODULE: botweb.settings.test | |
# right now, some tests rely on the ability to pull a valid user config from the ENV | |
# let's make sure `config` doesn't throw an exception in this case. Since the cassettes | |
# are recorded when there is a valid ENV-based user configuration we only need to worry | |
# about this in CI | |
USER_PREFERENCES: '{"livemode":true}' | |
USER_BINANCE_API_KEY: "" | |
USER_BINANCE_SECRET_KEY: "" | |
COINMARKETCAP_API_KEY: "" | |
services: | |
redis: | |
image: redis | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
# Maps port 6379 on service container to the host | |
- 6379:6379 | |
postgres: | |
image: postgres | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_PASSWORD: postgres | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9.13 | |
# https://stackoverflow.com/questions/62977821/how-to-cache-poetry-install-for-github-actions | |
- name: Install poetry | |
uses: snok/[email protected] | |
with: | |
version: 1.1.14 | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} | |
- name: Install dependencies | |
run: poetry install | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
# - name: lint | |
# run: | | |
# source .venv/bin/activate | |
# pylint **/*.py | |
- name: code formatting | |
run: | | |
set -eax | |
source .venv/bin/activate | |
black --version | |
black --check . | |
isort **/*.py -c -v | |
- name: Setup node.js (for pyright) | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "17" | |
- name: Run type checking | |
run: | | |
npm install --location=global pyright@latest | |
source .venv/bin/activate | |
pyright . | |
- name: Run DB migrations | |
run: | | |
source .venv/bin/activate | |
python manage.py migrate | |
- name: Run Tests | |
run: | | |
source .venv/bin/activate | |
pytest |