Skip to content

Commit

Permalink
feat: add support for base [email protected] to django and flask extensions (
Browse files Browse the repository at this point in the history
#708)

* Add support for base [email protected] to django and flask extensions

* put the spread tests for django where they are run

* Remove the rockcraft.yaml and prune docker in spread test

* add ignore imports in spread test for Django

* update doc for new 24.04 base

* typo in docs
  • Loading branch information
javierdelapuente authored Sep 16, 2024
1 parent 919010c commit e47860c
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/reference/extensions/django-framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ A statsd-exporter is installed alongside the Gunicorn server to export Gunicorn
server metrics.

.. note::
The Django extension is compatible with the ``bare`` and ``[email protected]``
bases.
The Django extension is compatible with the ``bare``, ``[email protected]``
and ``[email protected]`` bases.

Project requirements
====================
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/extensions/flask-framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ A statsd-exporter is installed alongside the Gunicorn server to export Gunicorn
server metrics.

.. note::
The Flask extension is compatible with the ``bare`` and ``[email protected]``
bases.
The Flask extension is compatible with the ``bare``, ``[email protected]``
and ``[email protected]`` bases.

Project requirements
====================
Expand Down
2 changes: 1 addition & 1 deletion rockcraft/extensions/gunicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class _GunicornBase(Extension):
@override
def get_supported_bases() -> tuple[str, ...]:
"""Return supported bases."""
return "bare", "[email protected]", "ubuntu:22.04"
return "bare", "[email protected]", "ubuntu:22.04", "[email protected]"

@staticmethod
@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

import os

from django.core.asgi import get_asgi_application
from django.core.asgi import ( # pyright: ignore[reportMissingImports]
get_asgi_application,
)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example_django.settings")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.contrib import admin
from django.urls import path
from django.contrib import admin # pyright: ignore[reportMissingImports]
from django.urls import path # pyright: ignore[reportMissingImports]

urlpatterns = [
path("admin/", admin.site.urls),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

import os

from django.core.wsgi import get_wsgi_application
from django.core.wsgi import ( # pyright: ignore[reportMissingImports]
get_wsgi_application,
)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example_django.settings")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ def main():
"""Run administrative tasks."""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example_django.settings")
try:
from django.core.management import execute_from_command_line
from django.core.management import ( # pyright: ignore[reportMissingImports]
execute_from_command_line,
)
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
summary: django extension test

environment:
SCENARIO/base_2204: ubuntu-22.04
SCENARIO/base_2404: ubuntu-24.04
ROCKCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS: "true"

execute: |
run_rockcraft init --name example-django --profile django-framework
sed -i "s/base: .*/base: ${SCENARIO//-/@}/g" rockcraft.yaml
run_rockcraft pack
test -f example-django_0.1_amd64.rock
Expand Down Expand Up @@ -34,3 +39,5 @@ restore: |
rm -f example-django_0.1_amd64.rock
docker rmi -f example-django
docker rm -f example-django-container
rm -f "*.rock" rockcraft.yaml
docker system prune -a -f
1 change: 1 addition & 0 deletions tests/spread/rockcraft/extension-flask/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ summary: flask extension test
environment:
SCENARIO/bare: bare
SCENARIO/base_2204: ubuntu-22.04
SCENARIO/base_2404: ubuntu-24.04
execute: |
NAME="flask-${SCENARIO//./-}"
ROCK_FILE="${NAME}_0.1_amd64.rock"
Expand Down

0 comments on commit e47860c

Please sign in to comment.