Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI #64

Closed
wants to merge 3 commits into from
Closed

CI #64

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI

# Enable Buildkit and let compose use it to speed up image building
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1

on:
pull_request:
branches: ['main']

push:
branches: ['main']

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
pytest:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:12
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres

env:
DATABASE_URL: 'postgres://postgres:postgres@localhost:5432/postgres'

steps:
- name: Checkout Code Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: pip
cache-dependency-path: requirements-dev.txt

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt

- name: Test with pytest
run: pytest
58 changes: 58 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
default_stages: [commit]


repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: detect-private-key

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.9-for-vscode
hooks:
- id: prettier
args: ['--tab-width', '2', '--single-quote']
exclude: 'templates/'

- repo: https://github.com/adamchainz/django-upgrade
rev: '1.13.0'
hooks:
- id: django-upgrade
args: ['--target-version', '4.1']

- repo: https://github.com/asottile/pyupgrade
rev: v3.4.0
hooks:
- id: pyupgrade
args: [--py311-plus]

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8

# sets up .pre-commit-ci.yaml to ensure pre-commit dependencies stay up to date
ci:
autoupdate_schedule: weekly
skip: []
submodules: false
12 changes: 6 additions & 6 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from oauth2_provider.models import Application
from rest_framework.test import APIClient

from users.factories import UserFactory, FCMDeviceFactory
from messaging.factories import ServerFactory
from users.factories import FCMDeviceFactory, UserFactory


@pytest.fixture
def user(db):
Expand All @@ -27,7 +27,7 @@ def auth_device(user, api_client):
"""
Create the Basic Authentication credentials for the test user.
"""
credentials = f"{user.username}:testpass".encode("utf-8")
credentials = f"{user.username}:testpass".encode()
base64_credentials = base64.b64encode(credentials).decode("utf-8")
cred = f"Basic {base64_credentials}"
api_client.credentials(HTTP_AUTHORIZATION=cred)
Expand All @@ -50,7 +50,7 @@ def oauth_app(user):

@pytest.fixture
def authed_client(api_client, oauth_app):
auth = f'{oauth_app.client_id}:{oauth_app.raw_client_secret}'.encode('utf-8')
credentials = base64.b64encode(auth).decode('utf-8')
api_client.defaults['HTTP_AUTHORIZATION'] = 'Basic ' + credentials
auth = f"{oauth_app.client_id}:{oauth_app.raw_client_secret}".encode()
credentials = base64.b64encode(auth).decode("utf-8")
api_client.defaults["HTTP_AUTHORIZATION"] = "Basic " + credentials
return api_client
2 changes: 1 addition & 1 deletion connectid/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'connectid.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "connectid.settings")

application = get_asgi_application()
21 changes: 9 additions & 12 deletions connectid/localsettings.example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-yofpqrszrdtv0ftihjd09cuim2al9^n9j^b85%-y0v*^_lj18d'
SECRET_KEY = "django-insecure-yofpqrszrdtv0ftihjd09cuim2al9^n9j^b85%-y0v*^_lj18d"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand All @@ -8,20 +8,17 @@
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'connect',
'USER': 'connect',
'PASSWORD': 'connect',
'HOST': 'localhost',
'PORT': '5433'
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "connect",
"USER": "connect",
"PASSWORD": "connect",
"HOST": "localhost",
"PORT": "5433",
}
}

ALLOWED_HOSTS = [
'127.0.0.1',
'localhost'
]
ALLOWED_HOSTS = ["127.0.0.1", "localhost"]

TWILIO_ACCOUNT_SID = None
TWILIO_AUTH_TOKEN = None
Expand Down
Loading
Loading