From dc1c82ef160e6fc6f360f4dfa3cb0d2ad5f0aee3 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Sat, 18 Mar 2023 23:02:27 +0800 Subject: [PATCH 1/5] .git-blame-ignore-revs: update --- .git-blame-ignore-revs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 166746c09..4ffa70a2f 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,3 +1,6 @@ +# *.fsx,*.fs: formatting F# files using fantomless +df5cfb143c4efe73806ead91e5cddf4e133be0a8 + # commitlint.config: split helper funcs and plugins 3008d6578aa484ae776b29c9246dca4eeae3418a From 1ddfc08b25c49f6e027ab933ab86e86fc47443aa Mon Sep 17 00:00:00 2001 From: Afshin Arani Date: Sun, 26 Mar 2023 16:38:57 +0330 Subject: [PATCH 2/5] WorkflowGuidelines: common bad practices (#96) This commit descibes some bad practices like DRY, Magic Numbers and Primitive Obsession. --- WorkflowGuidelines.md | 80 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/WorkflowGuidelines.md b/WorkflowGuidelines.md index 379e5be7f..a68b14c3b 100644 --- a/WorkflowGuidelines.md +++ b/WorkflowGuidelines.md @@ -1,5 +1,84 @@ # Workflow guidelines +* Avoid typical bad practices like: + + * Magic numbers: + + Avoid using unnamed numerical constants in software code, this practice makes code hard to understand and maintain. + + Example: + ``` + var distance = GpsUtil.GetDistance() + if (distance < 100) + throw new NotImplementedException(); + ``` + ``` + private const int MinimumSupportedDistanceToNotifyKillerDrones = 100; + + ... + + var distance = GpsUtil.GetDistance() + if (distance < MinimumSupportedDistanceToNotifyKillerDrones) + throw new NotImplementedException(); + ``` + + * DRY (Don't Repeat Yourself): + + The DRY principle suggests that a piece of information should only be stored once in a project and should be referenced as needed, rather than being copied and pasted multiple times throughout the codebase. + + It has several benefits, including reducing the amount of code that needs to be written and maintained, improving the consistency and quality of the code, and reducing the risk of introducing errors and bugs when the information changes. + + Example: + ``` + let preAuthInputMac = + CalculateMacWithSHA3256 + preAuthInput + ":hs_mac" + + ... + + let authInputMac = + CalculateMacWithSHA3256 + authInput + ":hs_mac" + ``` + ``` + let AuthenticationDigestCalculationKey = ":hs_mac" + + ... + + let preAuthInputMac = + CalculateMacWithSHA3256 + preAuthInput + AuthenticationDigestCalculationKey + + ... + + let authInputMac = + CalculateMacWithSHA3256 + authInput + AuthenticationDigestCalculationKey + ``` + + * Primitive Obsession: + + Primitive Obsession is a situation where simple data types such as strings, integers, or arrays are overused in place of more appropriate objects. + + Example: + ``` + let saveFilePath = System.Console.ReadLine() + + let savedData = System.IO.File.ReadAllText saveFilePath + ``` + ``` + let saveFilePath = + let saveFilePathInString = + System.Console.ReadLine() + System.IO.FileInfo saveFilePathInString + + let savedData = System.IO.File.ReadAllText saveFilePath.FullName + ``` + * When contributing a PullRequest, separate your commits in units of work (don't mix changes that have different concerns in the same commit). Don't forget to include all explanations and reasonings in the commit messages, @@ -75,3 +154,4 @@ closed after the commit lands, then you would use the word `Closes` instead of Do not use long lines (manually crop them with EOLs because git doesn't do this automatically). + From 73ada7e5eb50a91e421d45bb918645ad6a331e63 Mon Sep 17 00:00:00 2001 From: Zahra TehraniNasab <50144546+realmarv@users.noreply.github.com> Date: Tue, 28 Mar 2023 13:46:07 +0330 Subject: [PATCH 3/5] scripts/detectNotUsingGitPush1by1.fsx: fix (#92) The script should query the fork repository that the PR originated from, otherwise some commits might not have CI status and this script will throw an error, while the user has pushed the commits one by one. The `GITHUB_EVENT_PATH` environment variable points to a JSON file that contains information about the pull request event, including the user and repository information of the fork repository. This is an example of the JSON file: ``` { "action": "opened", "number": 4, "pull_request": { "_links": { "comments": { "href": "https://api.github.com/repos/realmarv/conventions/issues/4/comments" }, "commits": { "href": "https://api.github.com/repos/realmarv/conventions/pulls/4/commits" }, "html": { "href": "https://github.com/realmarv/conventions/pull/4" }, "issue": { "href": "https://api.github.com/repos/realmarv/conventions/issues/4" }, "review_comment": { "href": "https://api.github.com/repos/realmarv/conventions/pulls/comments{/number}" }, "review_comments": { "href": "https://api.github.com/repos/realmarv/conventions/pulls/4/comments" }, "self": { "href": "https://api.github.com/repos/realmarv/conventions/pulls/4" }, "statuses": { "href": "https://api.github.com/repos/realmarv/conventions/statuses/c5eb50ea6c5a72d61ab85d96ffc66cc4741d3133" } }, "active_lock_reason": null, "additions": 21, "assignee": null, "assignees": [], "author_association": "OWNER", "auto_merge": null, "base": { "label": "realmarv:master", "ref": "master", "repo": { "allow_auto_merge": false, "allow_forking": true, "allow_merge_commit": true, "allow_rebase_merge": true, "allow_squash_merge": true, "allow_update_branch": false, "archive_url": "https://api.github.com/repos/realmarv/conventions/{archive_format}{/ref}", "archived": false, "assignees_url": "https://api.github.com/repos/realmarv/conventions/assignees{/user}", "blobs_url": "https://api.github.com/repos/realmarv/conventions/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/realmarv/conventions/branches{/branch}", "clone_url": "https://github.com/realmarv/conventions.git", "collaborators_url": "https://api.github.com/repos/realmarv/conventions/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/realmarv/conventions/comments{/number}", "commits_url": "https://api.github.com/repos/realmarv/conventions/commits{/sha}", "compare_url": "https://api.github.com/repos/realmarv/conventions/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/realmarv/conventions/contents/{+path}", "contributors_url": "https://api.github.com/repos/realmarv/conventions/contributors", "created_at": "2022-10-12T08:48:57Z", "default_branch": "master", "delete_branch_on_merge": false, "deployments_url": "https://api.github.com/repos/realmarv/conventions/deployments", "description": null, "disabled": false, "downloads_url": "https://api.github.com/repos/realmarv/conventions/downloads", "events_url": "https://api.github.com/repos/realmarv/conventions/events", "fork": true, "forks": 0, "forks_count": 0, "forks_url": "https://api.github.com/repos/realmarv/conventions/forks", "full_name": "realmarv/conventions", "git_commits_url": "https://api.github.com/repos/realmarv/conventions/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/realmarv/conventions/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/realmarv/conventions/git/tags{/sha}", "git_url": "git://github.com/realmarv/conventions.git", "has_discussions": false, "has_downloads": true, "has_issues": false, "has_pages": false, "has_projects": true, "has_wiki": true, "homepage": null, "hooks_url": "https://api.github.com/repos/realmarv/conventions/hooks", "html_url": "https://github.com/realmarv/conventions", "id": 550128772, "is_template": false, "issue_comment_url": "https://api.github.com/repos/realmarv/conventions/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/realmarv/conventions/issues/events{/number}", "issues_url": "https://api.github.com/repos/realmarv/conventions/issues{/number}", "keys_url": "https://api.github.com/repos/realmarv/conventions/keys{/key_id}", "labels_url": "https://api.github.com/repos/realmarv/conventions/labels{/name}", "language": "TypeScript", "languages_url": "https://api.github.com/repos/realmarv/conventions/languages", "license": { "key": "mit", "name": "MIT License", "node_id": "MDc6TGljZW5zZTEz", "spdx_id": "MIT", "url": "https://api.github.com/licenses/mit" }, "merge_commit_message": "PR_TITLE", "merge_commit_title": "MERGE_MESSAGE", "merges_url": "https://api.github.com/repos/realmarv/conventions/merges", "milestones_url": "https://api.github.com/repos/realmarv/conventions/milestones{/number}", "mirror_url": null, "name": "conventions", "node_id": "R_kgDOIMpMhA", "notifications_url": "https://api.github.com/repos/realmarv/conventions/notifications{?since,all,participating}", "open_issues": 4, "open_issues_count": 4, "owner": { "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", "events_url": "https://api.github.com/users/realmarv/events{/privacy}", "followers_url": "https://api.github.com/users/realmarv/followers", "following_url": "https://api.github.com/users/realmarv/following{/other_user}", "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", "gravatar_id": "", "html_url": "https://github.com/realmarv", "id": 50144546, "login": "realmarv", "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", "organizations_url": "https://api.github.com/users/realmarv/orgs", "received_events_url": "https://api.github.com/users/realmarv/received_events", "repos_url": "https://api.github.com/users/realmarv/repos", "site_admin": false, "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", "type": "User", "url": "https://api.github.com/users/realmarv" }, "private": false, "pulls_url": "https://api.github.com/repos/realmarv/conventions/pulls{/number}", "pushed_at": "2023-03-23T09:00:26Z", "releases_url": "https://api.github.com/repos/realmarv/conventions/releases{/id}", "size": 2395, "squash_merge_commit_message": "COMMIT_MESSAGES", "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", "ssh_url": "git@github.com:realmarv/conventions.git", "stargazers_count": 0, "stargazers_url": "https://api.github.com/repos/realmarv/conventions/stargazers", "statuses_url": "https://api.github.com/repos/realmarv/conventions/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/realmarv/conventions/subscribers", "subscription_url": "https://api.github.com/repos/realmarv/conventions/subscription", "svn_url": "https://github.com/realmarv/conventions", "tags_url": "https://api.github.com/repos/realmarv/conventions/tags", "teams_url": "https://api.github.com/repos/realmarv/conventions/teams", "topics": [], "trees_url": "https://api.github.com/repos/realmarv/conventions/git/trees{/sha}", "updated_at": "2022-10-13T08:53:39Z", "url": "https://api.github.com/repos/realmarv/conventions", "use_squash_pr_title_as_default": false, "visibility": "public", "watchers": 0, "watchers_count": 0, "web_commit_signoff_required": false }, "sha": "0be2f2d608cdf893e146db1296dee750a2a54cfc", "user": { "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", "events_url": "https://api.github.com/users/realmarv/events{/privacy}", "followers_url": "https://api.github.com/users/realmarv/followers", "following_url": "https://api.github.com/users/realmarv/following{/other_user}", "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", "gravatar_id": "", "html_url": "https://github.com/realmarv", "id": 50144546, "login": "realmarv", "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", "organizations_url": "https://api.github.com/users/realmarv/orgs", "received_events_url": "https://api.github.com/users/realmarv/received_events", "repos_url": "https://api.github.com/users/realmarv/repos", "site_admin": false, "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", "type": "User", "url": "https://api.github.com/users/realmarv" } }, "body": null, "changed_files": 2, "closed_at": null, "comments": 0, "comments_url": "https://api.github.com/repos/realmarv/conventions/issues/4/comments", "commits": 2, "commits_url": "https://api.github.com/repos/realmarv/conventions/pulls/4/commits", "created_at": "2023-03-23T09:00:26Z", "deletions": 0, "diff_url": "https://github.com/realmarv/conventions/pull/4.diff", "draft": false, "head": { "label": "realmarv:fixGitPush1by1Check", "ref": "fixGitPush1by1Check", "repo": { "allow_auto_merge": false, "allow_forking": true, "allow_merge_commit": true, "allow_rebase_merge": true, "allow_squash_merge": true, "allow_update_branch": false, "archive_url": "https://api.github.com/repos/realmarv/conventions/{archive_format}{/ref}", "archived": false, "assignees_url": "https://api.github.com/repos/realmarv/conventions/assignees{/user}", "blobs_url": "https://api.github.com/repos/realmarv/conventions/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/realmarv/conventions/branches{/branch}", "clone_url": "https://github.com/realmarv/conventions.git", "collaborators_url": "https://api.github.com/repos/realmarv/conventions/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/realmarv/conventions/comments{/number}", "commits_url": "https://api.github.com/repos/realmarv/conventions/commits{/sha}", "compare_url": "https://api.github.com/repos/realmarv/conventions/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/realmarv/conventions/contents/{+path}", "contributors_url": "https://api.github.com/repos/realmarv/conventions/contributors", "created_at": "2022-10-12T08:48:57Z", "default_branch": "master", "delete_branch_on_merge": false, "deployments_url": "https://api.github.com/repos/realmarv/conventions/deployments", "description": null, "disabled": false, "downloads_url": "https://api.github.com/repos/realmarv/conventions/downloads", "events_url": "https://api.github.com/repos/realmarv/conventions/events", "fork": true, "forks": 0, "forks_count": 0, "forks_url": "https://api.github.com/repos/realmarv/conventions/forks", "full_name": "realmarv/conventions", "git_commits_url": "https://api.github.com/repos/realmarv/conventions/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/realmarv/conventions/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/realmarv/conventions/git/tags{/sha}", "git_url": "git://github.com/realmarv/conventions.git", "has_discussions": false, "has_downloads": true, "has_issues": false, "has_pages": false, "has_projects": true, "has_wiki": true, "homepage": null, "hooks_url": "https://api.github.com/repos/realmarv/conventions/hooks", "html_url": "https://github.com/realmarv/conventions", "id": 550128772, "is_template": false, "issue_comment_url": "https://api.github.com/repos/realmarv/conventions/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/realmarv/conventions/issues/events{/number}", "issues_url": "https://api.github.com/repos/realmarv/conventions/issues{/number}", "keys_url": "https://api.github.com/repos/realmarv/conventions/keys{/key_id}", "labels_url": "https://api.github.com/repos/realmarv/conventions/labels{/name}", "language": "TypeScript", "languages_url": "https://api.github.com/repos/realmarv/conventions/languages", "license": { "key": "mit", "name": "MIT License", "node_id": "MDc6TGljZW5zZTEz", "spdx_id": "MIT", "url": "https://api.github.com/licenses/mit" }, "merge_commit_message": "PR_TITLE", "merge_commit_title": "MERGE_MESSAGE", "merges_url": "https://api.github.com/repos/realmarv/conventions/merges", "milestones_url": "https://api.github.com/repos/realmarv/conventions/milestones{/number}", "mirror_url": null, "name": "conventions", "node_id": "R_kgDOIMpMhA", "notifications_url": "https://api.github.com/repos/realmarv/conventions/notifications{?since,all,participating}", "open_issues": 4, "open_issues_count": 4, "owner": { "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", "events_url": "https://api.github.com/users/realmarv/events{/privacy}", "followers_url": "https://api.github.com/users/realmarv/followers", "following_url": "https://api.github.com/users/realmarv/following{/other_user}", "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", "gravatar_id": "", "html_url": "https://github.com/realmarv", "id": 50144546, "login": "realmarv", "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", "organizations_url": "https://api.github.com/users/realmarv/orgs", "received_events_url": "https://api.github.com/users/realmarv/received_events", "repos_url": "https://api.github.com/users/realmarv/repos", "site_admin": false, "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", "type": "User", "url": "https://api.github.com/users/realmarv" }, "private": false, "pulls_url": "https://api.github.com/repos/realmarv/conventions/pulls{/number}", "pushed_at": "2023-03-23T09:00:26Z", "releases_url": "https://api.github.com/repos/realmarv/conventions/releases{/id}", "size": 2395, "squash_merge_commit_message": "COMMIT_MESSAGES", "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", "ssh_url": "git@github.com:realmarv/conventions.git", "stargazers_count": 0, "stargazers_url": "https://api.github.com/repos/realmarv/conventions/stargazers", "statuses_url": "https://api.github.com/repos/realmarv/conventions/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/realmarv/conventions/subscribers", "subscription_url": "https://api.github.com/repos/realmarv/conventions/subscription", "svn_url": "https://github.com/realmarv/conventions", "tags_url": "https://api.github.com/repos/realmarv/conventions/tags", "teams_url": "https://api.github.com/repos/realmarv/conventions/teams", "topics": [], "trees_url": "https://api.github.com/repos/realmarv/conventions/git/trees{/sha}", "updated_at": "2022-10-13T08:53:39Z", "url": "https://api.github.com/repos/realmarv/conventions", "use_squash_pr_title_as_default": false, "visibility": "public", "watchers": 0, "watchers_count": 0, "web_commit_signoff_required": false }, "sha": "c5eb50ea6c5a72d61ab85d96ffc66cc4741d3133", "user": { "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", "events_url": "https://api.github.com/users/realmarv/events{/privacy}", "followers_url": "https://api.github.com/users/realmarv/followers", "following_url": "https://api.github.com/users/realmarv/following{/other_user}", "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", "gravatar_id": "", "html_url": "https://github.com/realmarv", "id": 50144546, "login": "realmarv", "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", "organizations_url": "https://api.github.com/users/realmarv/orgs", "received_events_url": "https://api.github.com/users/realmarv/received_events", "repos_url": "https://api.github.com/users/realmarv/repos", "site_admin": false, "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", "type": "User", "url": "https://api.github.com/users/realmarv" } }, "html_url": "https://github.com/realmarv/conventions/pull/4", "id": 1287033164, "issue_url": "https://api.github.com/repos/realmarv/conventions/issues/4", "labels": [], "locked": false, "maintainer_can_modify": false, "merge_commit_sha": null, "mergeable": null, "mergeable_state": "unknown", "merged": false, "merged_at": null, "merged_by": null, "milestone": null, "node_id": "PR_kwDOIMpMhM5MtpFM", "number": 4, "patch_url": "https://github.com/realmarv/conventions/pull/4.patch", "rebaseable": null, "requested_reviewers": [], "requested_teams": [], "review_comment_url": "https://api.github.com/repos/realmarv/conventions/pulls/comments{/number}", "review_comments": 0, "review_comments_url": "https://api.github.com/repos/realmarv/conventions/pulls/4/comments", "state": "open", "statuses_url": "https://api.github.com/repos/realmarv/conventions/statuses/c5eb50ea6c5a72d61ab85d96ffc66cc4741d3133", "title": "Fix git push1by1 check", "updated_at": "2023-03-23T09:00:26Z", "url": "https://api.github.com/repos/realmarv/conventions/pulls/4", "user": { "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", "events_url": "https://api.github.com/users/realmarv/events{/privacy}", "followers_url": "https://api.github.com/users/realmarv/followers", "following_url": "https://api.github.com/users/realmarv/following{/other_user}", "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", "gravatar_id": "", "html_url": "https://github.com/realmarv", "id": 50144546, "login": "realmarv", "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", "organizations_url": "https://api.github.com/users/realmarv/orgs", "received_events_url": "https://api.github.com/users/realmarv/received_events", "repos_url": "https://api.github.com/users/realmarv/repos", "site_admin": false, "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", "type": "User", "url": "https://api.github.com/users/realmarv" } }, "repository": { "allow_forking": true, "archive_url": "https://api.github.com/repos/realmarv/conventions/{archive_format}{/ref}", "archived": false, "assignees_url": "https://api.github.com/repos/realmarv/conventions/assignees{/user}", "blobs_url": "https://api.github.com/repos/realmarv/conventions/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/realmarv/conventions/branches{/branch}", "clone_url": "https://github.com/realmarv/conventions.git", "collaborators_url": "https://api.github.com/repos/realmarv/conventions/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/realmarv/conventions/comments{/number}", "commits_url": "https://api.github.com/repos/realmarv/conventions/commits{/sha}", "compare_url": "https://api.github.com/repos/realmarv/conventions/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/realmarv/conventions/contents/{+path}", "contributors_url": "https://api.github.com/repos/realmarv/conventions/contributors", "created_at": "2022-10-12T08:48:57Z", "default_branch": "master", "deployments_url": "https://api.github.com/repos/realmarv/conventions/deployments", "description": null, "disabled": false, "downloads_url": "https://api.github.com/repos/realmarv/conventions/downloads", "events_url": "https://api.github.com/repos/realmarv/conventions/events", "fork": true, "forks": 0, "forks_count": 0, "forks_url": "https://api.github.com/repos/realmarv/conventions/forks", "full_name": "realmarv/conventions", "git_commits_url": "https://api.github.com/repos/realmarv/conventions/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/realmarv/conventions/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/realmarv/conventions/git/tags{/sha}", "git_url": "git://github.com/realmarv/conventions.git", "has_discussions": false, "has_downloads": true, "has_issues": false, "has_pages": false, "has_projects": true, "has_wiki": true, "homepage": null, "hooks_url": "https://api.github.com/repos/realmarv/conventions/hooks", "html_url": "https://github.com/realmarv/conventions", "id": 550128772, "is_template": false, "issue_comment_url": "https://api.github.com/repos/realmarv/conventions/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/realmarv/conventions/issues/events{/number}", "issues_url": "https://api.github.com/repos/realmarv/conventions/issues{/number}", "keys_url": "https://api.github.com/repos/realmarv/conventions/keys{/key_id}", "labels_url": "https://api.github.com/repos/realmarv/conventions/labels{/name}", "language": "TypeScript", "languages_url": "https://api.github.com/repos/realmarv/conventions/languages", "license": { "key": "mit", "name": "MIT License", "node_id": "MDc6TGljZW5zZTEz", "spdx_id": "MIT", "url": "https://api.github.com/licenses/mit" }, "merges_url": "https://api.github.com/repos/realmarv/conventions/merges", "milestones_url": "https://api.github.com/repos/realmarv/conventions/milestones{/number}", "mirror_url": null, "name": "conventions", "node_id": "R_kgDOIMpMhA", "notifications_url": "https://api.github.com/repos/realmarv/conventions/notifications{?since,all,participating}", "open_issues": 4, "open_issues_count": 4, "owner": { "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", "events_url": "https://api.github.com/users/realmarv/events{/privacy}", "followers_url": "https://api.github.com/users/realmarv/followers", "following_url": "https://api.github.com/users/realmarv/following{/other_user}", "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", "gravatar_id": "", "html_url": "https://github.com/realmarv", "id": 50144546, "login": "realmarv", "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", "organizations_url": "https://api.github.com/users/realmarv/orgs", "received_events_url": "https://api.github.com/users/realmarv/received_events", "repos_url": "https://api.github.com/users/realmarv/repos", "site_admin": false, "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", "type": "User", "url": "https://api.github.com/users/realmarv" }, "private": false, "pulls_url": "https://api.github.com/repos/realmarv/conventions/pulls{/number}", "pushed_at": "2023-03-23T09:00:26Z", "releases_url": "https://api.github.com/repos/realmarv/conventions/releases{/id}", "size": 2395, "ssh_url": "git@github.com:realmarv/conventions.git", "stargazers_count": 0, "stargazers_url": "https://api.github.com/repos/realmarv/conventions/stargazers", "statuses_url": "https://api.github.com/repos/realmarv/conventions/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/realmarv/conventions/subscribers", "subscription_url": "https://api.github.com/repos/realmarv/conventions/subscription", "svn_url": "https://github.com/realmarv/conventions", "tags_url": "https://api.github.com/repos/realmarv/conventions/tags", "teams_url": "https://api.github.com/repos/realmarv/conventions/teams", "topics": [], "trees_url": "https://api.github.com/repos/realmarv/conventions/git/trees{/sha}", "updated_at": "2022-10-13T08:53:39Z", "url": "https://api.github.com/repos/realmarv/conventions", "visibility": "public", "watchers": 0, "watchers_count": 0, "web_commit_signoff_required": false }, "sender": { "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", "events_url": "https://api.github.com/users/realmarv/events{/privacy}", "followers_url": "https://api.github.com/users/realmarv/followers", "following_url": "https://api.github.com/users/realmarv/following{/other_user}", "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", "gravatar_id": "", "html_url": "https://github.com/realmarv", "id": 50144546, "login": "realmarv", "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", "organizations_url": "https://api.github.com/users/realmarv/orgs", "received_events_url": "https://api.github.com/users/realmarv/received_events", "repos_url": "https://api.github.com/users/realmarv/repos", "site_admin": false, "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", "type": "User", "url": "https://api.github.com/users/realmarv" } } ``` --- scripts/detectNotUsingGitPush1by1.fsx | 526 +++++++++++++++++++++++++- 1 file changed, 523 insertions(+), 3 deletions(-) diff --git a/scripts/detectNotUsingGitPush1by1.fsx b/scripts/detectNotUsingGitPush1by1.fsx index 02196d9fd..0e5d03cf1 100644 --- a/scripts/detectNotUsingGitPush1by1.fsx +++ b/scripts/detectNotUsingGitPush1by1.fsx @@ -1,21 +1,541 @@ #!/usr/bin/env -S dotnet fsi open System +open System.IO open System.Net.Http open System.Net.Http.Headers +#r "nuget: FSharp.Data, Version=5.0.2" +open FSharp.Data + #r "nuget: Fsdk, Version=0.6.0--date20230214-0422.git-1ea6f62" open Fsdk +let githubEventPath = Environment.GetEnvironmentVariable "GITHUB_EVENT_PATH" -let gitRepo = Environment.GetEnvironmentVariable "GITHUB_REPOSITORY" - -if String.IsNullOrEmpty gitRepo then +if String.IsNullOrEmpty githubEventPath then Console.Error.WriteLine "This script is meant to be used only within a GitHubCI pipeline" Environment.Exit 2 +type githubEventType = + JsonProvider<""" +{ + "action": "opened", + "number": 4, + "pull_request": { + "_links": { + "comments": { + "href": "https://api.github.com/repos/realmarv/conventions/issues/4/comments" + }, + "commits": { + "href": "https://api.github.com/repos/realmarv/conventions/pulls/4/commits" + }, + "html": { + "href": "https://github.com/realmarv/conventions/pull/4" + }, + "issue": { + "href": "https://api.github.com/repos/realmarv/conventions/issues/4" + }, + "review_comment": { + "href": "https://api.github.com/repos/realmarv/conventions/pulls/comments{/number}" + }, + "review_comments": { + "href": "https://api.github.com/repos/realmarv/conventions/pulls/4/comments" + }, + "self": { + "href": "https://api.github.com/repos/realmarv/conventions/pulls/4" + }, + "statuses": { + "href": "https://api.github.com/repos/realmarv/conventions/statuses/c5eb50ea6c5a72d61ab85d96ffc66cc4741d3133" + } + }, + "active_lock_reason": null, + "additions": 21, + "assignee": null, + "assignees": [], + "author_association": "OWNER", + "auto_merge": null, + "base": { + "label": "realmarv:master", + "ref": "master", + "repo": { + "allow_auto_merge": false, + "allow_forking": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_squash_merge": true, + "allow_update_branch": false, + "archive_url": "https://api.github.com/repos/realmarv/conventions/{archive_format}{/ref}", + "archived": false, + "assignees_url": "https://api.github.com/repos/realmarv/conventions/assignees{/user}", + "blobs_url": "https://api.github.com/repos/realmarv/conventions/git/blobs{/sha}", + "branches_url": "https://api.github.com/repos/realmarv/conventions/branches{/branch}", + "clone_url": "https://github.com/realmarv/conventions.git", + "collaborators_url": "https://api.github.com/repos/realmarv/conventions/collaborators{/collaborator}", + "comments_url": "https://api.github.com/repos/realmarv/conventions/comments{/number}", + "commits_url": "https://api.github.com/repos/realmarv/conventions/commits{/sha}", + "compare_url": "https://api.github.com/repos/realmarv/conventions/compare/{base}...{head}", + "contents_url": "https://api.github.com/repos/realmarv/conventions/contents/{+path}", + "contributors_url": "https://api.github.com/repos/realmarv/conventions/contributors", + "created_at": "2022-10-12T08:48:57Z", + "default_branch": "master", + "delete_branch_on_merge": false, + "deployments_url": "https://api.github.com/repos/realmarv/conventions/deployments", + "description": null, + "disabled": false, + "downloads_url": "https://api.github.com/repos/realmarv/conventions/downloads", + "events_url": "https://api.github.com/repos/realmarv/conventions/events", + "fork": true, + "forks": 0, + "forks_count": 0, + "forks_url": "https://api.github.com/repos/realmarv/conventions/forks", + "full_name": "realmarv/conventions", + "git_commits_url": "https://api.github.com/repos/realmarv/conventions/git/commits{/sha}", + "git_refs_url": "https://api.github.com/repos/realmarv/conventions/git/refs{/sha}", + "git_tags_url": "https://api.github.com/repos/realmarv/conventions/git/tags{/sha}", + "git_url": "git://github.com/realmarv/conventions.git", + "has_discussions": false, + "has_downloads": true, + "has_issues": false, + "has_pages": false, + "has_projects": true, + "has_wiki": true, + "homepage": null, + "hooks_url": "https://api.github.com/repos/realmarv/conventions/hooks", + "html_url": "https://github.com/realmarv/conventions", + "id": 550128772, + "is_template": false, + "issue_comment_url": "https://api.github.com/repos/realmarv/conventions/issues/comments{/number}", + "issue_events_url": "https://api.github.com/repos/realmarv/conventions/issues/events{/number}", + "issues_url": "https://api.github.com/repos/realmarv/conventions/issues{/number}", + "keys_url": "https://api.github.com/repos/realmarv/conventions/keys{/key_id}", + "labels_url": "https://api.github.com/repos/realmarv/conventions/labels{/name}", + "language": "TypeScript", + "languages_url": "https://api.github.com/repos/realmarv/conventions/languages", + "license": { + "key": "mit", + "name": "MIT License", + "node_id": "MDc6TGljZW5zZTEz", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit" + }, + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE", + "merges_url": "https://api.github.com/repos/realmarv/conventions/merges", + "milestones_url": "https://api.github.com/repos/realmarv/conventions/milestones{/number}", + "mirror_url": null, + "name": "conventions", + "node_id": "R_kgDOIMpMhA", + "notifications_url": "https://api.github.com/repos/realmarv/conventions/notifications{?since,all,participating}", + "open_issues": 4, + "open_issues_count": 4, + "owner": { + "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", + "events_url": "https://api.github.com/users/realmarv/events{/privacy}", + "followers_url": "https://api.github.com/users/realmarv/followers", + "following_url": "https://api.github.com/users/realmarv/following{/other_user}", + "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", + "gravatar_id": "", + "html_url": "https://github.com/realmarv", + "id": 50144546, + "login": "realmarv", + "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", + "organizations_url": "https://api.github.com/users/realmarv/orgs", + "received_events_url": "https://api.github.com/users/realmarv/received_events", + "repos_url": "https://api.github.com/users/realmarv/repos", + "site_admin": false, + "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", + "type": "User", + "url": "https://api.github.com/users/realmarv" + }, + "private": false, + "pulls_url": "https://api.github.com/repos/realmarv/conventions/pulls{/number}", + "pushed_at": "2023-03-23T09:00:26Z", + "releases_url": "https://api.github.com/repos/realmarv/conventions/releases{/id}", + "size": 2395, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "ssh_url": "git@github.com:realmarv/conventions.git", + "stargazers_count": 0, + "stargazers_url": "https://api.github.com/repos/realmarv/conventions/stargazers", + "statuses_url": "https://api.github.com/repos/realmarv/conventions/statuses/{sha}", + "subscribers_url": "https://api.github.com/repos/realmarv/conventions/subscribers", + "subscription_url": "https://api.github.com/repos/realmarv/conventions/subscription", + "svn_url": "https://github.com/realmarv/conventions", + "tags_url": "https://api.github.com/repos/realmarv/conventions/tags", + "teams_url": "https://api.github.com/repos/realmarv/conventions/teams", + "topics": [], + "trees_url": "https://api.github.com/repos/realmarv/conventions/git/trees{/sha}", + "updated_at": "2022-10-13T08:53:39Z", + "url": "https://api.github.com/repos/realmarv/conventions", + "use_squash_pr_title_as_default": false, + "visibility": "public", + "watchers": 0, + "watchers_count": 0, + "web_commit_signoff_required": false + }, + "sha": "0be2f2d608cdf893e146db1296dee750a2a54cfc", + "user": { + "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", + "events_url": "https://api.github.com/users/realmarv/events{/privacy}", + "followers_url": "https://api.github.com/users/realmarv/followers", + "following_url": "https://api.github.com/users/realmarv/following{/other_user}", + "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", + "gravatar_id": "", + "html_url": "https://github.com/realmarv", + "id": 50144546, + "login": "realmarv", + "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", + "organizations_url": "https://api.github.com/users/realmarv/orgs", + "received_events_url": "https://api.github.com/users/realmarv/received_events", + "repos_url": "https://api.github.com/users/realmarv/repos", + "site_admin": false, + "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", + "type": "User", + "url": "https://api.github.com/users/realmarv" + } + }, + "body": null, + "changed_files": 2, + "closed_at": null, + "comments": 0, + "comments_url": "https://api.github.com/repos/realmarv/conventions/issues/4/comments", + "commits": 2, + "commits_url": "https://api.github.com/repos/realmarv/conventions/pulls/4/commits", + "created_at": "2023-03-23T09:00:26Z", + "deletions": 0, + "diff_url": "https://github.com/realmarv/conventions/pull/4.diff", + "draft": false, + "head": { + "label": "realmarv:fixGitPush1by1Check", + "ref": "fixGitPush1by1Check", + "repo": { + "allow_auto_merge": false, + "allow_forking": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_squash_merge": true, + "allow_update_branch": false, + "archive_url": "https://api.github.com/repos/realmarv/conventions/{archive_format}{/ref}", + "archived": false, + "assignees_url": "https://api.github.com/repos/realmarv/conventions/assignees{/user}", + "blobs_url": "https://api.github.com/repos/realmarv/conventions/git/blobs{/sha}", + "branches_url": "https://api.github.com/repos/realmarv/conventions/branches{/branch}", + "clone_url": "https://github.com/realmarv/conventions.git", + "collaborators_url": "https://api.github.com/repos/realmarv/conventions/collaborators{/collaborator}", + "comments_url": "https://api.github.com/repos/realmarv/conventions/comments{/number}", + "commits_url": "https://api.github.com/repos/realmarv/conventions/commits{/sha}", + "compare_url": "https://api.github.com/repos/realmarv/conventions/compare/{base}...{head}", + "contents_url": "https://api.github.com/repos/realmarv/conventions/contents/{+path}", + "contributors_url": "https://api.github.com/repos/realmarv/conventions/contributors", + "created_at": "2022-10-12T08:48:57Z", + "default_branch": "master", + "delete_branch_on_merge": false, + "deployments_url": "https://api.github.com/repos/realmarv/conventions/deployments", + "description": null, + "disabled": false, + "downloads_url": "https://api.github.com/repos/realmarv/conventions/downloads", + "events_url": "https://api.github.com/repos/realmarv/conventions/events", + "fork": true, + "forks": 0, + "forks_count": 0, + "forks_url": "https://api.github.com/repos/realmarv/conventions/forks", + "full_name": "realmarv/conventions", + "git_commits_url": "https://api.github.com/repos/realmarv/conventions/git/commits{/sha}", + "git_refs_url": "https://api.github.com/repos/realmarv/conventions/git/refs{/sha}", + "git_tags_url": "https://api.github.com/repos/realmarv/conventions/git/tags{/sha}", + "git_url": "git://github.com/realmarv/conventions.git", + "has_discussions": false, + "has_downloads": true, + "has_issues": false, + "has_pages": false, + "has_projects": true, + "has_wiki": true, + "homepage": null, + "hooks_url": "https://api.github.com/repos/realmarv/conventions/hooks", + "html_url": "https://github.com/realmarv/conventions", + "id": 550128772, + "is_template": false, + "issue_comment_url": "https://api.github.com/repos/realmarv/conventions/issues/comments{/number}", + "issue_events_url": "https://api.github.com/repos/realmarv/conventions/issues/events{/number}", + "issues_url": "https://api.github.com/repos/realmarv/conventions/issues{/number}", + "keys_url": "https://api.github.com/repos/realmarv/conventions/keys{/key_id}", + "labels_url": "https://api.github.com/repos/realmarv/conventions/labels{/name}", + "language": "TypeScript", + "languages_url": "https://api.github.com/repos/realmarv/conventions/languages", + "license": { + "key": "mit", + "name": "MIT License", + "node_id": "MDc6TGljZW5zZTEz", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit" + }, + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE", + "merges_url": "https://api.github.com/repos/realmarv/conventions/merges", + "milestones_url": "https://api.github.com/repos/realmarv/conventions/milestones{/number}", + "mirror_url": null, + "name": "conventions", + "node_id": "R_kgDOIMpMhA", + "notifications_url": "https://api.github.com/repos/realmarv/conventions/notifications{?since,all,participating}", + "open_issues": 4, + "open_issues_count": 4, + "owner": { + "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", + "events_url": "https://api.github.com/users/realmarv/events{/privacy}", + "followers_url": "https://api.github.com/users/realmarv/followers", + "following_url": "https://api.github.com/users/realmarv/following{/other_user}", + "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", + "gravatar_id": "", + "html_url": "https://github.com/realmarv", + "id": 50144546, + "login": "realmarv", + "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", + "organizations_url": "https://api.github.com/users/realmarv/orgs", + "received_events_url": "https://api.github.com/users/realmarv/received_events", + "repos_url": "https://api.github.com/users/realmarv/repos", + "site_admin": false, + "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", + "type": "User", + "url": "https://api.github.com/users/realmarv" + }, + "private": false, + "pulls_url": "https://api.github.com/repos/realmarv/conventions/pulls{/number}", + "pushed_at": "2023-03-23T09:00:26Z", + "releases_url": "https://api.github.com/repos/realmarv/conventions/releases{/id}", + "size": 2395, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "ssh_url": "git@github.com:realmarv/conventions.git", + "stargazers_count": 0, + "stargazers_url": "https://api.github.com/repos/realmarv/conventions/stargazers", + "statuses_url": "https://api.github.com/repos/realmarv/conventions/statuses/{sha}", + "subscribers_url": "https://api.github.com/repos/realmarv/conventions/subscribers", + "subscription_url": "https://api.github.com/repos/realmarv/conventions/subscription", + "svn_url": "https://github.com/realmarv/conventions", + "tags_url": "https://api.github.com/repos/realmarv/conventions/tags", + "teams_url": "https://api.github.com/repos/realmarv/conventions/teams", + "topics": [], + "trees_url": "https://api.github.com/repos/realmarv/conventions/git/trees{/sha}", + "updated_at": "2022-10-13T08:53:39Z", + "url": "https://api.github.com/repos/realmarv/conventions", + "use_squash_pr_title_as_default": false, + "visibility": "public", + "watchers": 0, + "watchers_count": 0, + "web_commit_signoff_required": false + }, + "sha": "c5eb50ea6c5a72d61ab85d96ffc66cc4741d3133", + "user": { + "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", + "events_url": "https://api.github.com/users/realmarv/events{/privacy}", + "followers_url": "https://api.github.com/users/realmarv/followers", + "following_url": "https://api.github.com/users/realmarv/following{/other_user}", + "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", + "gravatar_id": "", + "html_url": "https://github.com/realmarv", + "id": 50144546, + "login": "realmarv", + "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", + "organizations_url": "https://api.github.com/users/realmarv/orgs", + "received_events_url": "https://api.github.com/users/realmarv/received_events", + "repos_url": "https://api.github.com/users/realmarv/repos", + "site_admin": false, + "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", + "type": "User", + "url": "https://api.github.com/users/realmarv" + } + }, + "html_url": "https://github.com/realmarv/conventions/pull/4", + "id": 1287033164, + "issue_url": "https://api.github.com/repos/realmarv/conventions/issues/4", + "labels": [], + "locked": false, + "maintainer_can_modify": false, + "merge_commit_sha": null, + "mergeable": null, + "mergeable_state": "unknown", + "merged": false, + "merged_at": null, + "merged_by": null, + "milestone": null, + "node_id": "PR_kwDOIMpMhM5MtpFM", + "number": 4, + "patch_url": "https://github.com/realmarv/conventions/pull/4.patch", + "rebaseable": null, + "requested_reviewers": [], + "requested_teams": [], + "review_comment_url": "https://api.github.com/repos/realmarv/conventions/pulls/comments{/number}", + "review_comments": 0, + "review_comments_url": "https://api.github.com/repos/realmarv/conventions/pulls/4/comments", + "state": "open", + "statuses_url": "https://api.github.com/repos/realmarv/conventions/statuses/c5eb50ea6c5a72d61ab85d96ffc66cc4741d3133", + "title": "Fix git push1by1 check", + "updated_at": "2023-03-23T09:00:26Z", + "url": "https://api.github.com/repos/realmarv/conventions/pulls/4", + "user": { + "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", + "events_url": "https://api.github.com/users/realmarv/events{/privacy}", + "followers_url": "https://api.github.com/users/realmarv/followers", + "following_url": "https://api.github.com/users/realmarv/following{/other_user}", + "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", + "gravatar_id": "", + "html_url": "https://github.com/realmarv", + "id": 50144546, + "login": "realmarv", + "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", + "organizations_url": "https://api.github.com/users/realmarv/orgs", + "received_events_url": "https://api.github.com/users/realmarv/received_events", + "repos_url": "https://api.github.com/users/realmarv/repos", + "site_admin": false, + "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", + "type": "User", + "url": "https://api.github.com/users/realmarv" + } + }, + "repository": { + "allow_forking": true, + "archive_url": "https://api.github.com/repos/realmarv/conventions/{archive_format}{/ref}", + "archived": false, + "assignees_url": "https://api.github.com/repos/realmarv/conventions/assignees{/user}", + "blobs_url": "https://api.github.com/repos/realmarv/conventions/git/blobs{/sha}", + "branches_url": "https://api.github.com/repos/realmarv/conventions/branches{/branch}", + "clone_url": "https://github.com/realmarv/conventions.git", + "collaborators_url": "https://api.github.com/repos/realmarv/conventions/collaborators{/collaborator}", + "comments_url": "https://api.github.com/repos/realmarv/conventions/comments{/number}", + "commits_url": "https://api.github.com/repos/realmarv/conventions/commits{/sha}", + "compare_url": "https://api.github.com/repos/realmarv/conventions/compare/{base}...{head}", + "contents_url": "https://api.github.com/repos/realmarv/conventions/contents/{+path}", + "contributors_url": "https://api.github.com/repos/realmarv/conventions/contributors", + "created_at": "2022-10-12T08:48:57Z", + "default_branch": "master", + "deployments_url": "https://api.github.com/repos/realmarv/conventions/deployments", + "description": null, + "disabled": false, + "downloads_url": "https://api.github.com/repos/realmarv/conventions/downloads", + "events_url": "https://api.github.com/repos/realmarv/conventions/events", + "fork": true, + "forks": 0, + "forks_count": 0, + "forks_url": "https://api.github.com/repos/realmarv/conventions/forks", + "full_name": "realmarv/conventions", + "git_commits_url": "https://api.github.com/repos/realmarv/conventions/git/commits{/sha}", + "git_refs_url": "https://api.github.com/repos/realmarv/conventions/git/refs{/sha}", + "git_tags_url": "https://api.github.com/repos/realmarv/conventions/git/tags{/sha}", + "git_url": "git://github.com/realmarv/conventions.git", + "has_discussions": false, + "has_downloads": true, + "has_issues": false, + "has_pages": false, + "has_projects": true, + "has_wiki": true, + "homepage": null, + "hooks_url": "https://api.github.com/repos/realmarv/conventions/hooks", + "html_url": "https://github.com/realmarv/conventions", + "id": 550128772, + "is_template": false, + "issue_comment_url": "https://api.github.com/repos/realmarv/conventions/issues/comments{/number}", + "issue_events_url": "https://api.github.com/repos/realmarv/conventions/issues/events{/number}", + "issues_url": "https://api.github.com/repos/realmarv/conventions/issues{/number}", + "keys_url": "https://api.github.com/repos/realmarv/conventions/keys{/key_id}", + "labels_url": "https://api.github.com/repos/realmarv/conventions/labels{/name}", + "language": "TypeScript", + "languages_url": "https://api.github.com/repos/realmarv/conventions/languages", + "license": { + "key": "mit", + "name": "MIT License", + "node_id": "MDc6TGljZW5zZTEz", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit" + }, + "merges_url": "https://api.github.com/repos/realmarv/conventions/merges", + "milestones_url": "https://api.github.com/repos/realmarv/conventions/milestones{/number}", + "mirror_url": null, + "name": "conventions", + "node_id": "R_kgDOIMpMhA", + "notifications_url": "https://api.github.com/repos/realmarv/conventions/notifications{?since,all,participating}", + "open_issues": 4, + "open_issues_count": 4, + "owner": { + "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", + "events_url": "https://api.github.com/users/realmarv/events{/privacy}", + "followers_url": "https://api.github.com/users/realmarv/followers", + "following_url": "https://api.github.com/users/realmarv/following{/other_user}", + "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", + "gravatar_id": "", + "html_url": "https://github.com/realmarv", + "id": 50144546, + "login": "realmarv", + "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", + "organizations_url": "https://api.github.com/users/realmarv/orgs", + "received_events_url": "https://api.github.com/users/realmarv/received_events", + "repos_url": "https://api.github.com/users/realmarv/repos", + "site_admin": false, + "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", + "type": "User", + "url": "https://api.github.com/users/realmarv" + }, + "private": false, + "pulls_url": "https://api.github.com/repos/realmarv/conventions/pulls{/number}", + "pushed_at": "2023-03-23T09:00:26Z", + "releases_url": "https://api.github.com/repos/realmarv/conventions/releases{/id}", + "size": 2395, + "ssh_url": "git@github.com:realmarv/conventions.git", + "stargazers_count": 0, + "stargazers_url": "https://api.github.com/repos/realmarv/conventions/stargazers", + "statuses_url": "https://api.github.com/repos/realmarv/conventions/statuses/{sha}", + "subscribers_url": "https://api.github.com/repos/realmarv/conventions/subscribers", + "subscription_url": "https://api.github.com/repos/realmarv/conventions/subscription", + "svn_url": "https://github.com/realmarv/conventions", + "tags_url": "https://api.github.com/repos/realmarv/conventions/tags", + "teams_url": "https://api.github.com/repos/realmarv/conventions/teams", + "topics": [], + "trees_url": "https://api.github.com/repos/realmarv/conventions/git/trees{/sha}", + "updated_at": "2022-10-13T08:53:39Z", + "url": "https://api.github.com/repos/realmarv/conventions", + "visibility": "public", + "watchers": 0, + "watchers_count": 0, + "web_commit_signoff_required": false + }, + "sender": { + "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", + "events_url": "https://api.github.com/users/realmarv/events{/privacy}", + "followers_url": "https://api.github.com/users/realmarv/followers", + "following_url": "https://api.github.com/users/realmarv/following{/other_user}", + "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", + "gravatar_id": "", + "html_url": "https://github.com/realmarv", + "id": 50144546, + "login": "realmarv", + "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", + "organizations_url": "https://api.github.com/users/realmarv/orgs", + "received_events_url": "https://api.github.com/users/realmarv/received_events", + "repos_url": "https://api.github.com/users/realmarv/repos", + "site_admin": false, + "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", + "type": "User", + "url": "https://api.github.com/users/realmarv" + } + } +"""> + +let jsonString = File.ReadAllText githubEventPath +let parsedJsonObj = githubEventType.Parse jsonString + +let gitForkUser = parsedJsonObj.PullRequest.Head.User.Login +let gitForkRepo = parsedJsonObj.PullRequest.Head.Repo.Name +let gitRepo = $"{gitForkUser}/{gitForkRepo}" + let currentBranch = Process .Execute( From d0e72c6a0eb5b6b0e38096dfabed180f8aa41847 Mon Sep 17 00:00:00 2001 From: realmarv Date: Mon, 27 Mar 2023 18:00:13 +0330 Subject: [PATCH 4/5] scripts/detectNotUsingGitPush1by1: improve Improve the detectNotUsingGitPush1by1.fsx script to detect wrong CI status of commits. If commit msg contains text "failing test", then it would be allowed to have broken CI, else CI should be green. Fixes https://github.com/nblockchain/conventions/issues/95 --- scripts/detectNotUsingGitPush1by1.fsx | 456 ++++++++++++++++++++++++-- 1 file changed, 430 insertions(+), 26 deletions(-) diff --git a/scripts/detectNotUsingGitPush1by1.fsx b/scripts/detectNotUsingGitPush1by1.fsx index 0e5d03cf1..e81473633 100644 --- a/scripts/detectNotUsingGitPush1by1.fsx +++ b/scripts/detectNotUsingGitPush1by1.fsx @@ -563,37 +563,441 @@ let prCommits = .Split "\n" |> Seq.tail -let notUsingGitPush1by1 = - prCommits - |> Seq.map(fun commit -> - use client = new HttpClient() - client.DefaultRequestHeaders.Accept.Clear() - - client.DefaultRequestHeaders.Accept.Add( - MediaTypeWithQualityHeaderValue "application/vnd.github+json" - ) +type checkSuitsType = + JsonProvider<""" +{ + "total_count": 2, + "check_suites": [ + { + "id": 11157990057, + "node_id": "CS_kwDOIMpMhM8AAAACmRFqqQ", + "head_branch": "fSharpScriptsWithoutShebang-squashed2", + "head_sha": "86140764e7f95649a70f117067146d4a6b7c8201", + "status": "completed", + "conclusion": "success", + "url": "https://api.github.com/repos/realmarv/conventions/check-suites/11157990057", + "before": "b0d38475ff2e95f8f424c98a85efd39658d5ff15", + "after": "86140764e7f95649a70f117067146d4a6b7c8201", + "pull_requests": [ - client.DefaultRequestHeaders.Add("User-Agent", ".NET App") - client.DefaultRequestHeaders.Add("X-GitHub-Api-Version", "2022-11-28") + ], + "app": { + "id": 15368, + "slug": "github-actions", + "node_id": "MDM6QXBwMTUzNjg=", + "owner": { + "login": "github", + "id": 9919, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", + "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github", + "html_url": "https://github.com/github", + "followers_url": "https://api.github.com/users/github/followers", + "following_url": "https://api.github.com/users/github/following{/other_user}", + "gists_url": "https://api.github.com/users/github/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github/subscriptions", + "organizations_url": "https://api.github.com/users/github/orgs", + "repos_url": "https://api.github.com/users/github/repos", + "events_url": "https://api.github.com/users/github/events{/privacy}", + "received_events_url": "https://api.github.com/users/github/received_events", + "type": "Organization", + "site_admin": false + }, + "name": "GitHub Actions", + "description": "Automate your workflow from idea to production", + "external_url": "https://help.github.com/en/actions", + "html_url": "https://github.com/apps/github-actions", + "created_at": "2018-07-30T09:30:17Z", + "updated_at": "2019-12-10T19:04:12Z", + "permissions": { + "actions": "write", + "administration": "read", + "checks": "write", + "contents": "write", + "deployments": "write", + "discussions": "write", + "issues": "write", + "merge_queues": "write", + "metadata": "read", + "packages": "write", + "pages": "write", + "pull_requests": "write", + "repository_hooks": "write", + "repository_projects": "write", + "security_events": "write", + "statuses": "write", + "vulnerability_alerts": "read" + }, + "events": [ + "branch_protection_rule", + "check_run", + "check_suite", + "create", + "delete", + "deployment", + "deployment_status", + "discussion", + "discussion_comment", + "fork", + "gollum", + "issues", + "issue_comment", + "label", + "merge_group", + "milestone", + "page_build", + "project", + "project_card", + "project_column", + "public", + "pull_request", + "pull_request_review", + "pull_request_review_comment", + "push", + "registry_package", + "release", + "repository", + "repository_dispatch", + "status", + "watch", + "workflow_dispatch", + "workflow_run" + ] + }, + "created_at": "2023-02-23T12:10:48Z", + "updated_at": "2023-02-23T12:16:40Z", + "rerequestable": true, + "runs_rerequestable": false, + "latest_check_runs_count": 3, + "check_runs_url": "https://api.github.com/repos/realmarv/conventions/check-suites/11157990057/check-runs", + "head_commit": { + "id": "86140764e7f95649a70f117067146d4a6b7c8201", + "tree_id": "381222317743d7ccb6ae59ca9d4079c9f7ef882c", + "message": "FileConventions: add HasCorrectShebang function", + "timestamp": "2023-02-23T12:02:15Z", + "author": { + "name": "realmarv", + "email": "zahratehraninasab@gmail.com" + }, + "committer": { + "name": "realmarv", + "email": "zahratehraninasab@gmail.com" + } + }, + "repository": { + "id": 550128772, + "node_id": "R_kgDOIMpMhA", + "name": "conventions", + "full_name": "realmarv/conventions", + "private": false, + "owner": { + "login": "realmarv", + "id": 50144546, + "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", + "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/realmarv", + "html_url": "https://github.com/realmarv", + "followers_url": "https://api.github.com/users/realmarv/followers", + "following_url": "https://api.github.com/users/realmarv/following{/other_user}", + "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", + "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", + "organizations_url": "https://api.github.com/users/realmarv/orgs", + "repos_url": "https://api.github.com/users/realmarv/repos", + "events_url": "https://api.github.com/users/realmarv/events{/privacy}", + "received_events_url": "https://api.github.com/users/realmarv/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/realmarv/conventions", + "description": null, + "fork": true, + "url": "https://api.github.com/repos/realmarv/conventions", + "forks_url": "https://api.github.com/repos/realmarv/conventions/forks", + "keys_url": "https://api.github.com/repos/realmarv/conventions/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/realmarv/conventions/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/realmarv/conventions/teams", + "hooks_url": "https://api.github.com/repos/realmarv/conventions/hooks", + "issue_events_url": "https://api.github.com/repos/realmarv/conventions/issues/events{/number}", + "events_url": "https://api.github.com/repos/realmarv/conventions/events", + "assignees_url": "https://api.github.com/repos/realmarv/conventions/assignees{/user}", + "branches_url": "https://api.github.com/repos/realmarv/conventions/branches{/branch}", + "tags_url": "https://api.github.com/repos/realmarv/conventions/tags", + "blobs_url": "https://api.github.com/repos/realmarv/conventions/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/realmarv/conventions/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/realmarv/conventions/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/realmarv/conventions/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/realmarv/conventions/statuses/{sha}", + "languages_url": "https://api.github.com/repos/realmarv/conventions/languages", + "stargazers_url": "https://api.github.com/repos/realmarv/conventions/stargazers", + "contributors_url": "https://api.github.com/repos/realmarv/conventions/contributors", + "subscribers_url": "https://api.github.com/repos/realmarv/conventions/subscribers", + "subscription_url": "https://api.github.com/repos/realmarv/conventions/subscription", + "commits_url": "https://api.github.com/repos/realmarv/conventions/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/realmarv/conventions/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/realmarv/conventions/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/realmarv/conventions/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/realmarv/conventions/contents/{+path}", + "compare_url": "https://api.github.com/repos/realmarv/conventions/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/realmarv/conventions/merges", + "archive_url": "https://api.github.com/repos/realmarv/conventions/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/realmarv/conventions/downloads", + "issues_url": "https://api.github.com/repos/realmarv/conventions/issues{/number}", + "pulls_url": "https://api.github.com/repos/realmarv/conventions/pulls{/number}", + "milestones_url": "https://api.github.com/repos/realmarv/conventions/milestones{/number}", + "notifications_url": "https://api.github.com/repos/realmarv/conventions/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/realmarv/conventions/labels{/name}", + "releases_url": "https://api.github.com/repos/realmarv/conventions/releases{/id}", + "deployments_url": "https://api.github.com/repos/realmarv/conventions/deployments" + } + }, + { + "id": 11158210887, + "node_id": "CS_kwDOIMpMhM8AAAACmRTJRw", + "head_branch": "fSharpScriptsWithoutShebang-squashed2", + "head_sha": "86140764e7f95649a70f117067146d4a6b7c8201", + "status": "completed", + "conclusion": "success", + "url": "https://api.github.com/repos/realmarv/conventions/check-suites/11158210887", + "before": "b0d38475ff2e95f8f424c98a85efd39658d5ff15", + "after": "86140764e7f95649a70f117067146d4a6b7c8201", + "pull_requests": [ - let url = - sprintf - "https://api.github.com/repos/%s/commits/%s/check-suites" - gitRepo - commit + ], + "app": { + "id": 15368, + "slug": "github-actions", + "node_id": "MDM6QXBwMTUzNjg=", + "owner": { + "login": "github", + "id": 9919, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", + "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/github", + "html_url": "https://github.com/github", + "followers_url": "https://api.github.com/users/github/followers", + "following_url": "https://api.github.com/users/github/following{/other_user}", + "gists_url": "https://api.github.com/users/github/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github/subscriptions", + "organizations_url": "https://api.github.com/users/github/orgs", + "repos_url": "https://api.github.com/users/github/repos", + "events_url": "https://api.github.com/users/github/events{/privacy}", + "received_events_url": "https://api.github.com/users/github/received_events", + "type": "Organization", + "site_admin": false + }, + "name": "GitHub Actions", + "description": "Automate your workflow from idea to production", + "external_url": "https://help.github.com/en/actions", + "html_url": "https://github.com/apps/github-actions", + "created_at": "2018-07-30T09:30:17Z", + "updated_at": "2019-12-10T19:04:12Z", + "permissions": { + "actions": "write", + "administration": "read", + "checks": "write", + "contents": "write", + "deployments": "write", + "discussions": "write", + "issues": "write", + "merge_queues": "write", + "metadata": "read", + "packages": "write", + "pages": "write", + "pull_requests": "write", + "repository_hooks": "write", + "repository_projects": "write", + "security_events": "write", + "statuses": "write", + "vulnerability_alerts": "read" + }, + "events": [ + "branch_protection_rule", + "check_run", + "check_suite", + "create", + "delete", + "deployment", + "deployment_status", + "discussion", + "discussion_comment", + "fork", + "gollum", + "issues", + "issue_comment", + "label", + "merge_group", + "milestone", + "page_build", + "project", + "project_card", + "project_column", + "public", + "pull_request", + "pull_request_review", + "pull_request_review_comment", + "push", + "registry_package", + "release", + "repository", + "repository_dispatch", + "status", + "watch", + "workflow_dispatch", + "workflow_run" + ] + }, + "created_at": "2023-02-23T12:21:33Z", + "updated_at": "2023-02-23T12:26:13Z", + "rerequestable": true, + "runs_rerequestable": false, + "latest_check_runs_count": 3, + "check_runs_url": "https://api.github.com/repos/realmarv/conventions/check-suites/11158210887/check-runs", + "head_commit": { + "id": "86140764e7f95649a70f117067146d4a6b7c8201", + "tree_id": "381222317743d7ccb6ae59ca9d4079c9f7ef882c", + "message": "FileConventions: add HasCorrectShebang function", + "timestamp": "2023-02-23T12:02:15Z", + "author": { + "name": "realmarv", + "email": "zahratehraninasab@gmail.com" + }, + "committer": { + "name": "realmarv", + "email": "zahratehraninasab@gmail.com" + } + }, + "repository": { + "id": 550128772, + "node_id": "R_kgDOIMpMhA", + "name": "conventions", + "full_name": "realmarv/conventions", + "private": false, + "owner": { + "login": "realmarv", + "id": 50144546, + "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", + "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/realmarv", + "html_url": "https://github.com/realmarv", + "followers_url": "https://api.github.com/users/realmarv/followers", + "following_url": "https://api.github.com/users/realmarv/following{/other_user}", + "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", + "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", + "organizations_url": "https://api.github.com/users/realmarv/orgs", + "repos_url": "https://api.github.com/users/realmarv/repos", + "events_url": "https://api.github.com/users/realmarv/events{/privacy}", + "received_events_url": "https://api.github.com/users/realmarv/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/realmarv/conventions", + "description": null, + "fork": true, + "url": "https://api.github.com/repos/realmarv/conventions", + "forks_url": "https://api.github.com/repos/realmarv/conventions/forks", + "keys_url": "https://api.github.com/repos/realmarv/conventions/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/realmarv/conventions/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/realmarv/conventions/teams", + "hooks_url": "https://api.github.com/repos/realmarv/conventions/hooks", + "issue_events_url": "https://api.github.com/repos/realmarv/conventions/issues/events{/number}", + "events_url": "https://api.github.com/repos/realmarv/conventions/events", + "assignees_url": "https://api.github.com/repos/realmarv/conventions/assignees{/user}", + "branches_url": "https://api.github.com/repos/realmarv/conventions/branches{/branch}", + "tags_url": "https://api.github.com/repos/realmarv/conventions/tags", + "blobs_url": "https://api.github.com/repos/realmarv/conventions/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/realmarv/conventions/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/realmarv/conventions/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/realmarv/conventions/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/realmarv/conventions/statuses/{sha}", + "languages_url": "https://api.github.com/repos/realmarv/conventions/languages", + "stargazers_url": "https://api.github.com/repos/realmarv/conventions/stargazers", + "contributors_url": "https://api.github.com/repos/realmarv/conventions/contributors", + "subscribers_url": "https://api.github.com/repos/realmarv/conventions/subscribers", + "subscription_url": "https://api.github.com/repos/realmarv/conventions/subscription", + "commits_url": "https://api.github.com/repos/realmarv/conventions/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/realmarv/conventions/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/realmarv/conventions/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/realmarv/conventions/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/realmarv/conventions/contents/{+path}", + "compare_url": "https://api.github.com/repos/realmarv/conventions/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/realmarv/conventions/merges", + "archive_url": "https://api.github.com/repos/realmarv/conventions/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/realmarv/conventions/downloads", + "issues_url": "https://api.github.com/repos/realmarv/conventions/issues{/number}", + "pulls_url": "https://api.github.com/repos/realmarv/conventions/pulls{/number}", + "milestones_url": "https://api.github.com/repos/realmarv/conventions/milestones{/number}", + "notifications_url": "https://api.github.com/repos/realmarv/conventions/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/realmarv/conventions/labels{/name}", + "releases_url": "https://api.github.com/repos/realmarv/conventions/releases{/id}", + "deployments_url": "https://api.github.com/repos/realmarv/conventions/deployments" + } + } + ] +} +"""> - let json = (client.GetStringAsync url).Result +prCommits +|> Seq.iter(fun commit -> + use client = new HttpClient() + client.DefaultRequestHeaders.Accept.Clear() - json.Contains "\"check_suites\":[]" + client.DefaultRequestHeaders.Accept.Add( + MediaTypeWithQualityHeaderValue "application/vnd.github+json" ) - |> Seq.contains true -if notUsingGitPush1by1 then - let errMsg = + client.DefaultRequestHeaders.Add("User-Agent", ".NET App") + client.DefaultRequestHeaders.Add("X-GitHub-Api-Version", "2022-11-28") + + let url = sprintf - "Please push the commits one by one; using this script is recommended:%s%s" - Environment.NewLine - "https://github.com/nblockchain/conventions/blob/master/scripts/gitPush1by1.fsx" + "https://api.github.com/repos/%s/commits/%s/check-suites" + gitRepo + commit + + let checkSuitsJsonString = (client.GetStringAsync url).Result + + if checkSuitsJsonString.Contains "\"check_suites\":[]" then + let errMsg = + sprintf + "Please push the commits one by one; using this script is recommended:%s%s" + Environment.NewLine + "https://github.com/nblockchain/conventions/blob/master/scripts/gitPush1by1.fsx" + + Console.Error.WriteLine errMsg + Environment.Exit 1 + + let checkSuitsParsedJson = checkSuitsType.Parse checkSuitsJsonString + + let commitMessageTitle = + (checkSuitsParsedJson.CheckSuites.[0] + .HeadCommit + .Message) + .Split( + "\n" + ).[0] + + let commitHash = checkSuitsParsedJson.CheckSuites.[0].HeadSha + let status = checkSuitsParsedJson.CheckSuites.[0].Status + let conclusion = checkSuitsParsedJson.CheckSuites.[0].Conclusion + + if status = "completed" then + if commitMessageTitle.Contains "failing test" && conclusion = "success" then + Console.Error.WriteLine + $"The CI status of the commit \"{commitHash}\" must be `failure`, since it's adding a failing test." + + Environment.Exit 2 + + else if conclusion = "failure" then + Console.Error.WriteLine + $"The CI status of a commit that doesn't add a failing test must be `success`." - Console.Error.WriteLine errMsg - Environment.Exit 1 + Environment.Exit 2 +) From 4933be8ece2e745f6d8b32fbfec2e46d743a3834 Mon Sep 17 00:00:00 2001 From: realmarv Date: Tue, 28 Mar 2023 14:43:51 +0330 Subject: [PATCH 5/5] wip1 --- scripts/detectNotUsingGitPush1by1.fsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/detectNotUsingGitPush1by1.fsx b/scripts/detectNotUsingGitPush1by1.fsx index e81473633..dcbb3f96e 100644 --- a/scripts/detectNotUsingGitPush1by1.fsx +++ b/scripts/detectNotUsingGitPush1by1.fsx @@ -944,6 +944,8 @@ type checkSuitsType = } """> +printfn "prCommits: %A" prCommits + prCommits |> Seq.iter(fun commit -> use client = new HttpClient()