|
| 1 | += Couchbase Release Note Generator Design Guide |
| 2 | +:description: This document describes the architecture and high-level design of the Couchbase Release Note Generator. |
| 3 | +:page-topic-type: concepts |
| 4 | + |
| 5 | +:jql-fn: footnote:[JIRA Query Language] |
| 6 | +:jinja-fn: footnote:[For more information on Jinja templates, see https://jinja.palletsprojects.com] |
| 7 | +[abstract] |
| 8 | +{description} |
| 9 | + |
| 10 | +== Overview |
| 11 | + |
| 12 | +Producing release notes for the number of products that Couchbase offers is time-consuming. |
| 13 | +For this reason, the Technical Communications team has created a Python script that can generate release notes from JIRA tickets. |
| 14 | + |
| 15 | +The problem is made slightly more complicated because each product has its own format its release note. |
| 16 | +To get around this problem, the script uses a different template file for each product. |
| 17 | + |
| 18 | +NOTE: The plan is that all the products share the same format. |
| 19 | + |
| 20 | +== Design Goals |
| 21 | + |
| 22 | +When deciding on the design of the Couchbase Release Note Generator, the team considered the following goals: |
| 23 | + |
| 24 | +* Flexibility: The script should be able to handle new products and formats without requiring changes to the Python script. |
| 25 | +* Extensibility: The script should be easy to extend and modify to accommodate new requirements or changes in the JIRA data. |
| 26 | +* Maintainability: The codebase should be well-organized and easy to understand, making it easier to maintain and debug over time. |
| 27 | +* Allow for the optional use of AI to generate the release notes. |
| 28 | + |
| 29 | +== Release Note Generator Process Architecture |
| 30 | + |
| 31 | +The script is designed to be flexible and extendable. |
| 32 | +It uses a modular architecture that allows for the addition of new products and formats. |
| 33 | + |
| 34 | +[plantuml] |
| 35 | +---- |
| 36 | +@startuml |
| 37 | +skin rose |
| 38 | +
|
| 39 | +database "Couchbase\n jira \n database" as jira |
| 40 | +
|
| 41 | +component "CB Release Notes Generator\n(Python script)" as script |
| 42 | +file "Generated\n AsciiDoc\n file" as asciidoc |
| 43 | +file "templates\n(Jinja)" as template |
| 44 | +file "configuration file\n(YAML)" as configuration |
| 45 | +actor "Documentarian" as user |
| 46 | +
|
| 47 | +jira --> script |
| 48 | +configuration --> script |
| 49 | +template --> script |
| 50 | +script --> asciidoc |
| 51 | +user --> script |
| 52 | +@enduml |
| 53 | +---- |
| 54 | + |
| 55 | +. On invocation, the script loads the `release sets` from the configuration file, |
| 56 | +and displays them on screen. |
| 57 | +. The user selects one of the release sets (`Couchbase Server`, `Couchbase Mobile`, `Couchbase Operator` ...) |
| 58 | +. The user enters a series of parameters as defined in the selected `release set`: (`release date`, `release label` ...) |
| 59 | +.The script executes the JQL{empty}{jql-fn} statement defined in the `release set` supplying the parameters entered by the user. |
| 60 | +. The script collects the JIRA tickets that match the query. |
| 61 | +. The script loads the Jinja{empty}{jinja-fn} template defined in the release set and uses it to render the release note as an AsciiDoc file. |
| 62 | + |
| 63 | + |
| 64 | +== Logic Flow |
| 65 | + |
| 66 | +=== Step {counter:flow}: Render the menu options |
| 67 | + |
| 68 | +When the script is invoked, the first thing it does is load the configuration file: `cb_release_notes_config.yaml`. |
| 69 | +This file contains instructions on how to generate release notes for all supported products, as well as the location of the `.passwords.yaml`, |
| 70 | +a hidden file that contains security tokens for accessing JIRA. |
| 71 | + |
| 72 | +CAUTION: The contents of `.passwords.yaml` should be kept securely on your local machine. |
| 73 | +The file should not be shared or stored under version control. |
| 74 | + |
| 75 | +[source, yaml] |
| 76 | +---- |
| 77 | +# Configuration file for the release notes builder |
| 78 | +
|
| 79 | +# $schema: ./cb_release_config_schema.yaml |
| 80 | +
|
| 81 | +version: "2.2" |
| 82 | +
|
| 83 | +password_file: ./.passwords.yaml |
| 84 | +templates_directory: ./templates |
| 85 | +jira_batch_size: 50 |
| 86 | +
|
| 87 | +release_settings: |
| 88 | +
|
| 89 | + - name: "Fixes and enhancements (Server 8.0+)" |
| 90 | +
|
| 91 | + - name: "Couchbase Mobile" |
| 92 | +
|
| 93 | + - name: "Couchbase Operator" |
| 94 | +
|
| 95 | +
|
| 96 | +---- |
| 97 | + |
| 98 | +At this high-level, the contents of the configuration file are pretty straightforward: |
| 99 | + |
| 100 | +[horizontal] |
| 101 | +version:: |
| 102 | +The current version number of the release note generator. |
| 103 | + |
| 104 | +password_file:: |
| 105 | +The location and name of the password file. |
| 106 | +It is recommended that this file is prefixed with the `.` character which will hide the file under the macOS file system. |
| 107 | + |
| 108 | +templates_directory:: |
| 109 | +The location of the JinJa templates that the script will use to render the release notes in AsciiDoc. |
| 110 | + |
| 111 | +jira_batch_size:: |
| 112 | +Instead of fetching the Jira tickets in one go, the script can retrieve them in batches of a given size. |
| 113 | ++ |
| 114 | +NOTE: In practice, a release note shouldn't contain more that 50 tickets, |
| 115 | +so there is probably little point in changing the value. |
| 116 | + |
| 117 | +release_settings:: |
| 118 | +Defines the instructions for retrieving the tickets from the Jira database. |
| 119 | +Each setting defines the `name` (as shown) which the script uses to generate an on-screen menu |
| 120 | +from which the user can select the product to generate the release note for. |
| 121 | ++ |
| 122 | +.Release Notes Generator menu options |
| 123 | +image::release-note-generator/cb-release-notes-menu-options.png[Release Notes Generator menu options] |
| 124 | + |
| 125 | +In the following steps, we'll look at the release set options in more detail. |
| 126 | + |
| 127 | +== Step {counter:flow}: Get the parameters |
| 128 | + |
| 129 | +In this example, assume that the user has selected the first menu option: `Fixes and enhancements (Server 8.0+)`. |
| 130 | +The script will then load the release set configuration for the selected product: |
| 131 | +[source, yaml] |
| 132 | +---- |
| 133 | +- name: "Fixes and enhancements (Server 8.0+)" |
| 134 | + fields: |
| 135 | + - name: release_date |
| 136 | + type: text |
| 137 | + message: 'Enter the release date (Month Year):' |
| 138 | + - name: release_number |
| 139 | + type: text |
| 140 | + message: 'Enter the release label:' |
| 141 | + - name: release_text |
| 142 | + type: text |
| 143 | + message: 'Enter the release number for the title line:' |
| 144 | + - name: file_path |
| 145 | + type: file |
| 146 | + message: 'Enter the file path for the release notes:' |
| 147 | +
|
| 148 | +---- |
| 149 | +[#fields] |
| 150 | +The fields represent a list of parameters that the script will ask the user for |
| 151 | +by displaying a prompt for the parameter on-screen: |
| 152 | + |
| 153 | +[horizontal] |
| 154 | +name:: |
| 155 | +The name of the parameter (the name elements can be separated using the underscore character: `_`) |
| 156 | + |
| 157 | +type:: |
| 158 | +The parameter type can be one of the following: |
| 159 | ++ |
| 160 | +-- |
| 161 | +[horizontal] |
| 162 | +text::: |
| 163 | +A basic character string. |
| 164 | +This is the most commonly used field type. |
| 165 | + |
| 166 | +multiline::: |
| 167 | +Another text field with the option of launching your system editor |
| 168 | +for entering large amounts of text. |
| 169 | +Handy to have, but rarely used. |
| 170 | + |
| 171 | +choice::: |
| 172 | +Allows for a single selection from a sublist of items denoted by `choices`. |
| 173 | + |
| 174 | +select::: |
| 175 | +Allows for a single selection from a sublist of items denoted by `choices`. |
| 176 | + |
| 177 | +file::: |
| 178 | +This allows for the entry of a filename (with support for file path completion). |
| 179 | ++ |
| 180 | +NOTE: This is the only item considered to be mandatory, |
| 181 | +as it is required to pick up the name of the AsciiDoc file to which the release note is eventually written. |
| 182 | +-- |
| 183 | ++ |
| 184 | +message:: |
| 185 | +The prompt that is displayed for the user to enter the required information. |
| 186 | + |
| 187 | +In our example, the prompts displayed will look something like this, |
| 188 | +each item being filled in by the user before the script displays the next prompt. |
| 189 | + |
| 190 | +image::release-note-generator/retrieve-parameters.png[] |
| 191 | + |
| 192 | +TIP: The script will save the parameters as they're entered, |
| 193 | +then present them again on its next invocation. |
| 194 | + |
| 195 | +=== Step {counter:flow}: Retrieve the Jira tickets |
| 196 | +Having picked up the parameters, the script will then run a JQL query to retrieve the tickets for the release. |
| 197 | + |
| 198 | +[source,YAML] |
| 199 | +---- |
| 200 | +
|
| 201 | +url: https://jira.issues.couchbase.com |
| 202 | +jql: project = "Couchbase Server" |
| 203 | + AND type IN (Epic, Bug, Improvement, Task, "Technical Task") |
| 204 | + AND fixVersion in ({{release_number}}) |
| 205 | + AND labels IN (releasenote,releasenotecomplete) |
| 206 | + AND ("Release Notes[Labels]" NOT IN (suppress-{{release_number}}) OR "Release Notes[Labels]" IS EMPTY) |
| 207 | + AND summary !~ "System Test" AND resolution not in (Declined, "Won't Fix") |
| 208 | + AND reporter not in (membersOf(couchbase-qe-team)) |
| 209 | + ORDER BY key ASC |
| 210 | +---- |
| 211 | + |
| 212 | +It only needs two configuration items for this: |
| 213 | + |
| 214 | +[horizontal] |
| 215 | + |
| 216 | +url:: |
| 217 | +The URL of the Jira instance. For this to work, you must have a token defined in `.passwords.yaml`. |
| 218 | ++ |
| 219 | +[WARNING] |
| 220 | +.public/private tickets |
| 221 | +==== |
| 222 | +The script uses the Jira API to retrieve the tickets, |
| 223 | +and due to what I assume is a deliberate limitation, |
| 224 | +the API will only retrieve items that have a security level set to `public` or `none`. |
| 225 | +==== |
| 226 | + |
| 227 | +jql:: |
| 228 | +A valid JQL statement that the script will use to retrieve the tickets. |
| 229 | +Pay close attention to the field parameters delimited by `{{}}`; |
| 230 | +these are the named parameters that will be replaced with the values |
| 231 | +entered by the user from the xref:#fields[`fields`] section. |
| 232 | + |
| 233 | +=== Step {counter:flow}: Render the release note |
| 234 | + |
| 235 | + |
| 236 | + |
| 237 | + |
0 commit comments