Skip to content

Commit eeecf63

Browse files
authored
Merge pull request #5754 from per1234/bump-parser
Add Library Registry access control system
2 parents 0dc8ffd + ff77898 commit eeecf63

File tree

5 files changed

+197
-4
lines changed

5 files changed

+197
-4
lines changed

.github/CONTRIBUTING.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Contributor Guide
2+
3+
Thanks for your interest in contributing to the **Arduino Library Manager Registry**!
4+
5+
## Support and Discussion
6+
7+
If you would like to request assistance or discuss the **Library Manager Registry**, please make a topic on **Arduino Forum**:
8+
9+
https://forum.arduino.cc/c/17
10+
11+
## Registration and Maintenance
12+
13+
---
14+
15+
⚠ If you behave irresponsibly in your interactions with this repository, your Library Manager Registry privileges will be revoked.
16+
17+
Carefully read and follow the instructions in any comments the bot and human maintainers make on your pull requests. If you are having trouble following the instructions, add a comment that provides a detailed description of the problem you are having and a human maintainer will provide assistance.
18+
19+
Although we have set up automation for the most basic tasks, this repository is maintained by humans. So behave in a manner appropriate for interacting with humans, including clearly communicating what you are hoping to accomplish.
20+
21+
---
22+
23+
If you would like to submit a library, or request registry maintenance for a library already in the registry, please follow the instructions provided in the documentation:
24+
25+
[**Click here to see the documentation**](../README.md#table-of-contents)
26+
27+
Make sure to read the relevant sections of the FAQ:
28+
29+
[**Click here to see the FAQ**](../FAQ.md#table-of-contents)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Access control for the Arduino Library Manager registry.
2+
# This file is used by https://github.com/arduino/library-registry-submission-parser, via the "Manage PRs" workflow.
3+
4+
# Allowlist
5+
- host: github.com
6+
name: per1234
7+
access: allow
8+
reference:
9+
10+
# Denylist
11+
- host: github.com
12+
name: 7Semi
13+
access: deny
14+
reference: https://github.com/arduino/library-registry/pull/5734#pullrequestreview-2548818476
15+
- host: github.com
16+
name: ajangrahmat
17+
access: deny
18+
reference: https://github.com/arduino/library-registry/pull/5706#issuecomment-2588923290
19+
- host: github.com
20+
name: brincode
21+
access: deny
22+
reference: https://github.com/arduino/library-registry/pull/4460#issuecomment-2589062464
23+
- host: github.com
24+
name: DefHam140
25+
access: deny
26+
reference: https://github.com/arduino/library-registry/pull/5265#issuecomment-2589039572
27+
- host: github.com
28+
name: ErlTechnologies
29+
access: deny
30+
reference: https://github.com/arduino/library-registry/pull/4873#issuecomment-2589138298
31+
- host: github.com
32+
name: kelasrobot
33+
access: deny
34+
reference: https://github.com/arduino/library-registry/pull/5706#issuecomment-2588923290
35+
- host: github.com
36+
name: Subodh-roy2
37+
access: deny
38+
reference: https://github.com/arduino/library-registry/pull/4422#issuecomment-2589051618
39+
- host: github.com
40+
name: vpbharath
41+
access: deny
42+
reference: https://github.com/arduino/library-registry/pull/4873#issuecomment-2589138298
43+
- host: github.com
44+
name: YoavPaz
45+
access: deny
46+
reference: https://github.com/arduino/library-registry/pull/5741#issuecomment-2589016403

.github/workflows/manage-prs.yml

Lines changed: 110 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Manage PRs
22

33
env:
4-
SUBMISSION_PARSER_VERSION: 1.1.1 # See: https://github.com/arduino/library-manager-submission-parser/releases
4+
SUBMISSION_PARSER_VERSION: 2.0.0 # See: https://github.com/arduino/library-manager-submission-parser/releases
55
MAINTAINERS: |
66
# GitHub user names to request reviews from in cases where PRs can't be managed automatically.
77
- per1234
@@ -125,6 +125,7 @@ jobs:
125125
runs-on: ubuntu-latest
126126

127127
outputs:
128+
conclusion: ${{ steps.parse-request.outputs.conclusion }}
128129
type: ${{ steps.parse-request.outputs.type }}
129130
error: ${{ steps.parse-request.outputs.error }}
130131
arduinoLintLibraryManagerSetting: ${{ steps.parse-request.outputs.arduinoLintLibraryManagerSetting }}
@@ -133,6 +134,8 @@ jobs:
133134
indexer-logs-urls: ${{ steps.parse-request.outputs.indexer-logs-urls }}
134135

135136
steps:
137+
# Checkout the tip of the default branch (this is the action's default ref input value when workflow is triggered
138+
# by an issue_comment or pull_request_target event).
136139
- name: Checkout local repository
137140
uses: actions/checkout@v4
138141

@@ -160,12 +163,15 @@ jobs:
160163
chmod u+x "${{ steps.download-parser.outputs.file-path }}"
161164
REQUEST="$( \
162165
"${{ steps.download-parser.outputs.file-path }}" \
166+
--accesslist=".github/workflows/assets/accesslist.yml" \
163167
--diffpath="${{ needs.diff.outputs.path }}/${{ needs.diff.outputs.filename }}" \
164168
--repopath="${{ github.workspace }}" \
165169
--listname="repositories.txt" \
170+
--submitter="${{ github.actor }}" \
166171
)"
167172
# Due to limitations of the GitHub Actions workflow system, dedicated outputs must be created for use in
168173
# certain workflow fields.
174+
echo "::set-output name=conclusion::$(echo "$REQUEST" | jq -r -c '.conclusion')"
169175
echo "::set-output name=type::$(echo "$REQUEST" | jq -r -c '.type')"
170176
echo "::set-output name=error::$(echo "$REQUEST" | jq -r -c '.error')"
171177
echo "::set-output name=arduinoLintLibraryManagerSetting::$(echo "$REQUEST" | jq -r -c '.arduinoLintLibraryManagerSetting')"
@@ -191,10 +197,13 @@ jobs:
191197
labels: |
192198
- "topic: ${{ needs.parse.outputs.type }}"
193199
200+
# Handle problem found by the parser that can potentially be resolved by requester.
194201
parse-fail:
195202
needs:
196203
- parse
197-
if: needs.parse.outputs.error != ''
204+
if: >
205+
needs.parse.outputs.conclusion != 'declined' &&
206+
needs.parse.outputs.error != ''
198207
199208
runs-on: ubuntu-latest
200209
steps:
@@ -219,13 +228,64 @@ jobs:
219228
More information:
220229
https://github.com/${{ github.repository }}/blob/main/README.md#if-the-problem-is-with-the-pull-request
221230
231+
# Requester's registry privileges have been revoked.
232+
decline-request:
233+
needs:
234+
- parse
235+
if: >
236+
needs.parse.outputs.conclusion == 'declined' &&
237+
needs.parse.outputs.error != ''
238+
runs-on: ubuntu-latest
239+
steps:
240+
- name: Comment reason for declining request
241+
uses: octokit/request-action@v2.x
242+
if: needs.parse.outputs.error != ''
243+
env:
244+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
245+
with:
246+
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
247+
owner: ${{ github.repository_owner }}
248+
repo: ${{ github.event.repository.name }}
249+
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
250+
body: |
251+
|
252+
Hi @${{ github.actor }}
253+
Your request has been declined:
254+
255+
${{ env.ERROR_MESSAGE_PREFIX }}${{ needs.parse.outputs.error }}
256+
257+
- name: Close PR
258+
uses: octokit/request-action@v2.x
259+
env:
260+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
261+
with:
262+
route: PATCH /repos/{owner}/{repo}/pulls/{pull_number}
263+
owner: ${{ github.repository_owner }}
264+
repo: ${{ github.event.repository.name }}
265+
pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
266+
state: closed
267+
268+
- name: Add conclusion label to PR
269+
uses: octokit/request-action@v2.x
270+
env:
271+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
272+
with:
273+
# See: https://docs.github.com/rest/issues/labels#add-labels-to-an-issue
274+
route: POST /repos/{owner}/{repo}/issues/{issue_number}/labels
275+
owner: ${{ github.repository_owner }}
276+
repo: ${{ github.event.repository.name }}
277+
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
278+
labels: |
279+
- "conclusion: ${{ needs.parse.outputs.conclusion }}"
280+
222281
check-submissions:
223282
name: Check ${{ matrix.submission.submissionURL }}
224283
needs:
225284
- parse
226285
if: >
227286
needs.parse.outputs.type == 'submission' ||
228287
needs.parse.outputs.type == 'modification'
288+
229289
runs-on: ubuntu-latest
230290
strategy:
231291
fail-fast: false
@@ -275,6 +335,15 @@ jobs:
275335
if: matrix.submission.error != ''
276336
run: echo "PASS=false" >> "$GITHUB_ENV"
277337

338+
# Parser checks are relevant in the case where request is declined due to registry access having been revoked for
339+
# the library repository owners. However, the rest of the checks are irrelevant and may result in confusing
340+
# comments from the bot, so should be skipped.
341+
- name: Skip the rest of the checks if request is declined
342+
if: >
343+
needs.parse.outputs.conclusion == 'declined' &&
344+
env.PASS == 'true'
345+
run: echo "PASS=false" >> "$GITHUB_ENV"
346+
278347
- name: Install Arduino Lint
279348
if: env.PASS == 'true'
280349
run: |
@@ -418,12 +487,15 @@ jobs:
418487
run: |
419488
test -d "${{ env.CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_PATH }}"
420489
490+
# Handle problem found by the submission checks that can potentially be resolved by requester.
421491
check-submissions-fail:
422492
needs:
493+
- parse
423494
- check-submissions-result
424-
if: needs.check-submissions-result.outputs.pass == 'false'
495+
if: >
496+
needs.parse.outputs.conclusion != 'declined' &&
497+
needs.check-submissions-result.outputs.pass == 'false'
425498
runs-on: ubuntu-latest
426-
427499
steps:
428500
- name: Comment instructions to fix errors detected during submission checks
429501
uses: octokit/request-action@v2.x
@@ -449,6 +521,37 @@ jobs:
449521
More information:
450522
https://github.com/${{ github.repository }}/blob/main/README.md#if-the-problem-is-with-the-pull-request
451523
524+
decline-submissions:
525+
needs:
526+
- parse
527+
- check-submissions
528+
if: needs.parse.outputs.conclusion == 'declined'
529+
runs-on: ubuntu-latest
530+
steps:
531+
- name: Close PR
532+
uses: octokit/request-action@v2.x
533+
env:
534+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
535+
with:
536+
route: PATCH /repos/{owner}/{repo}/pulls/{pull_number}
537+
owner: ${{ github.repository_owner }}
538+
repo: ${{ github.event.repository.name }}
539+
pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
540+
state: closed
541+
542+
- name: Add conclusion label to PR
543+
uses: octokit/request-action@v2.x
544+
env:
545+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
546+
with:
547+
# See: https://docs.github.com/rest/issues/labels#add-labels-to-an-issue
548+
route: POST /repos/{owner}/{repo}/issues/{issue_number}/labels
549+
owner: ${{ github.repository_owner }}
550+
repo: ${{ github.event.repository.name }}
551+
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
552+
labels: |
553+
- "conclusion: ${{ needs.parse.outputs.conclusion }}"
554+
452555
merge:
453556
needs:
454557
- diff
@@ -601,6 +704,7 @@ jobs:
601704
- parse
602705
# These request types can't be automatically approved.
603706
if: >
707+
needs.parse.outputs.conclusion != 'declined' &&
604708
needs.parse.outputs.type != 'submission' &&
605709
needs.parse.outputs.type != 'invalid'
606710
runs-on: ubuntu-latest
@@ -627,8 +731,10 @@ jobs:
627731
needs:
628732
# Run after all other jobs
629733
- parse-fail
734+
- decline-request
630735
- merge-fail
631736
- check-submissions-fail
737+
- decline-submissions
632738
- label
633739
- not-submission
634740
# Run if any job failed. The workflow is configured so that jobs only fail when there is an unexpected error.

FAQ.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ Follow the instructions [here](README.md#adding-a-library-to-library-manager).
7272

7373
### What are the requirements for a library to be added to Library Manager?
7474

75+
- [ ] The library must be something of potential value to the Arduino community.
76+
- [ ] The submitter must behave in a responsible manner in their interactions with the Library Manager Registry.
7577
- [ ] The library must be fully compliant with the [Arduino Library Specification](https://arduino.github.io/arduino-cli/latest/library-specification).
7678
- [ ] The library must have [a library.properties file](https://arduino.github.io/arduino-cli/latest/library-specification/#library-metadata), in compliance with the Arduino Library 1.5 format.
7779
- [ ] The library.properties file must be located in the root of the repository.

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ See the instructions below for detailed instructions on how to do this via the G
3333

3434
### Instructions
3535

36+
---
37+
38+
⚠ If you behave irresponsibly in your interactions with this repository, your Library Manager Registry privileges will be revoked.
39+
40+
Carefully read and follow the instructions in any comments the bot and human maintainers make on your pull requests. If you are having trouble following the instructions, add a comment that provides a detailed description of the problem you are having and a human maintainer will provide assistance.
41+
42+
Although we have set up automation for the most basic tasks, this repository is maintained by humans. So behave in a manner appropriate for interacting with humans, including clearly communicating what you are hoping to accomplish.
43+
44+
---
45+
3646
1. You may want to first take a look at
3747
[the requirements for admission into the Arduino Library Manager index](FAQ.md#submission-requirements). Each submission will be checked for
3848
compliance before being accepted.

0 commit comments

Comments
 (0)