From fba4f1c9af90694db591d2255bc0002d294862c6 Mon Sep 17 00:00:00 2001 From: Tiago Nobrega Date: Mon, 6 May 2024 13:23:33 -0300 Subject: [PATCH] feat(flask): remove experimental flag for flask-framework extension (#522) (#560) Co-authored-by: David Andersson <51036209+jdkandersson@users.noreply.github.com> --- docs/reference/rockcraft.yaml.rst | 2 +- rockcraft/extensions/gunicorn.py | 8 +++++++- tests/spread/rockcraft/extension-flask/task.yaml | 8 +++----- tests/unit/extensions/test_gunicorn.py | 3 +-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/docs/reference/rockcraft.yaml.rst b/docs/reference/rockcraft.yaml.rst index 8886a544a..9a7fe0ddb 100644 --- a/docs/reference/rockcraft.yaml.rst +++ b/docs/reference/rockcraft.yaml.rst @@ -259,7 +259,7 @@ Extensions to enable when building the ROCK. Currently supported extensions: -- ``flask`` (experimental) +- ``flask-framework`` Example ======= diff --git a/rockcraft/extensions/gunicorn.py b/rockcraft/extensions/gunicorn.py index 2d3fc4a09..a6db1eb63 100644 --- a/rockcraft/extensions/gunicorn.py +++ b/rockcraft/extensions/gunicorn.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -"""An experimental extension for the Gunicorn based Python WSGI application extensions.""" +"""An extension for the Gunicorn based Python WSGI application extensions.""" import abc import ast import fnmatch @@ -188,6 +188,12 @@ def framework(self) -> str: """Return the wsgi framework name, e.g. flask, django.""" return "flask" + @staticmethod + @override + def is_experimental(base: str | None) -> bool: + """Check if the extension is in an experimental state.""" + return False + @override def gen_install_app_part(self) -> Dict[str, Any]: source_files = [f.name for f in sorted(self.project_root.iterdir())] diff --git a/tests/spread/rockcraft/extension-flask/task.yaml b/tests/spread/rockcraft/extension-flask/task.yaml index 62edff5c1..f40d93292 100644 --- a/tests/spread/rockcraft/extension-flask/task.yaml +++ b/tests/spread/rockcraft/extension-flask/task.yaml @@ -1,8 +1,6 @@ summary: flask extension test execute: | - export ROCKCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=true - run_rockcraft init --name flask-extension --profile flask-framework run_rockcraft pack @@ -15,15 +13,15 @@ execute: | sudo /snap/rockcraft/current/bin/skopeo --insecure-policy copy oci-archive:flask-extension_0.1_amd64.rock docker-daemon:flask-extension:latest # Ensure container exists docker images flask-extension | MATCH "flask-extension" - + # ensure container doesn't exist docker rm -f flask-extension-container - + # test the flask project is ready to run inside the container docker run --rm --entrypoint /bin/python3 flask-extension -m gunicorn --chdir /flask/app --check-config app:app docker run --rm --entrypoint /bin/python3 flask-extension -c "import pathlib;assert pathlib.Path('/flask/app/static/js/test.js').is_file()" docker run --rm --entrypoint /bin/python3 flask-extension -c "import pathlib;assert not pathlib.Path('/flask/app/node_modules').exists()" - + # test the default flask service docker run --name flask-extension-container -d -p 8137:8000 flask-extension retry -n 5 --wait 2 curl localhost:8137 diff --git a/tests/unit/extensions/test_gunicorn.py b/tests/unit/extensions/test_gunicorn.py index ae620893d..ae3a29cf5 100644 --- a/tests/unit/extensions/test_gunicorn.py +++ b/tests/unit/extensions/test_gunicorn.py @@ -21,8 +21,7 @@ @pytest.fixture -def flask_extension(mock_extensions, monkeypatch): - monkeypatch.setenv("ROCKCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS", "1") +def flask_extension(mock_extensions): extensions.register("flask-framework", extensions.FlaskFramework)