Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRDoc new schema #1946

Merged
merged 38 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6d83542
Initial tests with the new prdoc
chevdor Oct 18, 2023
4ecebe1
Fix config, schema and template
chevdor Oct 19, 2023
a73089b
Fix PRDoc CI
chevdor Oct 19, 2023
8f21b89
Add a non mandatory prdoc file
chevdor Oct 19, 2023
749380f
Ensure the repo is always checked out
chevdor Oct 19, 2023
be21a36
Test non mandatory erroneous prdoc file
chevdor Oct 19, 2023
34024d2
Fix docker call
chevdor Oct 19, 2023
339207c
Fix the prdoc search
chevdor Oct 19, 2023
1f09501
Fix prdoc
chevdor Oct 19, 2023
253e8af
Merge branch 'master' into wk-231018-prdoc-new-schema
chevdor Oct 20, 2023
83982d5
Fix audiences according to the forum post
chevdor Oct 23, 2023
71f976b
Remove the "enabled" fields for host_fn, it depends on the runtimes
chevdor Oct 23, 2023
3375e23
Fix quotes
chevdor Oct 23, 2023
9a7d9d2
Merge branch 'master' into wk-231018-prdoc-new-schema
chevdor Oct 23, 2023
1399680
Merge branch 'master' into wk-231018-prdoc-new-schema
chevdor Oct 24, 2023
7fdac49
Add quick start documentation for prdoc
chevdor Oct 24, 2023
9aabeeb
Fix markdown line length
chevdor Oct 24, 2023
1cf8092
Update prdoc/schema_user.json
chevdor Oct 25, 2023
8410b6f
Add PRDoc documentation in the CI output
chevdor Oct 26, 2023
55792aa
Add documentation
chevdor Oct 26, 2023
e2053af
Make the pallet propery optional for runtime migrations
chevdor Oct 26, 2023
b8c600c
Remove properties, add doc, fix template
chevdor Oct 26, 2023
026f53f
Require prdoc image v0.0.7
chevdor Oct 26, 2023
196e1fd
Rename runtime migration pallet into reference
chevdor Oct 27, 2023
1cdbd0b
Fix EOL
chevdor Oct 27, 2023
bacbe8c
Revert back to the parity image
chevdor Oct 27, 2023
93bb975
Update prdoc/schema_user.json
chevdor Nov 9, 2023
781f75e
Update docs/prdoc.md
chevdor Nov 9, 2023
bb19a12
Update docs/prdoc.md
chevdor Nov 9, 2023
0eca03c
Merge branch 'master' into wk-231018-prdoc-new-schema
chevdor Nov 9, 2023
26014fc
Merge branch 'master' into wk-231018-prdoc-new-schema
chevdor Nov 9, 2023
341c1d3
Merge branch 'master' into wk-231018-prdoc-new-schema
chevdor Nov 20, 2023
bab8f29
Merge branch 'master' into wk-231018-prdoc-new-schema
chevdor Nov 20, 2023
148175f
Remove semver from the schema
chevdor Nov 21, 2023
36547bd
Merge branch 'master' into wk-231018-prdoc-new-schema
chevdor Nov 21, 2023
661ebc8
Merge branch 'master' into wk-231018-prdoc-new-schema
chevdor Nov 23, 2023
80b8b23
Merge branch 'master' into wk-231018-prdoc-new-schema
chevdor Nov 25, 2023
6c5a33e
Merge branch 'master' into wk-231018-prdoc-new-schema
chevdor Nov 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions .github/workflows/check-prdoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ on:
types: [labeled, opened, synchronize, unlabeled]

env:
IMAGE: paritytech/prdoc:v0.0.5
IMAGE: docker.io/paritytech/prdoc:v0.0.6
API_BASE: https://api.github.com/repos
REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PR: ${{ github.event.pull_request.number }}
MOUNT: /prdoc
ENGINE: docker

jobs:
check-prdoc:
runs-on: ubuntu-latest
steps:
# we cannot show the version in this step (ie before checking out the repo)
# due to https://github.com/paritytech/prdoc/issues/15
- name: Pull image
run: |
echo "Pulling $IMAGE"
docker pull $IMAGE
docker run --rm $IMAGE --version
$ENGINE pull $IMAGE

- name: Check if PRdoc is required
id: get-labels
Expand All @@ -32,18 +32,27 @@ jobs:
echo "Labels: ${labels}"
echo "labels=${labels}" >> "$GITHUB_OUTPUT"

- name: No PRdoc required
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1

- name: Check PRDoc version
run: |
$ENGINE run --rm -v $PWD:/repo $IMAGE --version

- name: Early exit if PR is silent
if: ${{ contains(steps.get-labels.outputs.labels, 'R0') }}
run: |
echo "PR detected as silent, no PRdoc is required, exiting..."
hits=$(find prdoc -name "pr_$GITHUB_PR*.prdoc" | wc -l)
if (( hits > 0 )); then
echo "PR detected as silent, but a PRDoc was found, checking it as information"
$ENGINE run --rm -v $PWD:/repo $IMAGE check -n ${GITHUB_PR} || echo "Ignoring failure"
else
echo "PR detected as silent, no PRDoc found, exiting..."
chevdor marked this conversation as resolved.
Show resolved Hide resolved
fi
exit 0

- name: Checkout repo
if: ${{ !contains(steps.get-labels.outputs.labels, 'R0') }}
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1

- name: PRdoc check for PR#${{ github.event.pull_request.number }}
if: ${{ !contains(steps.get-labels.outputs.labels, 'R0') }}
run: |
echo "Checking for PR#${GITHUB_PR} in $MOUNT"
$ENGINE run --rm -v $PWD/prdoc:/doc $IMAGE check -n ${GITHUB_PR} || true
echo "Checking for PR#${GITHUB_PR}"
$ENGINE run --rm -v $PWD:/repo $IMAGE check -n ${GITHUB_PR}
7 changes: 7 additions & 0 deletions .prdoc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Config file for prdoc, see https://github.com/paritytech/prdoc

version = 1
schema = "prdoc/schema_user.json"
output_dir = "prdoc"
prdoc_folders = ["prdoc"]
template = "prdoc/.template.prdoc"
14 changes: 2 additions & 12 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,12 @@ The reviewers are also responsible to check:

All Pull Requests must contain proper title & description.

Some Pull Requests can be exempt of `prdoc` documentation, those
must be labelled with
Some Pull Requests can be exempt of `prdoc` documentation, those must be labelled with
[`R0-silent`](https://github.com/paritytech/labels/blob/main/ruled_labels/specs_polkadot-sdk.yaml#L89-L91).

Non "silent" PRs must come with documentation in the form of a `.prdoc` file.
chevdor marked this conversation as resolved.
Show resolved Hide resolved
A `.prdoc` documentation is made of a text file (YAML) named `/prdoc/pr_NNNN.prdoc` where `NNNN` is the PR number.
For convenience, those file can also contain a short description/title: `/prdoc/pr_NNNN_pr-foobar.prdoc`.

The CI automation checks for the presence and validity of a `prdoc` in the `/prdoc` folder.
Those files need to comply with a specific [schema](https://github.com/paritytech/prdoc/blob/master/schema_user.json). It
is highly recommended to [make your editor aware](https://github.com/paritytech/prdoc#schemas) of the schema as it is
self-described and will assist you in writing correct content.

This schema is also embedded in the
[prdoc](https://github.com/paritytech/prdoc) utility that can also be used to generate and check the validity of a
`prdoc` locally.
See more about `prdoc` [here](./prdoc.md)

## Helping out

Expand Down
6 changes: 5 additions & 1 deletion docs/DOCUMENTATION_GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ For the top-level pallet docs, consider the following template:
//!
//! ## Pallet API
//!
//! <Reminder: inside the [`pallet`] module, a template that leads the reader to the relevant items is auto-generated. There is no need to repeat
//! <Reminder: inside the [`pallet`] module, a template that leads the reader to the relevant items is auto-generated. There is no need to repeat
//! things like "See Config trait for ...", which are generated inside [`pallet`] here anyways. You can use the line below as-is:>
//!
//! See the [`pallet`] module for more information about the interfaces this pallet exposes, including its
Expand Down Expand Up @@ -349,3 +349,7 @@ Consider the fact that, similar to dispatchables, these docs will be part of the
and might be used by wallets and explorers.

Specifically for `error`, explain why the error has happened, and what can be done in order to avoid it.

## Documenting Changes/PR

See [PRDoc](./prdoc.md).
50 changes: 50 additions & 0 deletions docs/prdoc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# PRDoc

## Intro

With the merge of [PR #1946](https://github.com/paritytech/polkadot-sdk/pull/1946), a new method for
documenting changes has been introduced: `prdoc`. The [prdoc repository](https://github.com/paritytech/prdoc)
contains more documentation and tooling.

The current document describes how to quickly get started authoring `PRDoc` files.

## Requirements

When creating a PR, the author needs to decides with the `R0` label whether the change (PR) should
appear in the release notes or not.

Labelling a PR with `R0` means that no `PRDoc` is required.

A PR without the `R0` label **does** require a valid `PRDoc` file to be introduced in the PR.

## PRDoc how-to

A `.prdoc` file is a YAML file with a defined structure (ie JSON Schema).

For significant changes, a `.prdoc` file is mandatory and the file must meet the following
requirements:
- file named `pr_NNNN.prdoc` where `NNNN` is the PR number.
For convenience, those file can also contain a short description: `pr_NNNN_foobar.prdoc`.
- located under the [`prdoc` folder](https://github.com/paritytech/polkadot-sdk/tree/master/prdoc) of the repository
- compliant with the [JSON schema](https://json-schema.org/) defined in `prdoc/schema_user.json`

Those requirements can be fulfilled manually without any tooling but a text editor.
chevdor marked this conversation as resolved.
Show resolved Hide resolved

## Tooling

Users might find the following helpers convenient:
- Setup VSCode to be aware of the prdoc schema: see [using VSCode](https://github.com/paritytech/prdoc#using-vscode)
- Using the `prdoc` cli to:
- generate a `PRDoc` file from a [template defined in the Polkadot SDK
repo](https://github.com/paritytech/polkadot-sdk/blob/master/prdoc/.template.prdoc) simply providing a PR number
- check the validity of one or more `PRDoc` files
chevdor marked this conversation as resolved.
Show resolved Hide resolved

## Tips

The PRDoc schema is defined in each repo and usually is quite restrictive.
You cannot simply add a new property to a `PRDoc` file unless the Schema allows it.

There are however a few convenience optional properties that could be useful to authors:
- `authors`: An array of authors (strings). That can help an author find their PRs easily
- `tags`: Array of strings. Those are unrelated to the Github Labels and provided for
authors to flag their changes as they wish, in order to find PR and Documentation quicker
chevdor marked this conversation as resolved.
Show resolved Hide resolved
18 changes: 18 additions & 0 deletions prdoc/.template.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: ...

doc:
- audience: Node Dev
description: |
...

migrations:
db: []

runtime: []

crates: []

host_functions: []
4 changes: 2 additions & 2 deletions prdoc/pr_1226.prdoc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
title: Removed deprecated `Balances::transfer` and `Balances::set_balance_deprecated` functions.

doc:
- audience: Builder
- audience: Runtime User
description: The Balances pallet's dispatchables `set_balance_deprecated` and `transfer` were deprecated in [paritytech/substrate#12951](https://github.com/paritytech/substrate/pull/12951) and have now been removed.
notes:
notes:
- Use `set_balance_deprecated` instead `force_set_balance` and `transfer_allow_death` instead of `transfer`.

migrations:
Expand Down
2 changes: 1 addition & 1 deletion prdoc/pr_1234.prdoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
title: Introduce XcmFeesToAccount fee manager

doc:
- audience: Builder
- audience: Runtime User
description: |
Now all XCM sending, unless done by the system for the system, will be charged delivery fees.
All runtimes are now configured to send these delivery fees to a treasury account.
Expand Down
4 changes: 2 additions & 2 deletions prdoc/pr_1255.prdoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
title: Fix for Reward Deficit in the pool

doc:
- audience: Core Dev
- audience: Runtime Dev
description: Instead of fragile calculation of current balance by looking at free balance - ED, Nomination Pool now freezes ED in the pool reward account to restrict an account from going below minimum balance. This also has a nice side effect that if ED changes, we know how much is the imbalance in ED frozen in the pool and the current required ED. A pool operator can diligently top up the pool with the deficit in ED or vice versa, withdraw the excess they transferred to the pool.
notes:
- Introduces new call `adjust_pool_deposit` that allows to top up the deficit or withdraw the excess deposit for the pool.
Expand All @@ -19,4 +19,4 @@ migrations:
crates:
- name: pallet-nomination-pools

host_functions: []
host_functions: []
2 changes: 1 addition & 1 deletion prdoc/pr_1408_prodc-introduction.prdoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: PRdoc check

doc:
- audience: Core Dev
- audience: Node Dev
description: |
This PRdoc is an **example**.

Expand Down
2 changes: 1 addition & 1 deletion prdoc/pr_1818.prdoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
title: FRAME pallets warning for unchecked weight witness

doc:
- audience: Core Dev
- audience: Runtime Dev
description: |
FRAME pallets now emit a warning when a call uses a function argument that starts with an underscore in its weight declaration.

Expand Down
6 changes: 4 additions & 2 deletions prdoc/pr_1873.prdoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
title: Message Queue use proper overweight limit

doc:
- audience: Core Dev
- audience: Node Dev
description: |
Changed the overweight cutoff limit from the full `Config::ServiceWeight` to a lower value that is calculated based on the weight of the functions being called.

Expand All @@ -10,6 +10,8 @@ migrations:

runtime: []

crates: ["pallet-message-queue", patch]
crates:
- name: pallet-message-queue
semver: patch

host_functions: []
2 changes: 1 addition & 1 deletion prdoc/pr_1921.prdoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
title: Fix para-scheduler migration

doc:
- audience: Core Dev
- audience: Runtime Dev
description: |
Changing the `MigrateToV1` migration in the `ParachainScheduler` pallet to be truly idempotent. It is achieved by wrapping it in a `VersionedMigration`.

Expand Down
23 changes: 23 additions & 0 deletions prdoc/pr_1946_prdoc_new_schema.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://github.com/paritytech/prdoc

title: New PRDoc Schema
authors: [ chevdor ]
tags: [ prdoc, release ]
chevdor marked this conversation as resolved.
Show resolved Hide resolved

doc:
- audience: Node Dev
description: &desc |
The new version of prdoc and the new schema is activated in this PR.

- audience: Runtime Dev
description: *desc

migrations:
db: []

runtime: []

crates: []

host_functions: []
Loading