Skip to content

Commit 84b7178

Browse files
authored
Adding testing workflow (#26)
* Adding testing workflow
1 parent c7c219d commit 84b7178

3 files changed

Lines changed: 120 additions & 1 deletion

File tree

‎.github/workflows/build.yml‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: buid
2+
run-name: build & test (invoked by ${{ github.actor }})
3+
4+
on: [push]
5+
6+
jobs:
7+
app-tests:
8+
runs-on: ubuntu-latest
9+
timeout-minutes: 15
10+
continue-on-error: false
11+
services:
12+
grumpy-db:
13+
image: kartoza/postgis:latest
14+
env:
15+
POSTGRES_USER: grumpy_user
16+
POSTGRES_PASS: grumpy_pwd
17+
POSTGRES_DBNAME: grumpy_db
18+
ALLOW_IP_RANGE: 0.0.0.0/0
19+
ports:
20+
- 5666:5432
21+
22+
steps:
23+
- uses: actions/checkout@v5
24+
25+
- name: "install python"
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version-file: ".python-version"
29+
30+
- name: "install uv"
31+
uses: astral-sh/setup-uv@v6
32+
with:
33+
enable-cache: true
34+
version: "0.9.1"
35+
36+
- name: "install project dependencies"
37+
run: |
38+
sudo apt-get update
39+
sudo apt-get install -y postgresql-client python3-gdal
40+
uv sync --locked --dev
41+
42+
- name: "run tests"
43+
env:
44+
DJANGO_ENVIRONMENT: "ci"
45+
DJANGO_SETTINGS_MODULE: "config.settings"
46+
DATABASE_URL: "postgis://grumpy_user:grumpy_pwd@localhost:5666/grumpy_db"
47+
run: uv run pytest

‎config/settings/ci.py‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
"""
2+
Custom settings for "ci" environment.
3+
"""
4+
5+
from .base import *
6+
7+
import logging
8+
9+
logger = logging.getLogger(__name__)
10+
11+
#########
12+
# setup #
13+
#########
14+
15+
env = environ.Env()
16+
17+
DEBUG = False
18+
SECRET_KEY = env("DJANGO_SECRET_KEY", default="shhh")
19+
20+
########
21+
# apps #
22+
########
23+
24+
INSTALLED_APPS += []
25+
26+
#############
27+
# databases #
28+
#############
29+
30+
# no changes needed in ci
31+
32+
########################
33+
# static & media Files #
34+
########################
35+
36+
37+
STORAGES = {
38+
"default": {"BACKEND": "grumpy.core.storages.LocalMediaStorage"},
39+
"staticfiles": {"BACKEND": "grumpy.core.storages.LocalStaticStorage"},
40+
}
41+
42+
STATIC_URL = "/static/"
43+
STATIC_ROOT = ROOT_DIR / "_static"
44+
45+
MEDIA_URL = "/media/"
46+
MEDIA_ROOT = ROOT_DIR / "_media"
47+
48+
##################
49+
# security, etc. #
50+
##################
51+
52+
ALLOWED_HOST = env("DJANGO_HOST", default="*")
53+
ALLOWED_HOSTS = [ALLOWED_HOST]
54+
CORS_ALLOW_ALL_ORIGINS = True
55+
56+
#########
57+
# Email #
58+
#########
59+
60+
# in ci, just use the console for email
61+
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
62+
63+
SERVER_EMAIL = PROJECT_EMAIL.format(role="grumpyoldmensbookclub")
64+
DEFAULT_FROM_EMAIL = (
65+
f"{PROJECT_NAME} <{PROJECT_EMAIL.format(role='grumpyoldmensbookclub')}>"
66+
)
67+
68+
###########
69+
# logging #
70+
###########
71+
72+
# no logging in ci

‎grumpy/books/management/commands/list_books.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Command(BaseCommand):
1515
help = "Outputs the number of books owned by users according to their statuses."
1616

1717
def add_arguments(self, parser):
18-
18+
1919
parser.add_argument(
2020
"--read", action="store_true", help=_("Only list read books.")
2121
)

0 commit comments

Comments
 (0)