Add changelog generation (#761)

* WIP Release notes generation and templates

* WIP Add new sections to the template

* WIP renaming and wip

* Fix runtime template

* Add doc, NO_CACHE and tweaking of the templates

* Renaming cl into cumulus to make room for the polkadot and substrate

* Fetch data from Substrate and Polkadot

* WIP convert bash script to ruby

* Convert to Ruby

* Fix host function delection

* Extract priority to a macro

* Fix misc changes

* Draft release workflow

* Fix runtime dir

* Add ENV to ignore runtimes

* Install tooling separately

* WIP troubleshooting - remove sudo

* Minor formatting fixes

* Fix workflow

* Add missing dep

* Linting

* Fix changelog script

* Add missing tera install

* Use absolute paths

* Fix path + cleanup

* Fix changelog generation

* Add missing pre-release ENV

* Fix rust version ENV

* Fix release notes path

* Fix output

* Fix runtime_dir for cumulus

* Fix ENV substitutions

* Fix styling

* Debugging

* Styling

* Fix call to fetch the runtime version

* Cleanup and doc

* Delete sample .env

* Update scripts/changelog/templates/change.md.tera

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Change XCM emoji marker for a ✉️

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
This commit is contained in:
Chevdor
2021-11-19 17:30:05 +01:00
committed by GitHub
parent 69f030f81c
commit e4e8d4fb83
28 changed files with 897 additions and 15 deletions
@@ -0,0 +1,45 @@
{# This macro shows ONE change #}
{%- macro change(c, cml="[C]", dot="[P]", sub="[S]") -%}
{%- if c.meta.C and c.meta.C.value >= 7 -%}
{%- set prio = " ‼️ HIGH" -%}
{%- elif c.meta.C and c.meta.C.value >= 5 -%}
{%- set prio = " ❗️ Medium" -%}
{%- elif c.meta.C and c.meta.C.value >= 3 -%}
{%- set prio = " Low" -%}
{%- else -%}
{%- set prio = "" -%}
{%- endif -%}
{%- set audit = "" -%}
{#
{%- if c.meta.D and c.meta.D.value == 1 -%}
{%- set audit = "✅ audited " -%}
{%- elif c.meta.D and c.meta.D.value == 2 -%}
{%- set audit = "✅ trivial " -%}
{%- elif c.meta.D and c.meta.D.value == 3 -%}
{%- set audit = "✅ trivial " -%}
{%- elif c.meta.D and c.meta.D.value == 5 -%}
{%- set audit = "⏳ pending non-critical audit " -%}
{%- else -%}
{%- set audit = "" -%}
{%- endif -%}
#}
{%- if c.html_url is containing("polkadot") -%}
{%- set repo = dot -%}
{%- elif c.html_url is containing("cumulus") -%}
{%- set repo = cml -%}
{%- elif c.html_url is containing("substrate") -%}
{%- set repo = sub -%}
{%- else -%}
{%- set repo = " " -%}
{%- endif -%}
{%- if c.meta.T and c.meta.T.value == 6 -%}
{%- set xcm = " [✉️ XCM]" -%}
{%- else -%}
{%- set xcm = "" -%}
{%- endif -%}
{{- repo }} {{ audit }}[`#{{c.number}}`]({{c.html_url}}) {{- prio }} - {{ c.title | capitalize | truncate(length=60, end="…") }}{{xcm }}
{%- endmacro change -%}
@@ -0,0 +1,14 @@
{# This include generates the section showing the changes #}
## Changes
### Legend
- {{ CML }} Cumulus
- {{ DOT }} Polkadot
- {{ SUB }} Substrate
{% include "changes_client.md.tera" %}
{% include "changes_runtime.md.tera" %}
{% include "changes_misc.md.tera" %}
@@ -0,0 +1,17 @@
{% import "change.md.tera" as m_c -%}
### Client
{#- The changes are sorted by merge date #}
{%- for pr in changes | sort(attribute="merged_at") %}
{%- if pr.meta.B %}
{%- if pr.meta.B.value == 0 %}
{#- We skip silent ones -#}
{%- else -%}
{%- if pr.meta.B.value == 5 and not pr.title is containing("ompanion") %}
- {{ m_c::change(c=pr) }}
{%- endif -%}
{% endif -%}
{% endif -%}
{% endfor %}
@@ -0,0 +1,39 @@
{%- import "change.md.tera" as m_c -%}
{%- set_global misc_count = 0 -%}
{#- First pass to count #}
{%- for pr in changes -%}
{%- if pr.meta.B %}
{%- if pr.meta.B.value == 0 -%}
{#- We skip silent ones -#}
{%- else -%}
{%- if pr.meta.B and pr.meta.B.value != 5 and pr.meta.B.value != 7 or pr.meta.C or not pr.meta.B %}
{%- set_global misc_count = misc_count + 1 -%}
{%- endif -%}
{% endif -%}
{% endif -%}
{% endfor %}
### Misc
{% if misc_count > 10 %}
There are {{ misc_count }} other misc. changes. You can expand the list below to view them all.
<details><summary>{{ misc_count }} misc. changes</summary>
{% endif -%}
{#- The changes are sorted by merge date #}
{%- for pr in changes | sort(attribute="merged_at") %}
{%- if pr.meta.B and not pr.title is containing("ompanion") %}
{%- if pr.meta.B.value == 0 %}
{#- We skip silent ones -#}
{%- else -%}
{%- if pr.meta.B and pr.meta.B.value != 5 and pr.meta.B.value != 7 or pr.meta.C or not pr.meta.B %}
- {{ m_c::change(c=pr) }}
{%- endif -%}
{% endif -%}
{% endif -%}
{% endfor %}
{% if misc_count > 10 %}
</details>
{% endif -%}
@@ -0,0 +1,19 @@
{%- import "change.md.tera" as m_c -%}
### Runtime
{#- The changes are sorted by merge date -#}
{% for pr in changes | sort(attribute="merged_at") -%}
{%- if pr.meta.B -%}
{%- if pr.meta.B.value == 0 -%}
{#- We skip silent ones -#}
{%- else -%}
{%- if pr.meta.B.value == 7 and not pr.title is containing("ompanion") %}
- {{ m_c::change(c=pr) }}
{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- endfor %}
@@ -0,0 +1,6 @@
## Rust compiler versions
This release was tested against the following versions of `rustc`. Other versions may work.
- Rust Stable: `{{ env.RUSTC_STABLE }}`
- Rust Nightly: `{{ env.RUSTC_NIGHTLY }}`
@@ -0,0 +1,10 @@
{%- set to_ignore = changes | filter(attribute="meta.B.value", value=0) %}
<!--
## Debug
changes:
- total: {{ changes | length }}
- silent: {{ to_ignore | length }}
- remaining: {{ changes | length - to_ignore | length }}
-->
@@ -0,0 +1,10 @@
<!--
## Docker images
The docker image for this release can be found in [Docker hub](https://hub.docker.com/r/parity/polkadot-collator/tags?page=1&ordering=last_updated).
You may also pull it with:
```
docker pull parity/polkadot-collator:latest
```
-->
@@ -0,0 +1,37 @@
{% import "priority.md.tera" as m_p -%}
## Global Priority
{%- set cumulus_prio = 0 -%}
{%- set polkadot_prio = 0 -%}
{%- set substrate_prio = 0 -%}
{# We fetch the various priorities #}
{%- if cumulus.meta.C -%}
{%- set cumulus_prio = cumulus.meta.C.max -%}
{%- endif -%}
{%- if polkadot.meta.C -%}
{%- set polkadot_prio = polkadot.meta.C.max -%}
{%- endif -%}
{%- if substrate.meta.C -%}
{%- set substrate_prio = substrate.meta.C.max -%}
{%- endif -%}
{# We compute the global priority #}
{%- set global_prio = cumulus_prio -%}
{%- if polkadot_prio > global_prio -%}
{% set global_prio = polkadot_prio -%}
{%- endif -%}
{%- if substrate_prio > global_prio -%}
{%- set global_prio = substrate_prio -%}
{%- endif -%}
{# We show the result #}
{{ m_p::priority(p=global_prio) }}
<!--
- Cumulus: {{ cumulus_prio }}
- Polkadot: {{ polkadot_prio }}
- Substrate: {{ substrate_prio }}
-->
{# todo: show high prio list here #}
@@ -0,0 +1,30 @@
{%- import "change.md.tera" as m_c -%}
{%- set_global host_fn_count = 0 -%}
## Host functions
{% for pr in changes | sort(attribute="merged_at") -%}
{%- if pr.meta.B and pr.meta.B.value == 0 -%}
{#- We skip silent ones -#}
{%- else -%}
{%- if pr.meta.E and pr.meta.E.value == 4 -%}
{%- set_global host_fn_count = host_fn_count + 1 -%}
- {{ m_c::change(c=pr) }}
{% endif -%}
{% endif -%}
{%- endfor -%}
<!-- {{ host_fn_count }} host functions were detected -->
{% if host_fn_count == 0 -%}
️ This release does not contain any new host functions.
{% elif host_fn_count == 1 -%}
⚠️ The runtimes in this release contain one new **host function**.
⚠️ It is critical that you update your client before the chain switches to the new runtimes.
{%- else -%}
⚠️ The runtimes in this release contain {{ host_fn_count }} new **host function{{ host_fn_count | pluralize }}**.
⚠️ It is critical that you update your client before the chain switches to the new runtimes.
{%- endif %}
@@ -0,0 +1,14 @@
{%- import "change.md.tera" as m_c %}
## Migrations
{% for pr in changes | sort(attribute="merged_at") -%}
{%- if pr.meta.B and pr.meta.B.value == 0 %}
{#- We skip silent ones -#}
{%- else -%}
{%- if pr.meta.E and pr.meta.E.value == 1 -%}
- {{ m_c::change(c=pr) }}
{% endif -%}
{% endif -%}
{% endfor -%}
@@ -0,0 +1,9 @@
{%- if env.PRE_RELEASE == "true" -%}
-----
⚠️ Howdy! Beware, this is a **pre-release**
-----
{%- else -%}
<!-- NOT a pre-release-->
{%- endif %}
@@ -0,0 +1,21 @@
{# This macro convert a priority level into readable output #}
{%- macro priority(p) -%}
{%- if p >= 7 -%}
{%- set prio = "‼️ HIGH" -%}
{%- set text = "This is a **high priority** release and you must upgrade as as soon as possible" -%}
{%- elif p >= 5 -%}
{%- set prio = "❗️ Medium" -%}
{%- set text = "This is a medium priority release and you should upgrade in a timely manner" -%}
{%- elif p >= 3 -%}
{%- set prio = "Low" -%}
{%- set text = "This is a low priority release and you may upgrade at your convenience" -%}
{%- endif %}
{%- if prio %}
{{prio}}: {{text}}
{%- else -%}
<!-- No relevant Priority label as been detected -->
{% endif %}
{%- endmacro priority -%}
@@ -0,0 +1,27 @@
{# This macro shows one runtime #}
{%- macro runtime(runtime) -%}
### {{ runtime.name | capitalize }}
{%- if runtime.data.runtimes.compressed.subwasm.compression.compressed %}
{%- set compressed = "Yes" %}
{%- else %}
{%- set compressed = "No" %}
{%- endif %}
{%- set comp_ratio = 100 - (runtime.data.runtimes.compressed.subwasm.compression.size_compressed / runtime.data.runtimes.compressed.subwasm.compression.size_decompressed *100) %}
<!-- commit : {{ runtime.data.commit }} -->
<!-- tag : {{ runtime.data.tag }} -->
<!-- branch : {{ runtime.data.branch }} -->
<!-- pkg : {{ runtime.data.pkg }} -->
```
🏋️ Runtime Size: {{ runtime.data.runtimes.compressed.subwasm.size | filesizeformat }} ({{ runtime.data.runtimes.compressed.subwasm.size }} bytes)
🔥 Core Version: {{ runtime.data.runtimes.compressed.subwasm.core_version }}
🗜 Compressed: {{ compressed }}: {{ comp_ratio | round(method="ceil", precision=2) }}%
🎁 Metadata version: {{ runtime.data.runtimes.compressed.subwasm.metadata_version }}
🗳️ system.setCode hash: {{ runtime.data.runtimes.compressed.subwasm.proposal_hash }}
🗳️ authorizeUpgrade hash: {{ runtime.data.runtimes.compressed.subwasm.parachain_authorize_upgrade_hash }}
#️⃣ Blake2-256 hash: {{ runtime.data.runtimes.compressed.subwasm.blake2_256 }}
📦 IPFS: {{ runtime.data.runtimes.compressed.subwasm.ipfs_hash }}
```
{%- endmacro runtime %}
@@ -0,0 +1,17 @@
{# This include shows the list and details of the runtimes #}
{%- import "runtime.md.tera" as m_r -%}
## Runtimes
{% set rtm = srtool[0] -%}
The information about the runtimes included in this release can be found below.
The runtimes have been built using [{{ rtm.data.gen }}](https://github.com/paritytech/srtool) and `{{ rtm.data.rustc }}`.
{%- for runtime in srtool | sort(attribute="name") %}
{%- set HIDE_VAR = "HIDE_SRTOOL_" ~ runtime.name | upper %}
{%- if not env is containing(HIDE_VAR) %}
{{ m_r::runtime(runtime=runtime) }}
{%- endif %}
{%- endfor %}
@@ -0,0 +1,28 @@
{# This is the entry point of the template -#}
<!-- repository: {{ cumulus.repository.name }} -->
This release contains the changes from `{{ env.REF1 }}` to `{{ env.REF2 }}`.
{%- set changes = cumulus.changes | concat(with=substrate.changes) -%}
{%- set changes = changes | concat(with=polkadot.changes) -%}
{%- include "debug.md.tera" -%}
{%- set CML = "[C]" -%}
{%- set DOT = "[P]" -%}
{%- set SUB = "[S]" -%}
{# header warning and important notices -#}
{% include "pre_release.md.tera" -%}
{% include "global_priority.md.tera" -%}
{% include "host_functions.md.tera" -%}
{% include "compiler.md.tera" -%}
{% include "migrations.md.tera" -%}
{% include "runtimes.md.tera" -%}
{% include "changes.md.tera" -%}
{% include "docker_image.md.tera" -%}