Skip to content

Commit 45d0480

Browse files
authored
Merge branch 'main' into extension/block-on-missing
2 parents 797cc3f + b4aee1e commit 45d0480

File tree

11 files changed

+1860
-23
lines changed

11 files changed

+1860
-23
lines changed

.github/workflows/schema.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Schema
2+
on: [pull_request]
3+
4+
env:
5+
CHARMCRAFT_JSON: schema/charmcraft.json
6+
7+
jobs:
8+
diff-schema:
9+
runs-on: ubuntu-22.04
10+
11+
steps:
12+
- name: Checkout rockcraft
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Set up uv with caching
18+
id: setup-uv
19+
uses: astral-sh/setup-uv@v3
20+
with:
21+
enable-cache: true
22+
cache-suffix: ${{ steps.runner-info.outputs.cache-hash }}
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.10"
28+
29+
- name: Run generator script
30+
run: |
31+
uv run --frozen --no-dev --extra apt-jammy \
32+
python tools/schema.py > generated_schema.json
33+
34+
- name: Check with stored schema
35+
run: |
36+
test -f $CHARMCRAFT_JSON &&
37+
diff generated_schema.json $CHARMCRAFT_JSON
38+
39+
validate-schema:
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- name: Checkout Charmcraft
44+
uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
48+
- name: Set up Node.js
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: "20"
52+
53+
- name: Install ajv cli
54+
run: npm install -g ajv-cli
55+
56+
- name: Run ajv
57+
run: |
58+
# Don't fail immediately if one validation fails
59+
EXIT_CODE=0
60+
for proj_file in tests/spread/smoketests/basic/charmcraft*; do
61+
if ! ajv validate -s $CHARMCRAFT_JSON \
62+
-d $proj_file \
63+
--strict=false --spec=draft2020; then
64+
EXIT_CODE=1
65+
fi
66+
done
67+
exit $EXIT_CODE

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,7 @@ else
117117
brew install multipass
118118
brew install skopeo
119119
endif
120+
121+
.PHONY: schema
122+
schema: install-uv
123+
uv run tools/schema.py > schema/charmcraft.json

charmcraft/models/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ def _populate_platforms(cls, platforms: dict[str, Any]) -> dict[str, Any]:
11151115
return platforms
11161116

11171117

1118-
Charm = BasesCharm | PlatformCharm
1118+
Charm = PlatformCharm | BasesCharm
11191119

11201120

11211121
class Bundle(CharmcraftProject):

docs/howto/manage-revisions.rst

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Manage charm revisions
77

88
<!--As opposed to resource revisions. (Or bundle revisions, but that's being phased out.)-->
99

10+
1011
Create a charm revision
1112
-----------------------
1213

@@ -15,6 +16,7 @@ Charmhub (unless you're uploading the exact same file again).
1516

1617
See more: :ref:`publish-a-charm`
1718

19+
1820
View the existing charm revisions
1921
---------------------------------
2022

@@ -23,20 +25,30 @@ followed by the name of the charm.
2325

2426
See more: :ref:`ref_commands_revisions`
2527

28+
2629
Promote a charm revision to a better risk level
2730
-----------------------------------------------
2831

29-
To promote a charm revision to a higher-ranking risk level, use the GitHub
30-
``promote-charm`` action.
32+
To promote a charm revision to a more stable risk level, run
33+
:literalref:`charmcraft promote<ref_commands_promote>` with flags specifying the current
34+
and desired channels. For example, to promote a charm from the ``candidate`` channel to
35+
the ``stable`` channel, you would run:
36+
37+
.. code-block:: bash
38+
39+
charmcraft promote --from-channel=candidate --to-channel=stable
3140
32-
See more: `GitHub | canonical/charming-actions/promote-charm
33-
<https://github.com/canonical/charming-actions/tree/2.6.0/promote-charm>`_
41+
If you are looking to promote charm revisions in your CI workflow, the same result can
42+
be achieved with the `Charmhub Promotion
43+
<https://github.com/canonical/charming-actions/tree/main/promote-charm>`_ GitHub action.
44+
Note that this GitHub action resides in a separate repository and is therefore
45+
maintained separately from Charmcraft.
3446

3547
.. collapse:: Example outcome
3648

37-
For example, in the (partial) output of juju info mongodb below, revision 100 has
38-
been promoted from ``3.6/edge`` through ``3.6/beta`` and ``3.6/candidate`` all the
39-
way to ``3.6/stable``. (The up arrow next to ``3.6/beta`` indicates that that
49+
For example, in the following output of ``juju info mongodb``, revision 100
50+
has been promoted from ``3.6/edge`` through ``3.6/beta`` and ``3.6/candidate`` all
51+
the way to ``3.6/stable``. (The up arrow next to ``3.6/beta`` indicates that that
4052
channel has been closed and, if you try ``juju deploy --channel 3.6/beta``, what
4153
you'll get is the next higher-ranking risk level of the same track, that is,
4254
``3.6/candidate``.)

docs/reference/files/charmcraft-yaml-file.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ at least one ``requires`` integration with ``container`` scope.
937937
.. collapse:: Example
938938

939939
.. literalinclude:: charmcraft-sample-charm.yaml
940-
:start-at: storage: # Possible storage for the charm
940+
:start-at: storage: # Possible storage for the charm
941941
:end-before: subordinate:
942942

943943

docs/tutorial/write-your-first-kubernetes-charm-for-a-django-app.rst

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ PostgreSQL and need to deploy it. In a traditional setup, this can be
88
quite a challenge, but with Charmcraft you’ll find yourself packaging
99
and deploying your Django application in no time.
1010

11+
12+
Introduction
13+
------------
14+
1115
In this tutorial we will build a Kubernetes charm for a Django
1216
application using Charmcraft, so we can have a Django application up and
1317
running with Juju. Let’s get started!
@@ -24,16 +28,18 @@ This tutorial should take 90 minutes for you to complete.
2428
can be easily deployed, configured, scaled, integrated, etc.,
2529
on any Kubernetes cluster.
2630

31+
2732
What you’ll need
28-
----------------
33+
~~~~~~~~~~~~~~~~
2934

3035
- A local system, e.g., a laptop, with amd64 or arm64 architecture
3136
which has sufficient resources to launch a virtual machine with 4
3237
CPUs, 4 GB RAM, and a 50 GB disk.
3338
- Familiarity with Linux.
3439

40+
3541
What you’ll do
36-
--------------
42+
~~~~~~~~~~~~~~
3743

3844
Create a Django application. Use that to create a rock with
3945
``rockcraft``. Use that to create a charm with ``charmcraft``. Use that
@@ -381,6 +387,7 @@ respond with something similar to
381387
If you are not on the ``amd64`` platform, the name of the ``.charm``
382388
file will be different for you.
383389

390+
384391
Deploy the Django application
385392
-----------------------------
386393

@@ -516,12 +523,22 @@ Now you can open a new tab and visit http://django-hello-world. The
516523
Django app should respond in the browser with
517524
``The install worked successfully! Congratulations!``.
518525

519-
Add an initial app
520-
------------------
526+
527+
The development cycle
528+
---------------------
529+
530+
So far, we have worked though the entire cycle, from creating an application to
531+
deploying it. But now -- as in every real-world case -- we will go through the
532+
experience of iterating to develop the application, and deploy each iteration.
533+
534+
535+
Add a "Hello, world" app
536+
~~~~~~~~~~~~~~~~~~~~~~~~
537+
538+
In this iteration, we'll add a greeting app that returns a ``Hello, world!`` greeting.
521539

522540
The generated Django application does not come with an app, which is why
523-
we had to initially enable debug mode for testing. Let’s add a greeting
524-
app that returns a ``Hello, world!`` greeting. We will need to go back
541+
we had to initially enable debug mode for testing. We will need to go back
525542
out to the ``/django-hello-world`` directory where the rock is and enter
526543
into the ``/django_hello_world`` directory where the Django application
527544
is. Let’s add a new Django app:
@@ -556,6 +573,10 @@ Open the ``django_hello_world/urls.py`` file and edit the imports for
556573
path("admin/", admin.site.urls),
557574
]
558575
576+
577+
Update the rock
578+
~~~~~~~~~~~~~~~
579+
559580
Since we’re changing the application we should update the version of the
560581
rock. Go back to the ``/django-hello-world`` directory where the rock is
561582
and change the ``version`` in ``rockcraft.yaml`` to ``0.2``. The top of
@@ -593,8 +614,13 @@ Now let’s pack and upload the rock using similar commands as before:
593614
:end-before: [docs:repack-update-end]
594615
:dedent: 2
595616

596-
Now we can deploy the new version of the Django application from the
597-
``/charm`` directory using:
617+
618+
Redeploy the charm
619+
~~~~~~~~~~~~~~~~~~
620+
621+
We'll redeploy the new version with ``juju refresh``.
622+
623+
In the ``/charm`` directory, run:
598624

599625
.. literalinclude:: code/django/task.yaml
600626
:language: bash
@@ -618,8 +644,8 @@ inside the Multipass VM. Either way, the Django application should respond
618644
with ``Hello, world!``.
619645

620646

621-
Enable a configuration
622-
----------------------
647+
Provide a configuration
648+
-----------------------
623649

624650
To demonstrate how to provide a configuration to the Django application,
625651
we will make the greeting configurable. We will expect this
@@ -632,6 +658,10 @@ with:
632658
.. literalinclude:: code/django/views_greeting_configuration.py
633659
:language: python
634660

661+
662+
Update the rock (again)
663+
~~~~~~~~~~~~~~~~~~~~~~~
664+
635665
Increment the ``version`` in ``rockcraft.yaml`` to ``0.3`` such that the
636666
top of the ``rockcraft.yaml`` file looks similar to the following:
637667

@@ -667,6 +697,10 @@ Let’s pack and upload the rock:
667697
:end-before: [docs:repack-2nd-update-end]
668698
:dedent: 2
669699

700+
701+
Update the charm
702+
~~~~~~~~~~~~~~~~
703+
670704
Change back into the charm directory using ``cd charm``.
671705

672706
The ``django-framework`` Charmcraft extension supports adding
@@ -683,7 +717,8 @@ the end of the ``charmcraft.yaml`` file:
683717
replaced by ``_``. A ``DJANGO_`` prefix will also be added as a
684718
namespace for app configurations.
685719

686-
We can now pack and deploy the new version of the Django app:
720+
We can now pack a new version of the charm, and then deploy it once more with ``juju
721+
refresh``:
687722

688723
.. literalinclude:: code/django/task.yaml
689724
:language: bash

0 commit comments

Comments
 (0)