Skip to content
Merged
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
57 changes: 57 additions & 0 deletions .github/workflows/django-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Django CI

on:
push:
branches: [main, phase-1-ci-validation]
pull_request:
branches: [main]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: django-ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: Tests and Django checks
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: requirements.txt

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

- name: Run Django tests
env:
DJANGO_DEBUG: "False"
DJANGO_SECRET_KEY: ci-only-not-a-production-secret
DJANGO_ALLOWED_HOSTS: localhost,127.0.0.1,testserver
run: python manage.py test

- name: Run Django system check
env:
DJANGO_DEBUG: "False"
DJANGO_SECRET_KEY: ci-only-not-a-production-secret
DJANGO_ALLOWED_HOSTS: localhost,127.0.0.1,testserver
run: python manage.py check

- name: Check for missing migrations
env:
DJANGO_DEBUG: "False"
DJANGO_SECRET_KEY: ci-only-not-a-production-secret
DJANGO_ALLOWED_HOSTS: localhost,127.0.0.1,testserver
run: python manage.py makemigrations --check --dry-run
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ Open http://127.0.0.1:8000/ and create an account.

## Tests and checks

GitHub Actions runs the test suite, Django system check, and migration consistency check on pull requests to `main` and pushes to `main`. See `.github/workflows/django-ci.yml`.

Run the project's Django tests:

```bash
Expand Down
3 changes: 2 additions & 1 deletion notes/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.contrib.auth import get_user_model
from django.core.management import call_command
from django.test import TestCase
from django.test import TestCase, override_settings
from django.urls import reverse
from django.utils import timezone

Expand Down Expand Up @@ -279,6 +279,7 @@ def test_parse_tags(self):
self.assertEqual(parse_tags(" Work , #ideas,WORK,, "), ["work", "ideas"])
self.assertEqual(parse_tags(""), [])

@override_settings(DEBUG=False)
def test_error_pages_render(self):
self.assertEqual(self.client.get("/definitely-missing/").status_code, 404)
self.assertContains(self.client.get("/definitely-missing/"), "Note not found", status_code=404)
29 changes: 29 additions & 0 deletions templates/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="dark">
<meta name="theme-color" content="#12100d">
<title>{% block title %}Something went wrong – Ember{% endblock %}</title>
<style>
:root { color-scheme: dark; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #12100d; color: #f1eadd; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 24px; }
main { width: min(100%, 520px); text-align: center; padding: 44px 28px; border: 1px solid #383026; border-radius: 20px; background: #1a1712; box-shadow: 0 24px 80px #0006; }
.code { color: #f2701d; font-size: 13px; font-weight: 800; letter-spacing: .22em; }
h1 { margin: 14px 0 10px; font-size: clamp(26px, 6vw, 36px); line-height: 1.15; }
p { color: #b8ad9b; line-height: 1.65; margin: 0 0 26px; }
a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 18px; border-radius: 10px; background: #f2701d; color: #1a0e05; text-decoration: none; font-weight: 700; }
a:focus-visible { outline: 3px solid #f1eadd; outline-offset: 4px; }
</style>
</head>
<body>
<main>
<div class="code">{% block code %}ERROR{% endblock %}</div>
<h1>{% block heading %}Something went wrong{% endblock %}</h1>
<p>{% block text %}The page could not be loaded. Please try again.{% endblock %}</p>
<a href="/">Back to Ember</a>
</main>
</body>
</html>
Loading