1
0
mirror of https://github.com/arduino/library-registry.git synced 2025-07-14 22:21:02 +03:00

Automate the Library Manager submission process

Submissions of libraries to the Arduino Library Manager index can be done by submitting a pull request adding repositor
URLs to the list. The submissions are checked for compliance wih the requirements for addition to the index and as soon
as they are passing the pull request is merged and the entries are pushed to the index source file.
This commit is contained in:
per1234
2021-01-18 22:18:41 -08:00
parent 8a67c16fad
commit 050ac29d24
19 changed files with 2131 additions and 0 deletions

38
.github/workflows/check-config.yml vendored Normal file
View File

@ -0,0 +1,38 @@
name: Check configuration files
on:
push:
paths:
- ".github/workflows/check-config.yml"
- "Taskfile.yml"
- "**.yml"
- "**.yaml"
- "**.json"
pull_request:
paths:
- ".github/workflows/check-config.yml"
- "Taskfile.yml"
- "**.yml"
- "**.yaml"
- "**.json"
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch
workflow_dispatch:
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#repository_dispatch
repository_dispatch:
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout local repository
uses: actions/checkout@v2
- name: Install Taskfile
uses: arduino/actions/setup-taskfile@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Check formatting
run: task config:check-formatting

37
.github/workflows/check-docs.yml vendored Normal file
View File

@ -0,0 +1,37 @@
name: Check documentation files
on:
push:
paths:
- ".github/workflows/check-docs.yml"
- "Taskfile.yml"
- "**.md"
pull_request:
paths:
- ".github/workflows/check-docs.yml"
- "Taskfile.yml"
- "**.md"
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch
workflow_dispatch:
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#repository_dispatch
repository_dispatch:
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout local repository
uses: actions/checkout@v2
- name: Install Taskfile
uses: arduino/actions/setup-taskfile@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Check links
run: task docs:check-links
- name: Check formatting
run: task docs:check-formatting

45
.github/workflows/check-go.yml vendored Normal file
View File

@ -0,0 +1,45 @@
name: Check Go code
on:
push:
paths:
- ".github/workflows/check-go.yml"
- "Taskfile.yml"
- "manager/**"
pull_request:
paths:
- ".github/workflows/check-go.yml"
- "Taskfile.yml"
- "manager/**"
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch
workflow_dispatch:
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#repository_dispatch
repository_dispatch:
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout local repository
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.14"
- name: Install Taskfile
uses: arduino/actions/setup-taskfile@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Lint
run: task go:lint
- name: Run tests
run: task go:test
- name: Check formatting
run: task go:check-formatting

44
.github/workflows/check-license.yml vendored Normal file
View File

@ -0,0 +1,44 @@
name: Check license
on:
push:
paths:
- ".github/workflows/check-license.yml"
- "Taskfile.yml"
# Recognized license files. See: https://github.com/licensee/licensee/blob/master/docs/what-we-look-at.md#detecting-the-license-file
- "COPYING*"
- "LICENCE*"
- "LICENSE*"
pull_request:
paths:
- ".github/workflows/check-license.yml"
- "Taskfile.yml"
# Recognized license files. See: https://github.com/licensee/licensee/blob/master/docs/what-we-look-at.md#detecting-the-license-file
- "COPYING*"
- "LICENCE*"
- "LICENSE*"
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout local repository
uses: actions/checkout@v2
- name: Install Taskfile
uses: arduino/actions/setup-taskfile@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- uses: ruby/setup-ruby@v1
with:
ruby-version: ruby # Install latest version
- name: Install licensee
run: gem install licensee
# See: https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/licensing-a-repository
- name: Check license file
run: task --silent docs:check-license

319
.github/workflows/manage-prs.yml vendored Normal file
View File

@ -0,0 +1,319 @@
name: Manage PRs
on:
# pull_request_target trigger is used instead of pull_request so the token will have the write permissions needed to comment and merge.
# Note that this means the version of the workflow from the PR base ref will be used as opposed to the head ref, as is the case with pull_request triggered workflows.
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target
pull_request_target:
types:
- opened
- ready_for_review
- synchronize
issue_comment:
types:
- created
- edited
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#workflow_dispatch
workflow_dispatch:
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#repository_dispatch
repository_dispatch:
jobs:
enabled:
if: >
github.event_name == 'pull_request_target' ||
(
github.event_name == 'issue_comment' &&
github.event.issue.pull_request != '' &&
github.event.issue.state == 'open' &&
contains(github.event.comment.body, 'ArduinoBot')
)
runs-on: ubuntu-latest
steps:
- name: Dummy step to make job valid
run: ""
parse:
needs:
- enabled
runs-on: ubuntu-latest
outputs:
type: ${{ steps.parse-request.outputs.type }}
submissions: ${{ steps.parse-request.outputs.submissions }}
index-entry: ${{ steps.parse-request.outputs.index-entry }}
steps:
- name: Set environment variables
run: |
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
echo "MANAGER_PATH=${{ runner.temp }}/manager" >> "$GITHUB_ENV"
echo "INDEX_SOURCE_REPOSITORY_CHECKOUT_PATH=bcmi-labs/libraries-repository-engine" >> "$GITHUB_ENV"
echo "INDEX_SOURCE_PATH=repositories.txt" >> "$GITHUB_ENV" # Path of the LM index file under its repository.
- name: Checkout local repository
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
- name: Install Taskfile
uses: arduino/actions/setup-taskfile@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
# For security reasons, this must be done before checking out the PR branch.
- name: Build manager
env:
GO_BUILD_FLAGS: -o $MANAGER_PATH
run: task go:build
- name: Checkout PR branch
run: |
# https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/checking-out-pull-requests-locally
# It's necessary to reference both pull_request.number and issue.number because only one of the two are defined depending on whether the workflow is triggered by PR or comment event.
git fetch origin pull/${{ github.event.pull_request.number }}${{ github.event.issue.number }}/head:pr-branch
git checkout pr-branch
- name: Checkout index source list
uses: actions/checkout@v2
with:
repository: bcmi-labs/libraries-repository-engine
ref: production
token: ${{ secrets.REPO_SCOPE_TOKEN }}
path: ${{ env.INDEX_SOURCE_REPOSITORY_CHECKOUT_PATH }}
- name: Parse request
id: parse-request
run: |
REQUEST="$("$MANAGER_PATH" --baseref="${{ github.sha }}" --repopath="${{ github.workspace }}" --listname="repositories.txt" --indexsourcepath="${{ env.INDEX_SOURCE_REPOSITORY_CHECKOUT_PATH }}/${{ env.INDEX_SOURCE_PATH }}")"
# Due to limitations of the GitHub Actions workflow system, dedicated outputs must be created for use in certain workflow fields.
echo "::set-output name=type::$(echo "$REQUEST" | jq -r -c '.type')"
echo "::set-output name=submissions::$(echo "$REQUEST" | jq -c '.submissions')"
echo "::set-output name=index-entry::$(echo "$REQUEST" | jq -r -c '.indexEntry')"
label:
needs:
- enabled
- parse
runs-on: ubuntu-latest
steps:
- name: Label PR
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: PUT /repos/{owner}/{repo}/issues/{issue_number}/labels
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
labels: |
- ${{ needs.parse.outputs.type }}
check-submissions:
needs:
- enabled
- parse
if: needs.parse.outputs.type == 'submission'
runs-on: ubuntu-latest
strategy:
fail-fast: false
# A matrix job will run for each of the submission URLs
matrix:
submission: ${{ fromJson(needs.parse.outputs.submissions) }}
steps:
- name: Set environment variables
run: |
echo "REPORT_PATH=${{ runner.temp }}/report.json" >> "$GITHUB_ENV"
- name: Comment on error detected while parsing submission
if: matrix.submission.error != ''
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# NOTE: "Unexpected input(s) ..." warnings for the arbitrary octokit/request-action inputs are normal and expected.
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
body: |
|
A problem was found with your submission ${{ matrix.submission.submissionURL }}
${{ matrix.submission.error }}
- name: Fail on error detected while parsing
if: matrix.submission.error != ''
run: |
echo "::error::Error found with submission"
exit 1
- name: Clone submission
run: git clone --branch ${{ matrix.submission.tag }} --depth 1 ${{ matrix.submission.normalizedURL }} "${{ matrix.submission.name }}"
- name: Lint submission
id: arduino-lint
uses: arduino/arduino-lint-action@v1
continue-on-error: true # Continue the job so the report can be commented to the PR
with:
library-manager: submit
project-type: library
compliance: permissive
official: ${{ matrix.submission.official }}
path: ${{ matrix.submission.name }}
report-file: ${{ env.REPORT_PATH }}
- name: Read Arduino Lint report
id: read-lint-report
run: |
echo "::set-output name=report::$(jq -c . "${{ env.REPORT_PATH }}")"
- name: Comment on Arduino Lint warning
if: fromJson(steps.read-lint-report.outputs.report).summary.warningCount > 0 && fromJson(steps.read-lint-report.outputs.report).summary.errorCount == 0
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
body: |
|
[Arduino Lint](https://github.com/arduino/arduino-lint) has suggestions for possible improvements to ${{ matrix.submission.submissionURL }}:
```json
${{ toJson(fromJson(steps.read-lint-report.outputs.report).projects) }}
```
- name: Comment on Arduino Lint error
if: fromJson(steps.read-lint-report.outputs.report).summary.errorCount > 0
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
body: |
|
[Arduino Lint](https://github.com/arduino/arduino-lint) found errors with ${{ matrix.submission.submissionURL }}:
```json
${{ toJson(fromJson(steps.read-lint-report.outputs.report).projects) }}
```
- name: Fail on Arduino Lint error
if: steps.arduino-lint.outcome == 'failure'
run: |
echo "::error::Arduino Lint detected an error"
exit 1
check-submissions-fail:
needs:
- enabled
- check-submissions
if: failure() # This job will only run if the submission checks failed
runs-on: ubuntu-latest
steps:
- name: Comment instructions to fix errors detected during submission checks
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
body: |
|
Thanks for your interest in contributing to the Arduino Library Manager index @${{ github.actor }}
Please resolve the error(s) mentioned in the previous comment.
After resolving the issue, trigger this check again by doing one of the following:
- Commit the required change to the branch you submitted this pull request from.
- Comment here, mentioning @ArduinoBot in the comment
More information: https://github.com/${{ github.repository }}/main/README.md#if-the-problem-is-with-the-pull-request"
merge:
needs:
- enabled
- parse
- check-submissions
if: success() # This job will only run if the submission checks passed
runs-on: ubuntu-latest
steps:
- name: Merge pull request
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
- name: Checkout index source file repo
uses: actions/checkout@v2
with:
repository: bcmi-labs/libraries-repository-engine
ref: production
token: ${{ secrets.REPO_SCOPE_TOKEN }}
- name: Add entry to index source file
run: |
INDEX_SOURCE_FILE_PATH="${{ github.workspace }}/repositories.txt"
echo "${{ needs.parse.outputs.index-entry }}" >> "$INDEX_SOURCE_FILE_PATH"
git config --global user.email "bot@arduino.cc"
git config --global user.name "ArduinoBot"
git add --update "$INDEX_SOURCE_FILE_PATH"
echo -e "Add submission # ${{ github.event.pull_request.number }}${{ github.event.issue.number }}\n\n${{ github.event.repository.html_url }}/pull/${{ github.event.pull_request.number }}${{ github.event.issue.number }}" | git commit --file -
git push
request-review:
needs:
- enabled
- parse
if: needs.parse.outputs.type != 'submission' # These request types can't be automatically approved.
runs-on: ubuntu-latest
steps:
- name: Request pull request review
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
team_reviewers: |
- arduino/team_tooling
- name: Comment on required review
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
body: |
|
Hi @${{ github.actor }}. Your pull request has been detected as something other than a Library Manager submission. A maintainer will need to review it before it can be merged.
If you intended to submit a library, please check the instructions and update your pull request if necessary:
https://github.com/${{ github.repository }}/main/README.md#instructions

37
.github/workflows/spell-check.yml vendored Normal file
View File

@ -0,0 +1,37 @@
name: Spell Check
on:
pull_request:
paths-ignore:
- "repositories.txt"
push:
paths-ignore:
- "repositories.txt"
schedule:
# Run every Tuesday at 03:00 UTC to catch breakage caused by updates to the dictionary
- cron: "0 3 * * 2"
jobs:
spellcheck:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install Poetry
run: pip install poetry
- name: Install Taskfile
uses: arduino/actions/setup-taskfile@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Spell check
run: task check-spelling