1
0
mirror of https://github.com/arduino/library-registry.git synced 2025-11-05 10:50:36 +03:00
Commit Graph

118 Commits

Author SHA1 Message Date
per1234
e9352f1e53 Make "Check License" workflow path filter handle either YAML extension
There are two file extensions in common use for YAML files: `.yaml` and `.yml`. Although this project uses `.yml`
exclusively for YAML files, this is a standardized workflow which might be applied to projects that have established the
use of the other extension. It will be most flexible if it supports both.
2021-08-11 03:39:45 -07:00
per1234
0c1daad6e9 Remove reference comment from "Check License" workflow
Although very useful information, it doesn't apply directly to the licensee commands being run in this workflow step, and
thus might be confusing.
2021-08-11 03:39:45 -07:00
per1234
60c38f547a Add manual events as "Check License" workflow triggers
The `workflow_dispatch` event allows triggering the workflow via the GitHub web interface. This makes it easy to trigger
an immediate workflow run after some relevant external change.

The `repository_dispatch` event allows triggering workflows via the GitHub API. This might be useful for triggering an
immediate check in multiple relevant repositories after an external change, or some automated process. Although we don't
have any specific need for this event at the moment, the event has no impact on the workflow, so there is no reason
against having it. It is the sort of thing that can end up being useful if it is already in consistently in place, but
not worth setting up on demand, since the effort to set it up is greater than the effort to trigger all the workflows
manually.
2021-08-11 03:39:45 -07:00
per1234
a5ae9a22af Add source URL comment to "Check License" workflow
This will make it easier for the maintainers to sync fixes and improvements in either direction between the upstream
"template" workflow and its installation in this repository.
2021-08-11 03:39:45 -07:00
per1234
c8625b7cd7 Use standardized workflow/job/step names in "Check License" workflow
These are the naming conventions established in the standardized template workflow.
2021-08-11 03:39:44 -07:00
per1234
6a270f76f5 Require that PR head matches that of diff when merging
Due to the limitations imposed by by using both `pull_request_target` and `issue_comment` events to trigger the
"Manage PRs" workflow, the PR diff used for the validation is procured via a GitHub API request.

It is necessary to check that the pull request state matches that of the diff, which is achieved via the `sha` parameter
of the GitHub API request used to merge. This can not be determined from the `github` context provided by GitHub Actions
to the workflow for either of the trigger events, so the pull request metadata is requested from the GitHub API at the
same time as the diff.

This situation requires different handling by the `merge-fail` job. Fortunately, the two failure causes result in
different values from the merge request workflow step's `status` output.
2021-07-29 20:26:21 -07:00
per1234
03bdfa7974 Reduce likelihood of spurious merge conflict bot comment
Previously, the "Manage PRs" workflow made a comment suggesting to resolve the merge conflict after any failure to merge
a pull request. This comment is worded in a way that makes it somewhat applicable to other causes, but still might cause
the submitter to waste time unnecessarily trying to figure out how to merge a nonexistent merge conflict when the failure
had a different cause.

The 405 response is not specific to a failure due to merge conflict, but I believe that all failures due to merge
conflict will result in a 405. This means that the check is not perfect, but will make spurious mentions of merge
conflict resolution less likely at least.

A review is requested from a maintainer any time the merge fails, so they will be able to investigate and provide
assistance if necessary.
2021-07-29 20:10:56 -07:00
per1234
227b7d92b2 Merge pull request #282 from per1234/bump-parser
Bump library registry submission parser version used by "Manage PRs" workflow
2021-07-26 06:21:07 -07:00
per1234
014305a2cc Bump library registry submission parser
A new 1.1.0 version of `arduino/library-registry-submission-parser` is now available.
2021-07-26 06:16:25 -07:00
per1234
f8385ae72b Handle general problems with pull request
When possible, if problems are detected in a pull request, the bot will attempt to guide the PR author through the
process of making a valid submission, which should be handled in a completely automated fashion on our end.

It has become clear that we need to prevent the removal of the final newline from `repositories.txt`. The existing system
did not accomodate this requirement. Submissions are validated on a per-library basis, and the bot comments based on
identifying which library the problem applies to. But this newline removal is not necessarily related to any specific
item added to the list. So handling for general problems with a submission PR is needed, which is added here.

Because the PR author is more likely to require assistance with resolving this sort of problem, PR review from a
maintainer is requested.
2021-07-24 08:59:00 -07:00
per1234
c674fc0225 Add a dedicated "Manage PRs" workflow job for review request
The workflow result might indicate either that the PR author could require assistance from a maintainer or that something
is wrong with the system. In this case, the situation is brought to the attention of the maintainers by requesting a pull
request review from them.

Due to the need to avoid requesting review from a maintainer when they are the PR author (which is not allowed and thus
would result in a spurious workflow failure), the code for requesting this review is not as trivial as might be expected.
Previously, this code was duplicated at multiple places in the workflow, and would become more so as additional code is
added. The workflow is made cleaner by moving that duplicated code to a single dedicated job, which is facilitated by the
recent reworking of the workflow structure.

This is a pure refactoring and should have no effect on the workflow behavior.
2021-07-24 06:14:45 -07:00
per1234
ec4a8a8be1 Use a variable to define error message prefix
Whenever the bot needs to communicate to the user about a blocking issue with their pull request that they are able to
resolve, a standardized prefix is added to the situation-specific error message (" **ERROR:**") to draw their
attention to this information. This standardized text occurred multiple times in the workflow, which might lead to it
becoming inconsistent over time, or just more work to improve the text. Use of an environment variable ensures that all
uses of the prefix will be consistent and allows it to be edited once in a single place.
2021-07-24 06:14:45 -07:00
per1234
f67d72a764 Merge pull request #231 from per1234/unlink-mention
Avoid linkification of bot user name in comment
2021-07-20 00:56:58 -07:00
per1234
9b8632c524 Bump submission parser version to 1.0.1
A new release of `arduino/library-registry-submission-parser` is out with some minor improvements to the error messages
the bot comments to a pull request when problems with a submission are found.
2021-07-19 14:38:40 -07:00
per1234
02d74654d5 Avoid linkification of bot user name in comment
In the event the checks on a submission PR fails, the bot comments with instructions for how the checks can be triggered
to run again once the user has resolved the issue. One option is to comment on the PR thread, mentioning ArduinoBot.

GitHub automatically linkifies mentions to the user's profile page, which occurs in these instructions. The ArduinoBot
profile page is not of relevance or interest in this context, so there is no benefit to providing a one click path for
its access. In addition, the link makes the text more difficult to copy. So it's better to prevent its linkification,
which is achieved by wrapping the text in backticks.
2021-07-19 09:54:41 -07:00
per1234
6602308773 Remove workflow runs link from comment trigger reply
In the event the cause of a submission check failure is resolved externally, the user can trigger the "Manage PRs"
workflow run by mentioning ArduinoBot in a reply to the PR thread. Unlike a workflow run triggered by a push to the pull
request, GitHub Actions does not provide any visible indication on the PR page of the workflow run in progress. Instead,
we have configured the workflow so that the bot immediately comments on the PR thread so that the user is not left
wondering whether their comment had any effect as the longer process of the submission checks finishes before the
feedback about their result can be provided.

With the idea that some users might like to get a progress indicator in the time between the initial comment and the
final feedback from the workflow run, I added a link to the workflow runs page. However, we received feedback from
testers that encountering the fairly cryptic workflow run logs causes confusion. So we are trying to avoid leading users
toward those logs. Since the link does just that and is not necessary, it's best to simply remove it.
2021-07-19 04:14:22 -07:00
per1234
6cc8b40534 Only fail "Manage PRs" workflow on unexpected error
The "Manage PRs" GitHub Actions workflow processes pull requests submitted to the repository. It is intended to allow
completely automated submissions of libraries. The feedback mechanism used by the system is comments on the pull request
thread. These comments should provide all the necessary feedback about the process, including whatever is needed to
bring a submission into compliance in the event the automated checks find it to not meet the requirements.

From feedback provided by testers, we learned that they navigated to the workflow run logs provided by GitHub Actions
while trying to learn what the problem was with their submission.

The workflow run logs provide output from the internal workings of the system that is only of interest for developers
troubleshooting a malfunction of the system itself. We never intended to use them as a channel for communicating to the
regular users of the system. Users of the system may find them quite cryptic. Since this is an interface generated by
GitHub Actions, without much capability for customization, it would be quite difficult for us to improve their
readability for the normal user. Those efforts would also require an increase in the complexity of the workflow and make
it more difficult to maintain.

I think there are two possible paths a normal user would be likely to follow to the workflow logs while trying to
understand why their submission was not accepted:

- The check status UI shown at the bottom of the PR comment thread ("Some checks were not successful")
- Workflow run failure email notification ("Manage PRs: Some jobs were not successful: View workflow run")

These pathways are either less enticing or absent when a workflow run is successful.

Previously, there were two possible causes for a run of the "Manage PRs" workflow to fail:

- Submitted library did not meet the Library Manager requirements
- An unexpected error from one of the workflow steps

Since we already are using comments from the bot to communicate about the former, the workflow run failure status
indicators provided by GitHub Actions are superfluous. The latter only occurs under extraordinary and circumstances so
its effect on the user experience is not of concern.

So the way to improve the user experience is to configure the workflow to only fail on unexpected errors, only commenting
and blocking merge in the event of expected errors.
2021-07-18 03:55:17 -07:00
per1234
eb22d919fe Add prefix to error messages in bot comments
In the event of a problem with a submission, the comments on the pull request thread. Due to the use of a matrix job to
support submissions of any number of libraries in a single PR, this might consist of multiple comments. Adding a standard
prominent prefix ( **ERROR:**) to all error messages will ensure that the most important part of this information is
not missed.
2021-07-15 20:31:04 -07:00
per1234
b7626b1cc4 Approve submission PRs before auto-merging
This change to the "Manage PRs" workflow will cause the "github-actions" bot to add an approval pull request review to
submission PRs after they have passed all compliance checks, but before merging.

This is necessary to allow us to instate the "Require pull request reviews before merging" branch protection rule on
`main`, which will protect the repository from accidental pushes by the maintainers and administrators with write
permissions in the repository.

As an added benefit, this will more clearly indicate the status of a submission in the case where it is fully compliant
with the Library Manager requirements but an automated merge is not possible due to a merge conflict. In this case, the
bot will add an approval each time the workflow is triggered, but that is a reasonable behavior, and one permitted by the
PR review system (i.e., subsequent approvals will not cause a spurious workflow run failure, with either workflow trigger
event type).
2021-07-14 00:07:38 -07:00
per1234
f72e10f1ad Bump submission parser version to 1.0.0
There has been a 1.0.0 release of arduino/library-registry-submission-parser, so the "Manage PRs" workflow should use it.
2021-06-01 05:44:11 -07:00
per1234
8ccb23ac21 Use unique name for index source file
Previously, the submission list and the Library Manager index source list were both named "repositories.txt". I found having two files with similar content, but different purposes makes the already complex system unnecessarily difficult to understand.

Unlike the index source list, the submission list is solely a list of repositories, so its current "repositories.txt"
name is appropriate. The index source list contains other information unrelated to the library repository, so the
"repositories.txt" name is not so appropriate. Since the repository is named "library-registry", the filename
"registry.txt" makes sense.
2021-05-24 21:14:49 -07:00
per1234
ceda00d151 Post notification to Slack in the event of an unexpected workflow failure 2021-05-14 08:10:34 -07:00
per1234
30365a2d1e Remove review requests when no longer needed
If the PR is detected as something other than a submission, review is requested from a maintainer. It might be that the
PR was intended to be a submission and the submitter is able to resolve whatever caused it to be detected as otherwise
on their own. In this case, the automated system can handle things and review is no longer needed.
2021-05-10 07:22:26 -07:00
per1234
c4c45089f7 Don't request review for PRs from maintainer
Review requests to the PR author are not allowed. Previously, there would be a spurious workflow failure for every PR
from a user in the `env.MAINTAINERS` array.

When a maintainer is submitting a PR, they can request reviews as needed, so the automated review request can simply be
skipped in this case.
2021-05-10 03:48:28 -07:00
per1234
368738638f Request reviews from per1234 when maintainer attention is needed
Previously, the submission system was configured to automatically request reviews from the `arduino/team_tooling` team.
This doesn't work, likely due to the access token provided by GitHub not having the necessary permissions. However,
requesting from individual users works fine and in the end bothering the whole Tooling Team is probably a bad idea.
2021-05-09 18:39:00 -07:00
per1234
fb15582bf7 Clone submission to folder named after repository
The library folder name is a factor in the Arduino Lint results. Although the library.properties `name` value is used for
the Library Manager installation path, Arduino Lint rules also consider manual installation of libraries. These results
will be most accurate if the library is located in a folder named after the repository.
2021-05-03 05:39:45 -07:00
per1234
a7c285aa72 Add explanatory comment re: not using actions/checkout
We are accustomed to using the `actions/checkout` GitHub Action action in workflows whenever a repository needs to be
installed into the runner. So it may be quite unexpected to see `git clone` used.

In this case, it was necessary to do so in order to clone the library repository to run Arduino Lint on it because
`actions/checkout` can only be used with GitHub repositories, whereas multiple major Git hosts are supported for
submissions to Library Manager. This might not be obvious to those working on the workflow in the future, so it's worth
leaving a comment to avoid confusion.
2021-05-02 02:43:50 -07:00
per1234
66d13b057f Check new url on modification PRs
The "modify" request type is when the PR does removals as well as additions to the list. The valid reason for doing this
would be changing the URL of a library after the repo is renamed or the library moved to another repo.

This request type requires a manual review and merge, but the new URLs should be automatically processed to save the
reviewer from having to check it and work with the library submitter to resolve any issues that are found.

In this case, the `arduino/arduino-lint-action`'s `library-manager` input needs to be set to "update" instead of the
previously hardcoded "submit". The correct setting will be provided by the parser, so the workflow only needs to
implement the use of that setting.
2021-04-30 09:50:54 -07:00
per1234
db768adac6 Use text format Arduino Lint report in comment
Arduino Lint prints a summary report of the result of linting Arduino projects to stdout. It also offers the option of saving a JSON formatted report to a file.

In addition to rejecting the submission on an error result from Arduino Lint, the workflow also advocates for best
practices in the libraries of Library Manager by commenting a copy of the report to the PR thread if any warnings are
generated.

The machine-readable JSON format of the report file makes it easy to parse in the workflow to determine the warning
count. However, this JSON format is not terribly friendly to human readers. The `text` format report printed to stdout is
intended for that purpose. Previously, the JSON formatted report was commented to the PR thread, resulting in an
unpleasant experience for the submitter.

In the intended application of the `arduino/arduino-lint-action` GitHub Actions action, the report is printed to the log,
the interested user can access the report in the workflow run log, and any machine applications use the report file.
However, in this specialized use case, we need both a text format and a JSON format report file. Although that capability
could be added to the action, it would not likely be of use for other applications. For this reason, it makes more sense
to simply use the Arduino Lint application directly in the workflow. This really doesn't introduce any significant
complexity, since the action is only a thin wrapper.
2021-04-29 22:32:37 -07:00
per1234
c390055c1a Merge pull request #23 from arduino/skip-drafts
Don't run "Manage PRs" workflow on draft PRs
2021-04-29 01:36:32 -07:00
per1234
f678a3a457 Delete diff artifact after use in "Manage PRs" workflow
A workflow artifact is used to transfer the PR diff file from the `diff` job to the `parse` job. Once the artifact has
been downloaded by the `parse` job, it no longer serves any purpose.

It's possible the artifact might serve as a vector for exporting secrets from the workflow. Even though I don't have any
specific reasons to believe it is possible to cause secrets to be written to the artifact and the repository doesn't
currently have any secrets beyond `GITHUB_TOKEN`, nor need for any, it's still best to remove the unnecessary artifact.
2021-04-28 21:45:13 -07:00
per1234
ca4906f041 Don't run "Manage PRs" workflow on draft PRs
The draft mode clearly indicates that the PR is not ready for processing, so having the submission system run on these
PRs will only be an annoyance.
2021-04-28 21:01:06 -07:00
per1234
d8969cd40e Handle unexpected failures in "Manage PRs" workflow
The workflow already handles all expected failures in a manner that is as automated and friendly to the submitter as
possible.

However, there is always the chance for unexpected failures caused by a bug or service outage, which are in no way the
fault of the submitter. In this event, the workflow would previously fail without any clear explanation of what had
happened. This would be likely to cause confusion to the submitter. Since the system is very automated, this failure
might also go unnoticed by the repository maintainers.

A better way to handle unexpected failures is to:

- Add a special label ("status: maintenance required").
- Request a review from the Tooling Team.
- Comment to explain to the submitter that something went wrong and we will investigate.
2021-04-28 01:32:56 -07:00
per1234
f6342960d1 Restrict failure handling job runs to specific job failure
GitHub Actions workflow jobs default to the `if: success()` configuration. In this configuration, the job only runs when
the result of its job dependencies was success. When configuring a job to run on a failure result with `if: failure()` it
is logical to assume that the behavior would be inverted: the job would run only when the result of its dependency job
was failure. It does this, but also runs when its dependency job was canceled due to a failure of its own dependency.

This behavior of GitHub Actions resulted in the failure handling jobs running when they were not intended to. That is
avoided by specifying the exact job whose failure they were intended to handle in the conditional. It is still necessary
to use failure() in the conditional, otherwise they retain the default success() configuration and never run on a failure.
2021-04-28 01:27:30 -07:00
per1234
fd1da642b2 Merge pull request #21 from arduino/rename-job
Use less ambiguous name for workflow job handling non-submission PRs
2021-04-28 01:26:00 -07:00
per1234
f3a91c65e8 Use less ambiguous name for workflow job handling non-submission PRs
In the event a PR is detected as something other than a library submission, a review is requested from the Tooling Team
and a comment is made to the PR thread explaining the situation.

Previously, this job was named `request-review`. However, there are other circumstances under which a review will be
requested (e.g., merge conflict). So this was not a very good job name.

This job name is not referenced anywhere else in the workflow, so it currently only serves a documentation role and
changing it has no functional effect.
2021-04-27 23:21:42 -07:00
per1234
307f2802f9 Move comment re: "Unexpected input(s)" warnings for octokit/request-action to first usage
The `octokit/request-action` GitHub Actions action is designed to accept API request parameters as arbitrary action
inputs in the workflow. Because they have made no attempt to define all possible input keys in the action metadata,
normal and correct usage of the action cases GitHub Actions to display warnings in the workflow run log and summary. For
example:

Unexpected input(s) 'owner', 'repo', 'issue_number', 'labels', valid inputs are ['route', 'mediaType']

This has the potential to cause confusion, so I added a comment to the workflow explaining that this warning is expected
and doesn't indicate a problem. That comment somehow ended on a random occurence of `octokit/request-action` in the
workflow. It makes most sense to put it on the first usage of the action in the workflow, to make the information easy to
find.
2021-04-27 20:37:29 -07:00
per1234
610ddd71ff Merge pull request #16 from arduino/comment-feedback-issue-number
Remove unnecessary property reference from issue number definition for comment feedback comment
2021-04-27 08:30:30 -07:00
per1234
14d97cbc41 Merge pull request #18 from arduino/squash
Use squash merge for submission PRs
2021-04-27 08:30:15 -07:00
per1234
9710f18cd5 Provide assistance in the event of a merge conflict
It's certain that merge conflicts will occur as submitters take time to resolve blocking issues and other submissions are
accepted in the meantime. The PR merge will fail in this case.

Previously there was no provision for handling merge conflicts. The workflow run just failed at the merge job with no
comment from the bot.

The goal is for the automated system to work with the submitter as much as possible. Towards this goal, when the merge
fails, the bot will now comment to explain the problem and provide a link to a general tutorial for using the GitHub PR
merge conflict system.

A review is requested from the Tooling Team so that they can assist in the event the user is unable to resolve the merge
conflict, or the failure was caused by something else.
2021-04-27 07:51:47 -07:00
per1234
1df5fd85b5 Use squash merge for submission PRs
There is no good reason for a submission to consist of more than one commit.

As the submitter works with the bot to produce a compliant submission, they will sometimes end up with PRs that consist
of multiple non-atomic commits, which would pollute the repository's commit history if not squashed at the time of the
merge.
2021-04-26 21:55:19 -07:00
per1234
d83eb2b22c Remove unnecessary property reference from issue number definition for comment feedback comment
The "Manage PRs" workflow can be triggered by either a `pull_request_target` or `issue_comment` event. This means that
the `issue_number` parameter of the GitHub API request must be defined using both the `github.event.pull_request.number`
and `github.event.issue.number` properties because a different one is defined depending on which event was the trigger.
The exception is the API request for the bot comment used to provide immediate feedback when the workflow is triggered by
a comment. This API request is only ever used with an issue_comment event trigger, so the
github.event.pull_request.number property is not needed.
2021-04-26 17:07:09 -07:00
per1234
de21247de0 Remove unnecessary enabled job from "Manage PRs" workflow
This job was an artifact from an earlier version of the workflow, and was no longer necessary. It only added additional
code.
2021-04-26 14:23:02 -07:00
per1234
23c59049c4 Merge pull request #13 from arduino/comment-on-comment-trigger
Provide immediate response to comment trigger
2021-04-26 01:36:58 -07:00
per1234
83b4acfac7 Provide immediate response to comment trigger
When there is a problem with the submission that must be resolved in the library repository, a comment mentioning
`@ArduinoBot` is used to trigger the "Manage PRs" workflow.

We are accustomed to seeing the checks status in the PR thread when workflows are running. However, with a comment
triggered workflow this does not happen. The only indication of the workflow running is on the "Actions" tab. This can
leave the submitter wondering if their comment had any effect as the workflow takes some time to run before providing
feedback.

This uncertainty can be avoided by making the bot immediately comment to acknowledge that the check is in progress.
2021-04-25 23:35:39 -07:00
per1234
cad90e58f6 Comment on submission acceptance
Previously, as soon as a submission was compliant, the PR was merged silently. This might leave the submitter wondering
whether the submission process is complete.

There is some uncertain delay for the library release to be added to the server, the index to be generated, and the index
to propagate through the CDN, which might result in an increased support burden as the submitters comment or open issues
asking what is happening.

This is avoided by making the bot comment on the PR thread after the PR is merged, notifying the submitter that the
process was successful and that there will be some delay before the library is available from Library Manager.

Indexer logs URLs are provided for each submission, allowing the submitter to monitor the indexing process, both
immediately after the acceptance, as well as after they make future releases.
2021-04-25 22:21:36 -07:00
per1234
e1d572d8ab Merge pull request #9 from arduino/format-yaml
Reduce excessive line lengths in YAML files
2021-04-14 02:39:19 -07:00
per1234
016fc6cb8c Use custom matrix job names in check-submissions job
The "Manage PRs" GitHub Actions workflow generates a matrix job for each library submitted by the PR. The default job
name is generated from the job's matrix object. This contains the complete submission data, which results in a long and
somewhat cryptic job name that can make the workflow run more difficult to interpret.

The only necessary information is the description of the job's purpose ("check") and the submission URL (multiple URLs
per PR are supported). A custom job name allows for only using this information in the job name.
2021-04-14 00:50:06 -07:00
per1234
d96fcc48fd Reduce excessive line lengths in YAML files
The yamllint configuration advocates for keeping line lengths within 120 characters. While exceeding this length only
results in a warning, I think it is beneficial to stay within that limit when it is possible and doesn't have a harmful
effect. In that spirit, I have reduced the long lines where this was easily done. There remain a few that are either not
possible or else not reasonable to reduce, and that's OK.
2021-04-13 17:48:16 -07:00
per1234
eafd6bbaf9 Remove dependencies caching from workflows
After I set up caching in the template workflows, doubts were raised about whether it provided any benefits. I don't know
enough about this subject to make a call on that and I have been unable to get any more information on the subject.

Since the caching significantly increases the complexity of the workflows, which may make them more difficult to maintain
and contribute to, I think it's best to just remove all the caching for now. I hope to eventually be able to revisit this
topic and restore caching in any workflows where it is definitely beneficial.
2021-04-12 02:45:29 -07:00