Skip to content

Commit eaf380a

Browse files
authored
Add PRdoc check (#1408)
* Add test prdoc * Prepare for the check * Escape PR number * Fix conditional step * Add checkout and actual check * Cleanup * Minor fixes * Add doumentation * Add more doc
1 parent 7986b12 commit eaf380a

File tree

5 files changed

+96
-8
lines changed

5 files changed

+96
-8
lines changed

.github/workflows/check-prdoc.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Check PRdoc
2+
3+
on:
4+
pull_request:
5+
types: [labeled, opened, synchronize, unlabeled]
6+
7+
env:
8+
# todo: switch to paritytech/prdoc once the container is built & published
9+
# see https://github.com/paritytech/scripts/pull/595
10+
IMAGE: chevdor/prdoc:v0.0.4
11+
API_BASE: https://api.github.com/repos
12+
REPO: ${{ github.repository }}
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
GITHUB_PR: ${{ github.event.pull_request.number }}
15+
MOUNT: /prdoc
16+
ENGINE: docker
17+
18+
jobs:
19+
check-prdoc:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Pull image
23+
run: |
24+
echo "Pulling $IMAGE"
25+
docker pull $IMAGE
26+
docker run --rm $IMAGE --version
27+
28+
- name: Check if PRdoc is required
29+
id: get-labels
30+
run: |
31+
# Fetch the labels for the PR under test
32+
echo "Fetch the labels for $API_BASE/${REPO}/pulls/${GITHUB_PR}"
33+
labels=$( curl -H "Authorization: token ${GITHUB_TOKEN}" -s "$API_BASE/${REPO}/pulls/${GITHUB_PR}" | jq '.labels | .[] | .name' | tr "\n" ",")
34+
echo "Labels: ${labels}"
35+
echo "labels=${labels}" >> "$GITHUB_OUTPUT"
36+
37+
- name: No PRdoc required
38+
if: ${{ contains(steps.get-labels.outputs.labels, 'R0') }}
39+
run: |
40+
echo "PR detected as silent, no PRdoc is required, exiting..."
41+
exit 0
42+
43+
- name: Checkout repo
44+
if: ${{ !contains(steps.get-labels.outputs.labels, 'R0') }}
45+
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0
46+
47+
- name: PRdoc check for PR#${{ github.event.pull_request.number }}
48+
if: ${{ !contains(steps.get-labels.outputs.labels, 'R0') }}
49+
run: |
50+
echo "Checking for PR#$GITHUB_PR in $MOUNT"
51+
$ENGINE run --rm -v $PWD/prdoc:/doc $IMAGE check -n 1408

cumulus/scripts/ci/changelog/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ all the labels that are used, search for `meta` in the templates. Currently, the
6161
Note that labels with the same letter are mutually exclusive. A PR should not have both `B0` and `B5`, or both `C1` and
6262
`C9`. In case of conflicts, the template will decide which label will be considered.
6363

64-
## Dev and debuggin
64+
## Dev and debugging
6565

6666
### Hot Reload
6767

docs/CONTRIBUTING.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,36 @@ Reviews should finish with approval unless there are issues that would result in
8080

8181
The reviewers are also responsible to check:
8282

83-
a) if a changelog is necessary and attached
84-
85-
b) the quality of information in the changelog file
86-
87-
c) the PR has an impact on docs
88-
89-
d) that the docs team was included in the review process of a docs update
83+
1. if a changelog is necessary and attached
84+
1. the quality of information in the changelog file
85+
1. the PR has an impact on docs
86+
1. that the docs team was included in the review process of a docs update
9087

9188
**Reviews may not be used as an effective veto for a PR because**:
9289
1. There exists a somewhat cleaner/better/faster way of accomplishing the same feature/fix.
9390
2. It does not fit well with some other contributors' longer-term vision for the project.
9491

92+
## Documentation
93+
94+
All Pull Requests must contain proper title & description.
95+
96+
Some Pull Requests can be exempt of `prdoc` documentation, those
97+
must be labelled with
98+
[`R0-silent`](https://github.com/paritytech/labels/blob/main/ruled_labels/specs_polkadot-sdk.yaml#L89-L91).
99+
100+
Non "silent" PRs must come with documentation in the form of a `.prdoc` file.
101+
A `.prdoc` documentation is made of a text file (YAML) named `/prdoc/pr_NNNN.prdoc` where `NNNN` is the PR number.
102+
For convenience, those file can also contain a short description/title: `/prdoc/pr_NNNN_pr-foobar.prdoc`.
103+
104+
The CI automation checks for the presence and validity of a `prdoc` in the `/prdoc` folder.
105+
Those files need to comply with a specific [schema](https://github.com/paritytech/prdoc/blob/master/schema_user.json). It
106+
is highly recommended to [make your editor aware](https://github.com/paritytech/prdoc#schemas) of the schema as it is
107+
self-described and will assist you in writing correct content.
108+
109+
This schema is also embedded in the
110+
[prdoc](https://github.com/paritytech/prdoc) utility that can also be used to generate and check the validity of a
111+
`prdoc` locally.
112+
95113
## Helping out
96114

97115
We use [labels](https://github.com/paritytech/polkadot-sdk/labels) to manage PRs and issues and communicate

prdoc/.gitkeep

Whitespace-only changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This PR does not need a prdoc but it is provided in order to test
2+
title: PRdoc check
3+
4+
doc:
5+
- audience: Core Dev
6+
description: |
7+
This PRdoc is an **example**.
8+
9+
This PR brings support and automated checks for documentation in the form of a
10+
[`prdoc`](https://github.com/paritytech/prdoc/) file.
11+
12+
migrations:
13+
db: []
14+
15+
runtime: []
16+
17+
crates: []
18+
19+
host_functions: []

0 commit comments

Comments
 (0)