You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #1169 from james-garner-canonical/2024-10/docs/schema-release-process
#1169
#### Description
We want to ensure that `python-libjuju` supports the latest Juju schemas, and that it's clear to `python-libjuju` maintainers and users what versions are supported. This PR adds documentation on how to do this (`docs/CONTRIBUTING.md`), and follows this process for the existing schemas, updating the `3.1` series (`juju/client/SCHEMAS.md` and `juju/client/schemas-juju-*.json`)
#### QA Steps
No changes to generated code are introduced in this PR. `make client` should not produce any changes to the repo state.
Test should all pass.
#### Notes & Discussion
Replaces:
- #1166
Implicitly depends on:
- #1168
Since we add a schema for `3.1.10` here.
Copy file name to clipboardExpand all lines: docs/CONTRIBUTING.md
+102-1Lines changed: 102 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,4 +95,105 @@ An issue is triaged when it has the track label (e.g. `2.9`, `3.2`). And once it
95
95
96
96
Scan through our [existing issues](https://github.com/juju/python-libjuju/issues) to find one that interests you.
97
97
You can narrow down the search using `labels` as filters. See our [Labels](https://github.com/juju/python-libjuju/labels) for more information on that.
98
-
As a general rule, we don’t assign issues to anyone. If you find an issue to work on, you are welcome to open a PR with a fix.
98
+
As a general rule, we don’t assign issues to anyone. If you find an issue to work on, you are welcome to open a PR with a fix.
99
+
100
+
101
+
## Supporting a new Juju release
102
+
103
+
When new versions of Juju are released, there may be api (facade) changes, and python-libjuju needs to be updated to support them.
104
+
105
+
Every Juju build facilitates this with the inclusion of a json schema file (found in the Juju codebase under apiserver/facades/schema.json).
106
+
Juju's continuous integration testing ensures that this file is always kept up to date.
107
+
108
+
Some Juju releases may not feature any api changes at all.
109
+
Supporting many of the possible changes to the api is taken care of by python-libjuju's code generation.
110
+
The process for python-libjuju to take care of a Juju release is as follows.
111
+
112
+
### 1. Check previous release was handled correctly
113
+
114
+
If version X.Y.Z has just been released, where `Z` is 1 or more, then there should be:
115
+
1. A line in python-libjuju's `juju/client/SCHEMAS.md` starting with `X.Y.(Z-1)`
116
+
2. A schema file named `juju/client/schemas-juju-X.Y.(Z-1).json`
117
+
118
+
For example, if `3.4.17` was just released, we'd expect there to already be a line SCHEMAS.md starting with `3.4.16`, and a `schemas-juju-3.4.16.json` file.
119
+
120
+
If this is not the case, then you'll need to check what the latest release that has been handled is, and follow the process below for each release that hasn't been handled yet!
121
+
122
+
123
+
### 2. Adding the schema file for a Juju release
124
+
125
+
Now we know what release we're taking care of. Follow these steps to include the new schema file in python-libjuju:
126
+
127
+
### First release in a series
128
+
129
+
Is this the first release in a minor version series?
130
+
131
+
That is, an `X.Y.0` release, for example `3.6.0`?
132
+
133
+
1. Copy the X.Y.0 Juju release's `apiserver/facades/schema.json` file to `juju/client/schemas-juju-X.Y.0.json`
134
+
2. Add a new section to `juju/client/SCHEMAS.md`: `# X.Y`
135
+
3. Add a new line to that section: `X.Y.0`. For example, you might have:
136
+
```
137
+
# 3.6
138
+
3.6.0
139
+
```
140
+
141
+
142
+
### Subsequent releases
143
+
144
+
Otherwise, this is an `X.Y.Z` release where `Z` is 1 or more.
145
+
146
+
Here we have to check: is the `X.Y.Z` Juju release's `schema.json` file different from python-libjuju's `schemas-juju-X.Y.(Z-1).json`?
1. Copy the X.Y.Z Juju release's `apiserver/facades/schema.json` file to `juju/client/schemas-juju-X.Y.Z.json`
156
+
2. Add a new line to the `# X.Y` section in `juju/client/SCHEMAS.md`:
157
+
```
158
+
X.Y.Z
159
+
```
160
+
161
+
If there are **<ins>no</ins> differences**, then:
162
+
163
+
1. Rename the `schemas-juju-X.Y.(Z-1).json` file to `schemas-juju-X.Y.Z.json` - or equivalently, remove the `schemas-juju-X.Y.(Z-1).json` file and add Juju's `schema.json` as `schemas-juju-X.Y.Z.json`
164
+
165
+
2. Add a new line to the `# X.Y` section in `juju/client/SCHEMAS.md`:
166
+
167
+
```
168
+
X.Y.Z (identical to $PREV)
169
+
````
170
+
171
+
Where `$PREV` is either `X.Y.(Z-1)`, or if `X.Y.(Z-1)` was also identical to a previous release, then that release number instead. You can see examples of this in `SCHEMAS.md`.
172
+
173
+
174
+
### 3. Generate python-libjuju client code from new schema
175
+
176
+
In the python-libjuju root directory, run `make client`.
177
+
178
+
This will run code generation and update the `juju/client/_definitions.py`, `juju/client/_client.py` and `juju/client/_client{N}.py`files as needed.
179
+
180
+
The `_client{N}.py` files, like `_client1.py` and `_client19.py` contain definitions for specific facade numbers (1 and 19 in this case). Running `make client` might result in the creation of some new numbered files.
181
+
182
+
183
+
### 4. Validate with newly generated code
184
+
185
+
Run the tests under `tests/validate`, for example:
186
+
```
187
+
python -m pytest tests/validate -vv
188
+
```
189
+
190
+
If the `test_client_facades` test fails, it means that the `client_facades` dictionary in python-libjuju's `juju/client/connection.py` doesn't match the new facades from code generation with the new schema file. In this case, we would expect some differences, so you can update the `client_facades` dictionary based on the output of the test so that it passes.
191
+
192
+
193
+
### 5. Open a PR
194
+
195
+
Check any changed files into version control, as well as any new `_client{N}.py` and `schemas-juju-X.Y.Z.json` files, and open a PR. A good PR title would be `chore: add schemas for juju X.Y.Z`.
196
+
197
+
Tests on this PR might fail. These failures will need to be investigated. One possible cause of failures would be if python-libjuju requires additional changes to support a new facade version. If this is the case, a potential solution is to manually move the problematic facade number from `client_facades` to `excluded_facade_versions`, and open an issue about supporting that facade.
198
+
199
+
You can run the integration tests locally, but they can be a bit unpredictable. You could also just push to your fork to have them run on github, but if you open a PR then the other maintainers can help out.
0 commit comments