Skip to content

Commit

Permalink
Merge branch 'main' into ROCKS-936/make-rockcraft-pull-chisel-at-pack…
Browse files Browse the repository at this point in the history
…-time
  • Loading branch information
Linostar authored Oct 23, 2024
2 parents 188c0f3 + 6939aba commit 0125e7d
Show file tree
Hide file tree
Showing 27 changed files with 1,639 additions and 170 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,9 @@ jobs:
- name: Run codespell
run: |
make test-codespell
- name: Run flake8
run: |
make test-flake8
- name: Run mypy
run: |
make test-mypy
- name: Run pydocstyle
run: |
make test-pydocstyle
- name: Run pyright
run: |
sudo snap watch --last=install
Expand Down
11 changes: 1 addition & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ autoformat: ## Run automatic code formatters.
ifndef RUFF
$(error "Ruff not installed. Install it with `sudo snap install ruff` or using the official installation instructions: https://docs.astral.sh/ruff/installation/")
endif
autoflake rockcraft/ tests/
black .
ruff check --fix-only rockcraft tests

Expand Down Expand Up @@ -74,7 +73,7 @@ install: clean ## Install python package.
python setup.py install

.PHONY: lint
lint: test-black test-codespell test-flake8 test-mypy test-pydocstyle test-pyright test-ruff test-sphinx-lint test-shellcheck ## Run all linting tests.
lint: test-black test-codespell test-mypy test-pyright test-ruff test-sphinx-lint test-shellcheck ## Run all linting tests.

.PHONY: release
release: dist ## Release with twine.
Expand All @@ -88,10 +87,6 @@ test-black:
test-codespell:
codespell rockcraft tests

.PHONY: test-flake8
test-flake8:
flake8 rockcraft tests

.PHONY: test-ruff
test-ruff:
ifndef RUFF
Expand All @@ -107,10 +102,6 @@ test-integrations: ## Run integration tests.
test-mypy:
mypy rockcraft tests

.PHONY: test-pydocstyle
test-pydocstyle:
pydocstyle rockcraft

.PHONY: test-pylint
test-pylint:
echo "rockcraft has replaced pylint with ruff. Please use `make test-ruff` instead."
Expand Down
7 changes: 7 additions & 0 deletions docs/.wordlist.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
ACR
AMD
amd
ARGS
ASGI
Autotools
autotools
boolean
Expand Down Expand Up @@ -31,6 +34,8 @@ entrypoint
entrypoints
executables
expressjs
fastapi
FastAPI
Filesets
fileset
filesets
Expand Down Expand Up @@ -91,6 +96,7 @@ Podman
ppa
pre
pyfiglet
PPAs
PyPI
reStructuredText
rock's
Expand Down Expand Up @@ -138,6 +144,7 @@ ubuntu
unbuilt
UID
usrmerge
Uvicorn
VENV
venv
WSGI
Expand Down
4 changes: 4 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"product_page": "github.com/canonical/rockcraft",
"discourse": "https://discourse.ubuntu.com/c/rocks/117",
"github_url": "https://github.com/canonical/rockcraft",
"display_contributors": False,
}

extensions = [
Expand Down Expand Up @@ -96,6 +97,9 @@
"https://github.com/canonical/pebble#layer-specification",
"https://juju.is/cloud-native-kubernetes-usage-report-2021#selection-criteria-for-container-images",
"https://matrix.to/#/#rocks:ubuntu.com",
# Ignore changelog links to Rockcraft releases, because the changelog entries
# are written before the actual release is tagged.
"https://github.com/canonical/rockcraft/releases/tag/.*",
]

rst_epilog = """
Expand Down
160 changes: 160 additions & 0 deletions docs/reference/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
:tocdepth: 2

.. Check out the bottom of the page for the release template
Changelog
*********

1.6.0 (2024-Oct-17)
-------------------

Core
====

- Rockcraft 1.6.0 updates Pydantic, the internal library
used to process ``rockcraft.yaml`` files, to a new major version. This change
should not have any user-visible consequences, but please report any issues on
`GitHub <https://github.com/canonical/rockcraft/issues>`_.
- Managed (non-destructive) runs now fail as expected if the build plan is
empty. For example, trying to build a project with only ``amd64`` in its
``platforms`` will now fail when building on a non-amd64
machine.
- ``package-repositories`` entries now support ``series`` and ``pocket`` for
``apt`` repositories, and ``key-id`` for PPAs.

Bases
#####

``bare``
""""""""

- ``bare``-based rocks now have a default ``PATH`` value set on the image,
following the behaviour of ``Pebble`` services.

Plugins
#######

``poetry``
""""""""""

- Add a new plugin for Python projects that use the `Poetry`_ build system.

Extensions
##########

fastapi-framework
"""""""""""""""""

- Add a new ``fastapi-framework`` extension for `FastAPI`_-based projects.

flask-framework
"""""""""""""""

- On ``bare``-based rocks, the extension now uses Chisel slices for the Python
interpreter.
- Add support for the ``[email protected]`` base.

django-framework
""""""""""""""""

- The ``django-framework`` extension is now stable and no longer requires the
``ROCKCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS`` environment variable.
- Add support for the ``[email protected]`` base.

go-framework
""""""""""""

- Add a new ``go-framework`` extension for Go-based projects.

Command line
============

- Improve reporting of builds that fail because they match multiple platforms.
- Improve error messages for invalid ``rockcraft.yaml`` files.
- The ``pack`` command now supports ``--shell`` and ``--shell-after``, and
correctly handles cases where the packing itself fails and the ``--debug``
argument is passed.
- The ``clean`` command now supports the ``--platform`` argument to filter which
build environments to clean.
- Positional arguments are now correctly displayed on the ``help`` output of
commands.
- The terminal cursor is now hidden during execution.

Init
====

- Add new ``--profile`` argument options for ``go-framework`` and
``fastapi-framework``.

Documentation
=============

- Add :ref:`reference documentation <craft_parts_poetry_plugin>` for the new
``poetry`` plugin.
- Add a :ref:`how-to guide <add_internal_user_to_a_rock>` on adding internal
users to rocks.
- Improve the ``flask-framework``
:ref:`tutorial <build-a-rock-for-a-flask-application>` based on user feedback.
- Add a :ref:`tutorial <build-a-rock-for-a-django-application>` for the
``django-framework`` extension.
- Add a :ref:`tutorial <build-a-rock-for-a-fastapi-application>` for the
``fastapi-framework`` extension.

For a complete list of commits, check out the `1.6.0`_ release on GitHub.


.. _FastAPI: https://fastapi.tiangolo.com
.. _Poetry: https://python-poetry.org

.. _1.6.0: https://github.com/canonical/rockcraft/releases/tag/1.6.0

..
release template:
X.Y.Z (YYYY-MMM-DD)
-------------------

Core
====

# for everything related to the lifecycle of packing a rock

Bases
#####

<[email protected]>
""""""""""""""
(order from newest base to oldest base)

Plugins
#######

<plugin>
""""""""

Extensions
##########

<extension>
"""""""""""

Metadata
########

Sources
#######


Command line
============

# for command line and UX changes

Init
====


Documentation
=============

For a complete list of commits, check out the `X.Y.Z`_ release on GitHub.
58 changes: 58 additions & 0 deletions docs/reference/extensions/fastapi-framework.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.. _fastapi-framework-reference:

fastapi-framework
-----------------

The FastAPI extension streamlines the process of building FastAPI application
rocks.

It facilitates the installation of FastAPI application dependencies, including
Uvicorn, inside the rock. Additionally, it transfers your project files to
``/app`` within the rock.

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

Project requirements
====================

There are 2 requirements to be able to use the ``fastapi-framework`` extension:

1. There must be a ``requirements.txt`` file in the root of the project with
``fastapi`` declared as a dependency
2. The project must include a ASGI app in a variable called ``app`` in one of
the following files relative to the project root (in order of priority):

* ``app.py``
* ``main.py``
* ``__init__.py``, ``app.py`` or ``main.py`` within the ``app`` or ``src``
directory or within a directory with the name of the rock as declared in
``rockcraft.yaml``.

``parts`` > ``fastapi-framework/install-app`` > ``prime``
=========================================================

You can use this field to specify the files to be included or excluded from
your rock upon ``rockcraft pack``. Follow the ``app/<filename>`` notation. For
example:

.. code-block:: yaml
parts:
fastapi-framework/install-app:
prime:
- app/.env
- app/app.py
- app/webapp
- app/templates
- app/static
Some files, if they exist, are included by default. These include:
``app``, ``src``, ``<rock name>``, ``app.py``, ``migrate``, ``migrate.sh``,
``migrate.py``, ``static``, ``templates``.

Useful links
============

- :ref:`build-a-rock-for-a-fastapi-application`
1 change: 1 addition & 0 deletions docs/reference/extensions/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ initiating a new rock.

flask-framework
django-framework
fastapi-framework
1 change: 1 addition & 0 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ Rockcraft's components, commands and keywords.
Extensions <extensions/index>
plugins
parts_steps
changelog
3 changes: 3 additions & 0 deletions docs/reference/rockcraft.yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ Extensions to enable when building the ROCK.
Currently supported extensions:

- ``flask-framework``
- ``django-framework``
- ``go-framework``
- ``fastapi-framework``

Example
=======
Expand Down
2 changes: 1 addition & 1 deletion docs/reuse/tutorial/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ choice or simply use one of the already existing editors in your Ubuntu
environment (like ``vi``).

.. _`lxd-docker-connectivity-issue`: https://documentation.ubuntu.com/lxd/en/latest/howto/network_bridge_firewalld/#prevent-connectivity-issues-with-lxd-and-docker
.. _`install-multipass`: https://multipass.run/docs/how-to-install-multipass
.. _`install-multipass`: https://multipass.run/docs/install-multipass
10 changes: 5 additions & 5 deletions docs/tutorial/code/django/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ execute: |
cd django_hello_world
python manage.py runserver &
retry -n 5 --wait 2 curl localhost:8000
retry -n 5 --wait 2 curl --fail localhost:8000
# [docs:curl-django]
curl localhost:8000
Expand Down Expand Up @@ -59,7 +59,7 @@ execute: |
sudo docker run --rm -d -p 8000:8000 \
--name django-hello-world django-hello-world:0.1
# [docs:docker-run-end]
retry -n 5 --wait 2 curl localhost:8000
retry -n 5 --wait 2 curl --fail localhost:8000
# [docs:curl-django-rock]
curl localhost:8000
Expand Down Expand Up @@ -97,7 +97,7 @@ execute: |
sudo docker run --rm -d -p 8000:8000 \
--name django-hello-world django-hello-world:0.1-chiselled
# [docs:docker-run-chisel-end]
retry -n 5 --wait 2 curl localhost:8000
retry -n 5 --wait 2 curl --fail localhost:8000
# [docs:curl-django-bare-rock]
curl localhost:8000
Expand Down Expand Up @@ -128,7 +128,7 @@ execute: |
sudo docker run --rm -d -p 8000:8000 \
--name django-hello-world django-hello-world:0.2
# [docs:docker-run-update-end]
retry -n 5 --wait 2 curl localhost:8000/time/
retry -n 5 --wait 2 curl --fail localhost:8000/time/
# [docs:curl-time]
curl localhost:8000/time/
Expand All @@ -142,7 +142,7 @@ execute: |
# [docs:cleanup]
# exit and delete the virtual environment
deactivate
rm -rf .venv django_hello_world
rm -rf .venv django_hello_world __pycache__
# delete all the files created during the tutorial
rm django-hello-world_0.1_amd64.rock \
django-hello-world_0.1-chiselled_amd64.rock \
Expand Down
Loading

0 comments on commit 0125e7d

Please sign in to comment.