Skip to content

Use a dedicated output field to indicate request conclusion #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ type accessDataType struct {

// request is the type of the request data.
type request struct {
Conclusion string `json:"conclusion"` // Request conclusion.
Type string `json:"type"` // Request type.
ArduinoLintLibraryManagerSetting string `json:"arduinoLintLibraryManagerSetting"` // Argument to pass to Arduino Lint's --library-manager flag.
Submissions []submissionType `json:"submissions"` // Data for submitted libraries.
Expand Down Expand Up @@ -185,7 +186,8 @@ func main() {
if accessData.Host == "github.com" && *submitterArgument == accessData.Name {
submitterAccess = accessData.Access
if submitterAccess == Deny {
req.Type = "declined"
req.Conclusion = "declined"
req.Type = "invalid"
req.Error = fmt.Sprintf("Library registry privileges for @%s have been revoked.%%0ASee: %s", *submitterArgument, accessData.Reference)
}
break
Expand Down Expand Up @@ -216,7 +218,7 @@ func main() {
}
if len(submissionURLs) > 0 && !allowedSubmissions {
// If none of the submissions are allowed, decline the request.
req.Type = "declined"
req.Conclusion = "declined"
}

// Check for duplicates within the submission itself.
Expand Down
35 changes: 28 additions & 7 deletions tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@pytest.mark.parametrize(
"repopath_folder_name,"
"submitter,"
"expected_conclusion,"
"expected_type,"
"expected_error,"
"expected_submissions,"
Expand All @@ -32,6 +33,7 @@
(
"submitter-access-allow",
"AllowUser",
"",
"submission",
"",
[
Expand All @@ -53,30 +55,33 @@
"submitter-access-deny",
"DenyUser",
"declined",
"invalid",
"Library registry privileges for @DenyUser have been revoked.%0ASee: https://example.com",
None,
"",
"",
),
("list-deleted-diff", "FooUser", "other", "", None, "", ""),
("list-deleted-diff", "FooUser", "other", "", None, "", ""),
("list-deleted-diff", "FooUser", "other", "", None, "", ""),
("multi-file-diff", "FooUser", "other", "", None, "", ""),
("non-list-diff", "FooUser", "other", "", None, "", ""),
("list-rename-diff", "FooUser", "other", "", None, "", ""),
("list-deleted-diff", "FooUser", "", "other", "", None, "", ""),
("list-deleted-diff", "FooUser", "", "other", "", None, "", ""),
("list-deleted-diff", "FooUser", "", "other", "", None, "", ""),
("multi-file-diff", "FooUser", "", "other", "", None, "", ""),
("non-list-diff", "FooUser", "", "other", "", None, "", ""),
("list-rename-diff", "FooUser", "", "other", "", None, "", ""),
(
"no-final-newline-diff",
"FooUser",
"",
"invalid",
"Pull request removes newline from the end of a file.%0APlease add a blank line to the end of the file.",
None,
"",
"",
),
("removal", "FooUser", "removal", "", None, "", ""),
("removal", "FooUser", "", "removal", "", None, "", ""),
(
"modification",
"FooUser",
"",
"modification",
"",
[
Expand All @@ -96,6 +101,7 @@
(
"url-error",
"FooUser",
"",
"submission",
"",
[
Expand All @@ -115,6 +121,7 @@
(
"url-404",
"FooUser",
"",
"submission",
"",
[
Expand All @@ -135,6 +142,7 @@
"all-owner-access-deny",
"FooUser",
"declined",
"submission",
"",
[
{
Expand All @@ -154,6 +162,7 @@
(
"some-owner-access-deny",
"FooUser",
"",
"submission",
"",
[
Expand Down Expand Up @@ -184,6 +193,7 @@
(
"not-supported-git-host",
"FooUser",
"",
"submission",
"",
[
Expand All @@ -205,6 +215,7 @@
(
"not-git-clone-url",
"FooUser",
"",
"submission",
"",
[
Expand All @@ -225,6 +236,7 @@
(
"already-in-library-manager",
"FooUser",
"",
"submission",
"",
[
Expand All @@ -244,6 +256,7 @@
(
"type-arduino",
"FooUser",
"",
"submission",
"",
[
Expand All @@ -263,6 +276,7 @@
(
"type-partner",
"FooUser",
"",
"submission",
"",
[
Expand All @@ -282,6 +296,7 @@
(
"type-recommended",
"FooUser",
"",
"submission",
"",
[
Expand All @@ -301,6 +316,7 @@
(
"type-contributed",
"FooUser",
"",
"submission",
"",
[
Expand All @@ -321,6 +337,7 @@
(
"no-tags",
"FooUser",
"",
"submission",
"",
[
Expand All @@ -342,6 +359,7 @@
(
"no-library-properties",
"FooUser",
"",
"submission",
"",
[
Expand All @@ -362,6 +380,7 @@
(
"duplicates-in-submission",
"FooUser",
"",
"submission",
"",
[
Expand Down Expand Up @@ -395,6 +414,7 @@ def test_request(
run_command,
repopath_folder_name,
submitter,
expected_conclusion,
expected_type,
expected_error,
expected_submissions,
Expand Down Expand Up @@ -423,6 +443,7 @@ def test_request(
assert result.ok

request = json.loads(result.stdout)
assert request["conclusion"] == expected_conclusion
assert request["type"] == expected_type
assert request["error"] == expected_error
assert request["submissions"] == expected_submissions
Expand Down
Loading