-
-
Notifications
You must be signed in to change notification settings - Fork 407
134 lines (117 loc) · 5.03 KB
/
newly-added-rfcs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Newly Added RFC
# Runs various checks on pull requests that add new RFCs
on:
pull_request:
types: [opened, labeled, unlabeled, synchronize, reopened, ready_for_review]
paths:
- 'text/*.md'
jobs:
check-rfcs:
name: Does PR add RFCs?
runs-on: ubuntu-latest
outputs:
rfcs-added: ${{ steps.rfcs.outputs.added-rfcs-count > 0 }}
rfcs-changed: ${{ steps.rfcs.outputs.modified-rfcs-count }}
modified-rfc: ${{ steps.rfcs.outputs.modified-rfc }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: RFCs Added or Changed
id: rfcs
uses: ./.github/actions/find-added-or-modified-rfcs
- name: Debug output
run: |
echo "RFC Added count: ${{ steps.rfcs.outputs.added-rfcs-count }}"
echo "RFC Changed count: ${{ steps.rfcs.outputs.modified-rfcs-count }}"
echo "RFC: ${{ steps.rfcs.outputs.modified-rfc }}"
if [[ ${{ steps.rfcs.outputs.added-rfcs-count }} == 1 ]]; then
echo "## RFC Added in this PR!!!" >> $GITHUB_STEP_SUMMARY
elif [[ ${{steps.rfcs.outputs.added-rfcs-count}} == 0 ]]; then
echo "## No RFCs added in this PR" >> $GITHUB_STEP_SUMMARY
fi
check-in-exploring:
name: Stage must be 'Exploring' (via label) for new RFC before merging
if: needs.check-rfcs.outputs.rfcs-added == 'true'
runs-on: ubuntu-latest
needs: [check-rfcs]
steps:
- name: Ensure the RFC is in the Exploring Stage before merge is allowed
if: ${{ !contains(github.event.pull_request.labels.*.name, 'S-Exploring') }}
run: |
echo "::error::Newly added RFCs must advance to the Exploring Stage (via label) before merging to Accepted is allowed"
exit 1
verify-only-in-one-stage:
name: RFC must be in only one stage before merging (labels)
runs-on: ubuntu-latest
needs: [check-rfcs]
if: needs.check-rfcs.outputs.rfcs-added == 'true'
steps:
- name: Ensure the RFC only has one stage
if: contains(github.event.pull_request.labels.*.name, 'S-Exploring') && contains(github.event.pull_request.labels.*.name, 'S-Proposed')
run: |
echo "::error::Newly added RFC must only have one stage label"
exit 1
only-one-rfc-added:
name: Only one RFC can be added in a PR
runs-on: ubuntu-latest
needs: [ check-rfcs ]
if: needs.check-rfcs.outputs.rfcs-added == 'true'
steps:
- name: Fail if more than 1 RFC is added or modified
if: ${{ needs.check-rfcs.outputs.rfcs-changed > 1}}
run: |
echo "::error::More than 1 RFC is added or modified in this PR; will be unable to automatically open PRs for advancement"
exit 1
frontmatter-stage-is-accepted:
name: Frontmatter stage must be 'accepted' before merging
runs-on: ubuntu-latest
needs: [ check-rfcs ]
if: needs.check-rfcs.outputs.rfcs-added == 'true'
steps:
- uses: actions/checkout@v3
- name: Setup RFCs tooling
uses: ./.github/actions/setup-rfcs-tooling
- name: Verify stage of newly added RFC is `accepted` in frontmatter
run: |
frontmatter=`node rfcs-tooling/scripts/rfc-frontmatter.mjs ${{ needs.check-rfcs.outputs.modified-rfc }}`
stage=`echo $frontmatter | jq '.stage'`
if [[ $stage != '"accepted"' ]]; then
echo "::error::Newly added RFCs must have the stage 'accepted' in the frontmatter"
exit 1
fi
check-filename:
name: Filename matches RFC number
runs-on: ubuntu-latest
needs: [ check-rfcs ]
if: needs.check-rfcs.outputs.rfcs-added == 'true'
steps:
- uses: actions/checkout@v3
- name: Setup RFCs tooling
uses: ./.github/actions/setup-rfcs-tooling
- name: Test RFC Filename matches PR Number that adds it
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: node rfcs-tooling/scripts/check-filename-matches-pr.mjs $PR_NUMBER ${{ needs.check-rfcs.outputs.modified-rfc }}
check-accepted-pr-url:
name: Verify Accepted PR URL is correct
runs-on: ubuntu-latest
needs: [ check-rfcs ]
if: needs.check-rfcs.outputs.rfcs-added == 'true'
steps:
- uses: actions/checkout@v3
- name: Setup RFCs tooling
uses: ./.github/actions/setup-rfcs-tooling
- name: Verify Accepted PR URL is correct
run: |
frontmatter=`node rfcs-tooling/scripts/rfc-frontmatter.mjs ${{ needs.check-rfcs.outputs.modified-rfc }}`
accepted_pr=`echo $frontmatter | jq '.prs.accepted'`
accepted_pr=${accepted_pr//\"/}
expected_pr="${{ github.event.pull_request.html_url }}"
expected_pr=${expected_pr//\"/}
if [[ $accepted_pr != $expected_pr ]]; then
echo "Accepted PR in frontmatter: $accepted_pr"
echo "Expected PR in frontmatter: $expected_pr"
echo "::error::Accepted PR URL is incorrect, please update the frontmatter prs.accepted to \"${{ github.event.pull_request.html_url }}\""
exit 1
fi