From 091b1c25f493e36a66c3b4ede2cdc170f9e64983 Mon Sep 17 00:00:00 2001 From: Yasunari Watanabe Date: Fri, 8 Jan 2021 16:42:22 +0800 Subject: [PATCH] tests: add cases that require per-build state tracking of statuses `status.success_test_different_steps_from_prev` This is for an incoming successful build on develop branch with a single build step, "notabot-test/build". There exist past successes for same branch + different steps, and for different branch + same step, but not for same branch + same step. Thus, it should generate a notification. `status.success_test_not_affected_by_unrelated_success_with_different_steps` This is for an incoming successful build on develop branch with two steps, "notabot-test/{build-infra,setup}". Here, previously a build with steps "build-infra" and "setup" failed on step "build-infra". Then a subsequent build with step "build" succeeded, so the overall pipeline state is a success. However, the more recent successful but unrelated build should not affect generation of another success notification, given the change in status state for "build-infra". --- ...uccess_test_different_steps_from_prev.json | 222 ++++++++++++++++++ ...nrelated_success_with_different_steps.json | 222 ++++++++++++++++++ ...uccess_test_different_steps_from_prev.json | 17 ++ ...nrelated_success_with_different_steps.json | 17 ++ .../71a5b16f3e880a58a4b63201174254c9663faca4 | 79 +++++++ ...f3e880a58a4b63201174254c9663faca4-statuses | 162 +++++++++++++ test/slack_payloads.expected | 44 ++++ 7 files changed, 763 insertions(+) create mode 100644 mock_payloads/status.success_test_different_steps_from_prev.json create mode 100644 mock_payloads/status.success_test_not_affected_by_unrelated_success_with_different_steps.json create mode 100644 mock_states/status.success_test_different_steps_from_prev.json create mode 100644 mock_states/status.success_test_not_affected_by_unrelated_success_with_different_steps.json create mode 100644 test/github-api-cache/71a5b16f3e880a58a4b63201174254c9663faca4 create mode 100644 test/github-api-cache/71a5b16f3e880a58a4b63201174254c9663faca4-statuses diff --git a/mock_payloads/status.success_test_different_steps_from_prev.json b/mock_payloads/status.success_test_different_steps_from_prev.json new file mode 100644 index 00000000..9279ece8 --- /dev/null +++ b/mock_payloads/status.success_test_different_steps_from_prev.json @@ -0,0 +1,222 @@ +{ + "id": 1437427, + "sha": "71a5b16f3e880a58a4b63201174254c9663faca4", + "name": "ahrefs/notabot_test", + "target_url": "https://buildkite.com/ahrefs/notabot-test/builds/4", + "avatar_url": "https://git.ahrefs.com/avatars/oa/6?", + "context": "buildkite/notabot-test", + "description": "Build #4 passed (5 minutes, 19 seconds)", + "state": "success", + "commit": { + "sha": "71a5b16f3e880a58a4b63201174254c9663faca4", + "node_id": "MDY6Q29tbWl0MTgyOjBkOTUzMDJhZGRkNjZjMTgxNmJjZTFiMWQ0OTVlZDFjOTNjY2Q0Nzg=", + "commit": { + "author": { + "name": "Louis Roché", + "email": "louis.roche@ahrefs.com", + "date": "2020-06-02T03:14:51Z" + }, + "committer": { + "name": "GitHub Enterprise", + "email": "git@ahrefs.com", + "date": "2020-06-02T03:14:51Z" + }, + "message": "Update README.md", + "tree": { + "sha": "ee5c539cad37c77348ce7a55756acc542b41cfc7", + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/trees/ee5c539cad37c77348ce7a55756acc542b41cfc7" + }, + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/commits/71a5b16f3e880a58a4b63201174254c9663faca4", + "comment_count": 0, + "verification": { + "verified": false, + "reason": "unsigned", + "signature": null, + "payload": null + } + }, + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/71a5b16f3e880a58a4b63201174254c9663faca4", + "html_url": "https://git.ahrefs.com/ahrefs/notabot_test/commit/71a5b16f3e880a58a4b63201174254c9663faca4", + "comments_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/71a5b16f3e880a58a4b63201174254c9663faca4/comments", + "author": { + "login": "louis", + "id": 34, + "node_id": "MDQ6VXNlcjM0", + "avatar_url": "https://git.ahrefs.com/avatars/u/34?", + "gravatar_id": "", + "url": "https://git.ahrefs.com/api/v3/users/louis", + "html_url": "https://git.ahrefs.com/louis", + "followers_url": "https://git.ahrefs.com/api/v3/users/louis/followers", + "following_url": "https://git.ahrefs.com/api/v3/users/louis/following{/other_user}", + "gists_url": "https://git.ahrefs.com/api/v3/users/louis/gists{/gist_id}", + "starred_url": "https://git.ahrefs.com/api/v3/users/louis/starred{/owner}{/repo}", + "subscriptions_url": "https://git.ahrefs.com/api/v3/users/louis/subscriptions", + "organizations_url": "https://git.ahrefs.com/api/v3/users/louis/orgs", + "repos_url": "https://git.ahrefs.com/api/v3/users/louis/repos", + "events_url": "https://git.ahrefs.com/api/v3/users/louis/events{/privacy}", + "received_events_url": "https://git.ahrefs.com/api/v3/users/louis/received_events", + "type": "User", + "site_admin": false + }, + "committer": null, + "parents": [ + { + "sha": "04cb72d6dc8d92131282a7eff57f6caf632f0a39", + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/04cb72d6dc8d92131282a7eff57f6caf632f0a39", + "html_url": "https://git.ahrefs.com/ahrefs/notabot_test/commit/04cb72d6dc8d92131282a7eff57f6caf632f0a39" + } + ] + }, + "branches": [ + { + "name": "develop", + "commit": { + "sha": "71a5b16f3e880a58a4b63201174254c9663faca4", + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/71a5b16f3e880a58a4b63201174254c9663faca4" + }, + "protected": false + } + ], + "created_at": "2020-06-02T03:21:39+00:00", + "updated_at": "2020-06-02T03:21:39+00:00", + "repository": { + "id": 182, + "node_id": "MDEwOlJlcG9zaXRvcnkxODI=", + "name": "notabot_test", + "full_name": "ahrefs/notabot_test", + "private": true, + "owner": { + "login": "ahrefs", + "id": 7, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc=", + "avatar_url": "https://git.ahrefs.com/avatars/u/7?", + "gravatar_id": "", + "url": "https://git.ahrefs.com/api/v3/users/ahrefs", + "html_url": "https://git.ahrefs.com/ahrefs", + "followers_url": "https://git.ahrefs.com/api/v3/users/ahrefs/followers", + "following_url": "https://git.ahrefs.com/api/v3/users/ahrefs/following{/other_user}", + "gists_url": "https://git.ahrefs.com/api/v3/users/ahrefs/gists{/gist_id}", + "starred_url": "https://git.ahrefs.com/api/v3/users/ahrefs/starred{/owner}{/repo}", + "subscriptions_url": "https://git.ahrefs.com/api/v3/users/ahrefs/subscriptions", + "organizations_url": "https://git.ahrefs.com/api/v3/users/ahrefs/orgs", + "repos_url": "https://git.ahrefs.com/api/v3/users/ahrefs/repos", + "events_url": "https://git.ahrefs.com/api/v3/users/ahrefs/events{/privacy}", + "received_events_url": "https://git.ahrefs.com/api/v3/users/ahrefs/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://git.ahrefs.com/ahrefs/notabot_test", + "description": null, + "fork": false, + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test", + "forks_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/forks", + "keys_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/keys{/key_id}", + "collaborators_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/collaborators{/collaborator}", + "teams_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/teams", + "hooks_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/hooks", + "issue_events_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/issues/events{/number}", + "events_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/events", + "assignees_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/assignees{/user}", + "branches_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/branches{/branch}", + "tags_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/tags", + "blobs_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/blobs{/sha}", + "git_tags_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/tags{/sha}", + "git_refs_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/refs{/sha}", + "trees_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/trees{/sha}", + "statuses_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/statuses/{sha}", + "languages_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/languages", + "stargazers_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/stargazers", + "contributors_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/contributors", + "subscribers_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/subscribers", + "subscription_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/subscription", + "commits_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits{/sha}", + "git_commits_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/commits{/sha}", + "comments_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/comments{/number}", + "issue_comment_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/issues/comments{/number}", + "contents_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/contents/{+path}", + "compare_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/compare/{base}...{head}", + "merges_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/merges", + "archive_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/{archive_format}{/ref}", + "downloads_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/downloads", + "issues_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/issues{/number}", + "pulls_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/pulls{/number}", + "milestones_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/milestones{/number}", + "notifications_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/notifications{?since,all,participating}", + "labels_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/labels{/name}", + "releases_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/releases{/id}", + "deployments_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/deployments", + "created_at": "2020-06-01T18:44:17Z", + "updated_at": "2020-06-02T03:14:53Z", + "pushed_at": "2020-06-02T03:14:51Z", + "git_url": "git://git.ahrefs.com/ahrefs/notabot_test.git", + "ssh_url": "git@git.ahrefs.com:ahrefs/notabot_test.git", + "clone_url": "https://git.ahrefs.com/ahrefs/notabot_test.git", + "svn_url": "https://git.ahrefs.com/ahrefs/notabot_test", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Shell", + "has_issues": true, + "has_projects": false, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master" + }, + "organization": { + "login": "ahrefs", + "id": 7, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc=", + "url": "https://git.ahrefs.com/api/v3/orgs/ahrefs", + "repos_url": "https://git.ahrefs.com/api/v3/orgs/ahrefs/repos", + "events_url": "https://git.ahrefs.com/api/v3/orgs/ahrefs/events", + "hooks_url": "https://git.ahrefs.com/api/v3/orgs/ahrefs/hooks", + "issues_url": "https://git.ahrefs.com/api/v3/orgs/ahrefs/issues", + "members_url": "https://git.ahrefs.com/api/v3/orgs/ahrefs/members{/member}", + "public_members_url": "https://git.ahrefs.com/api/v3/orgs/ahrefs/public_members{/member}", + "avatar_url": "https://git.ahrefs.com/avatars/u/7?", + "description": null + }, + "enterprise": { + "id": 1, + "slug": "ahrefs-pte-ltd", + "name": "Ahrefs Pte Ltd", + "node_id": "MDEwOkVudGVycHJpc2Ux", + "avatar_url": "https://git.ahrefs.com/avatars/b/1?", + "description": null, + "website_url": null, + "html_url": "https://git.ahrefs.com/enterprises/ahrefs-pte-ltd", + "created_at": "2019-01-09T18:50:55Z", + "updated_at": "2019-03-01T16:07:28Z" + }, + "sender": { + "login": "ip", + "id": 3, + "node_id": "MDQ6VXNlcjM=", + "avatar_url": "https://git.ahrefs.com/avatars/u/3?", + "gravatar_id": "", + "url": "https://git.ahrefs.com/api/v3/users/ip", + "html_url": "https://git.ahrefs.com/ip", + "followers_url": "https://git.ahrefs.com/api/v3/users/ip/followers", + "following_url": "https://git.ahrefs.com/api/v3/users/ip/following{/other_user}", + "gists_url": "https://git.ahrefs.com/api/v3/users/ip/gists{/gist_id}", + "starred_url": "https://git.ahrefs.com/api/v3/users/ip/starred{/owner}{/repo}", + "subscriptions_url": "https://git.ahrefs.com/api/v3/users/ip/subscriptions", + "organizations_url": "https://git.ahrefs.com/api/v3/users/ip/orgs", + "repos_url": "https://git.ahrefs.com/api/v3/users/ip/repos", + "events_url": "https://git.ahrefs.com/api/v3/users/ip/events{/privacy}", + "received_events_url": "https://git.ahrefs.com/api/v3/users/ip/received_events", + "type": "User", + "site_admin": true + } +} diff --git a/mock_payloads/status.success_test_not_affected_by_unrelated_success_with_different_steps.json b/mock_payloads/status.success_test_not_affected_by_unrelated_success_with_different_steps.json new file mode 100644 index 00000000..7cde7029 --- /dev/null +++ b/mock_payloads/status.success_test_not_affected_by_unrelated_success_with_different_steps.json @@ -0,0 +1,222 @@ +{ + "id": 1437427, + "sha": "0d95302addd66c1816bce1b1d495ed1c93ccd478", + "name": "ahrefs/notabot_test", + "target_url": "https://buildkite.com/ahrefs/notabot-test/builds/2", + "avatar_url": "https://git.ahrefs.com/avatars/oa/6?", + "context": "buildkite/notabot-test", + "description": "Build #2 passed (5 minutes, 19 seconds)", + "state": "success", + "commit": { + "sha": "0d95302addd66c1816bce1b1d495ed1c93ccd478", + "node_id": "MDY6Q29tbWl0MTgyOjBkOTUzMDJhZGRkNjZjMTgxNmJjZTFiMWQ0OTVlZDFjOTNjY2Q0Nzg=", + "commit": { + "author": { + "name": "Louis Roché", + "email": "louis.roche@ahrefs.com", + "date": "2020-06-02T03:14:51Z" + }, + "committer": { + "name": "GitHub Enterprise", + "email": "git@ahrefs.com", + "date": "2020-06-02T03:14:51Z" + }, + "message": "Update README.md", + "tree": { + "sha": "ee5c539cad37c77348ce7a55756acc542b41cfc7", + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/trees/ee5c539cad37c77348ce7a55756acc542b41cfc7" + }, + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/commits/0d95302addd66c1816bce1b1d495ed1c93ccd478", + "comment_count": 0, + "verification": { + "verified": false, + "reason": "unsigned", + "signature": null, + "payload": null + } + }, + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/0d95302addd66c1816bce1b1d495ed1c93ccd478", + "html_url": "https://git.ahrefs.com/ahrefs/notabot_test/commit/0d95302addd66c1816bce1b1d495ed1c93ccd478", + "comments_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/0d95302addd66c1816bce1b1d495ed1c93ccd478/comments", + "author": { + "login": "louis", + "id": 34, + "node_id": "MDQ6VXNlcjM0", + "avatar_url": "https://git.ahrefs.com/avatars/u/34?", + "gravatar_id": "", + "url": "https://git.ahrefs.com/api/v3/users/louis", + "html_url": "https://git.ahrefs.com/louis", + "followers_url": "https://git.ahrefs.com/api/v3/users/louis/followers", + "following_url": "https://git.ahrefs.com/api/v3/users/louis/following{/other_user}", + "gists_url": "https://git.ahrefs.com/api/v3/users/louis/gists{/gist_id}", + "starred_url": "https://git.ahrefs.com/api/v3/users/louis/starred{/owner}{/repo}", + "subscriptions_url": "https://git.ahrefs.com/api/v3/users/louis/subscriptions", + "organizations_url": "https://git.ahrefs.com/api/v3/users/louis/orgs", + "repos_url": "https://git.ahrefs.com/api/v3/users/louis/repos", + "events_url": "https://git.ahrefs.com/api/v3/users/louis/events{/privacy}", + "received_events_url": "https://git.ahrefs.com/api/v3/users/louis/received_events", + "type": "User", + "site_admin": false + }, + "committer": null, + "parents": [ + { + "sha": "04cb72d6dc8d92131282a7eff57f6caf632f0a39", + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/04cb72d6dc8d92131282a7eff57f6caf632f0a39", + "html_url": "https://git.ahrefs.com/ahrefs/notabot_test/commit/04cb72d6dc8d92131282a7eff57f6caf632f0a39" + } + ] + }, + "branches": [ + { + "name": "develop", + "commit": { + "sha": "0d95302addd66c1816bce1b1d495ed1c93ccd478", + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/0d95302addd66c1816bce1b1d495ed1c93ccd478" + }, + "protected": false + } + ], + "created_at": "2020-06-02T03:21:39+00:00", + "updated_at": "2020-06-02T03:21:39+00:00", + "repository": { + "id": 182, + "node_id": "MDEwOlJlcG9zaXRvcnkxODI=", + "name": "notabot_test", + "full_name": "ahrefs/notabot_test", + "private": true, + "owner": { + "login": "ahrefs", + "id": 7, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc=", + "avatar_url": "https://git.ahrefs.com/avatars/u/7?", + "gravatar_id": "", + "url": "https://git.ahrefs.com/api/v3/users/ahrefs", + "html_url": "https://git.ahrefs.com/ahrefs", + "followers_url": "https://git.ahrefs.com/api/v3/users/ahrefs/followers", + "following_url": "https://git.ahrefs.com/api/v3/users/ahrefs/following{/other_user}", + "gists_url": "https://git.ahrefs.com/api/v3/users/ahrefs/gists{/gist_id}", + "starred_url": "https://git.ahrefs.com/api/v3/users/ahrefs/starred{/owner}{/repo}", + "subscriptions_url": "https://git.ahrefs.com/api/v3/users/ahrefs/subscriptions", + "organizations_url": "https://git.ahrefs.com/api/v3/users/ahrefs/orgs", + "repos_url": "https://git.ahrefs.com/api/v3/users/ahrefs/repos", + "events_url": "https://git.ahrefs.com/api/v3/users/ahrefs/events{/privacy}", + "received_events_url": "https://git.ahrefs.com/api/v3/users/ahrefs/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://git.ahrefs.com/ahrefs/notabot_test", + "description": null, + "fork": false, + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test", + "forks_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/forks", + "keys_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/keys{/key_id}", + "collaborators_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/collaborators{/collaborator}", + "teams_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/teams", + "hooks_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/hooks", + "issue_events_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/issues/events{/number}", + "events_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/events", + "assignees_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/assignees{/user}", + "branches_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/branches{/branch}", + "tags_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/tags", + "blobs_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/blobs{/sha}", + "git_tags_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/tags{/sha}", + "git_refs_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/refs{/sha}", + "trees_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/trees{/sha}", + "statuses_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/statuses/{sha}", + "languages_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/languages", + "stargazers_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/stargazers", + "contributors_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/contributors", + "subscribers_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/subscribers", + "subscription_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/subscription", + "commits_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits{/sha}", + "git_commits_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/commits{/sha}", + "comments_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/comments{/number}", + "issue_comment_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/issues/comments{/number}", + "contents_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/contents/{+path}", + "compare_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/compare/{base}...{head}", + "merges_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/merges", + "archive_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/{archive_format}{/ref}", + "downloads_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/downloads", + "issues_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/issues{/number}", + "pulls_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/pulls{/number}", + "milestones_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/milestones{/number}", + "notifications_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/notifications{?since,all,participating}", + "labels_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/labels{/name}", + "releases_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/releases{/id}", + "deployments_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/deployments", + "created_at": "2020-06-01T18:44:17Z", + "updated_at": "2020-06-02T03:14:53Z", + "pushed_at": "2020-06-02T03:14:51Z", + "git_url": "git://git.ahrefs.com/ahrefs/notabot_test.git", + "ssh_url": "git@git.ahrefs.com:ahrefs/notabot_test.git", + "clone_url": "https://git.ahrefs.com/ahrefs/notabot_test.git", + "svn_url": "https://git.ahrefs.com/ahrefs/notabot_test", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Shell", + "has_issues": true, + "has_projects": false, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master" + }, + "organization": { + "login": "ahrefs", + "id": 7, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc=", + "url": "https://git.ahrefs.com/api/v3/orgs/ahrefs", + "repos_url": "https://git.ahrefs.com/api/v3/orgs/ahrefs/repos", + "events_url": "https://git.ahrefs.com/api/v3/orgs/ahrefs/events", + "hooks_url": "https://git.ahrefs.com/api/v3/orgs/ahrefs/hooks", + "issues_url": "https://git.ahrefs.com/api/v3/orgs/ahrefs/issues", + "members_url": "https://git.ahrefs.com/api/v3/orgs/ahrefs/members{/member}", + "public_members_url": "https://git.ahrefs.com/api/v3/orgs/ahrefs/public_members{/member}", + "avatar_url": "https://git.ahrefs.com/avatars/u/7?", + "description": null + }, + "enterprise": { + "id": 1, + "slug": "ahrefs-pte-ltd", + "name": "Ahrefs Pte Ltd", + "node_id": "MDEwOkVudGVycHJpc2Ux", + "avatar_url": "https://git.ahrefs.com/avatars/b/1?", + "description": null, + "website_url": null, + "html_url": "https://git.ahrefs.com/enterprises/ahrefs-pte-ltd", + "created_at": "2019-01-09T18:50:55Z", + "updated_at": "2019-03-01T16:07:28Z" + }, + "sender": { + "login": "ip", + "id": 3, + "node_id": "MDQ6VXNlcjM=", + "avatar_url": "https://git.ahrefs.com/avatars/u/3?", + "gravatar_id": "", + "url": "https://git.ahrefs.com/api/v3/users/ip", + "html_url": "https://git.ahrefs.com/ip", + "followers_url": "https://git.ahrefs.com/api/v3/users/ip/followers", + "following_url": "https://git.ahrefs.com/api/v3/users/ip/following{/other_user}", + "gists_url": "https://git.ahrefs.com/api/v3/users/ip/gists{/gist_id}", + "starred_url": "https://git.ahrefs.com/api/v3/users/ip/starred{/owner}{/repo}", + "subscriptions_url": "https://git.ahrefs.com/api/v3/users/ip/subscriptions", + "organizations_url": "https://git.ahrefs.com/api/v3/users/ip/orgs", + "repos_url": "https://git.ahrefs.com/api/v3/users/ip/repos", + "events_url": "https://git.ahrefs.com/api/v3/users/ip/events{/privacy}", + "received_events_url": "https://git.ahrefs.com/api/v3/users/ip/received_events", + "type": "User", + "site_admin": true + } +} diff --git a/mock_states/status.success_test_different_steps_from_prev.json b/mock_states/status.success_test_different_steps_from_prev.json new file mode 100644 index 00000000..97d9c97b --- /dev/null +++ b/mock_states/status.success_test_different_steps_from_prev.json @@ -0,0 +1,17 @@ + +{ + "pipeline_statuses": { + "buildkite/notabot-test": { + "develop": "success" + }, + "buildkite/notabot-test/build-infra": { + "develop": "success" + }, + "buildkite/notabot-test/setup": { + "develop": "success" + }, + "buildkite/notabot-test/build": { + "feature/123": "success" + } + } +} \ No newline at end of file diff --git a/mock_states/status.success_test_not_affected_by_unrelated_success_with_different_steps.json b/mock_states/status.success_test_not_affected_by_unrelated_success_with_different_steps.json new file mode 100644 index 00000000..8b341252 --- /dev/null +++ b/mock_states/status.success_test_not_affected_by_unrelated_success_with_different_steps.json @@ -0,0 +1,17 @@ + +{ + "pipeline_statuses": { + "buildkite/notabot-test": { + "develop": "success" + }, + "buildkite/notabot-test/build-infra": { + "develop": "failure" + }, + "buildkite/notabot-test/setup": { + "develop": "success" + }, + "buildkite/notabot-test/build": { + "develop": "success" + } + } +} \ No newline at end of file diff --git a/test/github-api-cache/71a5b16f3e880a58a4b63201174254c9663faca4 b/test/github-api-cache/71a5b16f3e880a58a4b63201174254c9663faca4 new file mode 100644 index 00000000..844451cf --- /dev/null +++ b/test/github-api-cache/71a5b16f3e880a58a4b63201174254c9663faca4 @@ -0,0 +1,79 @@ +{ + "sha": "0d95302addd66c1816bce1b1d495ed1c93ccd478", + "node_id": "MDY6Q29tbWl0MTgyOjBkOTUzMDJhZGRkNjZjMTgxNmJjZTFiMWQ0OTVlZDFjOTNjY2Q0Nzg=", + "commit": { + "author": { + "name": "Louis Roché", + "email": "louis.roche@ahrefs.com", + "date": "2020-06-02T03:14:51Z" + }, + "committer": { + "name": "GitHub Enterprise", + "email": "git@ahrefs.com", + "date": "2020-06-02T03:14:51Z" + }, + "message": "Update README.md", + "tree": { + "sha": "ee5c539cad37c77348ce7a55756acc542b41cfc7", + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/trees/ee5c539cad37c77348ce7a55756acc542b41cfc7" + }, + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/git/commits/0d95302addd66c1816bce1b1d495ed1c93ccd478", + "comment_count": 0, + "verification": { + "verified": false, + "reason": "unsigned", + "signature": null, + "payload": null + } + }, + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/0d95302addd66c1816bce1b1d495ed1c93ccd478", + "html_url": "https://git.ahrefs.com/ahrefs/notabot_test/commit/0d95302addd66c1816bce1b1d495ed1c93ccd478", + "comments_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/0d95302addd66c1816bce1b1d495ed1c93ccd478/comments", + "author": { + "login": "louis", + "id": 34, + "node_id": "MDQ6VXNlcjM0", + "avatar_url": "https://git.ahrefs.com/avatars/u/34?", + "gravatar_id": "", + "url": "https://git.ahrefs.com/api/v3/users/louis", + "html_url": "https://git.ahrefs.com/louis", + "followers_url": "https://git.ahrefs.com/api/v3/users/louis/followers", + "following_url": "https://git.ahrefs.com/api/v3/users/louis/following{/other_user}", + "gists_url": "https://git.ahrefs.com/api/v3/users/louis/gists{/gist_id}", + "starred_url": "https://git.ahrefs.com/api/v3/users/louis/starred{/owner}{/repo}", + "subscriptions_url": "https://git.ahrefs.com/api/v3/users/louis/subscriptions", + "organizations_url": "https://git.ahrefs.com/api/v3/users/louis/orgs", + "repos_url": "https://git.ahrefs.com/api/v3/users/louis/repos", + "events_url": "https://git.ahrefs.com/api/v3/users/louis/events{/privacy}", + "received_events_url": "https://git.ahrefs.com/api/v3/users/louis/received_events", + "type": "User", + "site_admin": false + }, + "committer": null, + "parents": [ + { + "sha": "04cb72d6dc8d92131282a7eff57f6caf632f0a39", + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/commits/04cb72d6dc8d92131282a7eff57f6caf632f0a39", + "html_url": "https://git.ahrefs.com/ahrefs/notabot_test/commit/04cb72d6dc8d92131282a7eff57f6caf632f0a39" + } + ], + "stats": { + "total": 2, + "additions": 1, + "deletions": 1 + }, + "files": [ + { + "sha": "e7d353f786a2f29d0cf7ed6fdad08ec446c1b9b1", + "filename": "README.md", + "status": "modified", + "additions": 1, + "deletions": 1, + "changes": 2, + "blob_url": "https://git.ahrefs.com/ahrefs/notabot_test/blob/0d95302addd66c1816bce1b1d495ed1c93ccd478/README.md", + "raw_url": "https://git.ahrefs.com/ahrefs/notabot_test/raw/0d95302addd66c1816bce1b1d495ed1c93ccd478/README.md", + "contents_url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/contents/README.md?ref=0d95302addd66c1816bce1b1d495ed1c93ccd478", + "patch": "@@ -1 +1 @@\n-some content\n+some different content" + } + ] +} diff --git a/test/github-api-cache/71a5b16f3e880a58a4b63201174254c9663faca4-statuses b/test/github-api-cache/71a5b16f3e880a58a4b63201174254c9663faca4-statuses new file mode 100644 index 00000000..8a6acf21 --- /dev/null +++ b/test/github-api-cache/71a5b16f3e880a58a4b63201174254c9663faca4-statuses @@ -0,0 +1,162 @@ +[ + { + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/statuses/0d95302addd66c1816bce1b1d495ed1c93ccd478", + "avatar_url": "https://git.ahrefs.com/avatars/oa/6?", + "id": 1447704, + "node_id": "MDEzOlN0YXR1c0NvbnRleHQxNDQ3NzA0", + "state": "success", + "description": "Build #4 passed (12 seconds)", + "target_url": "https://buildkite.com/ahrefs/notabot-test/builds/4", + "context": "buildkite/notabot-test", + "created_at": "2020-06-04T05:55:59Z", + "updated_at": "2020-06-04T05:55:59Z", + "creator": { + "login": "ip", + "id": 3, + "node_id": "MDQ6VXNlcjM=", + "avatar_url": "https://git.ahrefs.com/avatars/u/3?", + "gravatar_id": "", + "url": "https://git.ahrefs.com/api/v3/users/ip", + "html_url": "https://git.ahrefs.com/ip", + "followers_url": "https://git.ahrefs.com/api/v3/users/ip/followers", + "following_url": "https://git.ahrefs.com/api/v3/users/ip/following{/other_user}", + "gists_url": "https://git.ahrefs.com/api/v3/users/ip/gists{/gist_id}", + "starred_url": "https://git.ahrefs.com/api/v3/users/ip/starred{/owner}{/repo}", + "subscriptions_url": "https://git.ahrefs.com/api/v3/users/ip/subscriptions", + "organizations_url": "https://git.ahrefs.com/api/v3/users/ip/orgs", + "repos_url": "https://git.ahrefs.com/api/v3/users/ip/repos", + "events_url": "https://git.ahrefs.com/api/v3/users/ip/events{/privacy}", + "received_events_url": "https://git.ahrefs.com/api/v3/users/ip/received_events", + "type": "User", + "site_admin": true + } + }, + { + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/statuses/0d95302addd66c1816bce1b1d495ed1c93ccd478", + "avatar_url": "https://git.ahrefs.com/avatars/oa/6?", + "id": 1447703, + "node_id": "MDEzOlN0YXR1c0NvbnRleHQxNDQ3NzAz", + "state": "success", + "description": "Passed (1 second)", + "target_url": "https://buildkite.com/ahrefs/notabot-test/builds/4#1e0475c9-d929-4a2d-876f-f49320780a7c", + "context": "buildkite/notabot-test/build", + "created_at": "2020-06-04T05:55:59Z", + "updated_at": "2020-06-04T05:55:59Z", + "creator": { + "login": "ip", + "id": 3, + "node_id": "MDQ6VXNlcjM=", + "avatar_url": "https://git.ahrefs.com/avatars/u/3?", + "gravatar_id": "", + "url": "https://git.ahrefs.com/api/v3/users/ip", + "html_url": "https://git.ahrefs.com/ip", + "followers_url": "https://git.ahrefs.com/api/v3/users/ip/followers", + "following_url": "https://git.ahrefs.com/api/v3/users/ip/following{/other_user}", + "gists_url": "https://git.ahrefs.com/api/v3/users/ip/gists{/gist_id}", + "starred_url": "https://git.ahrefs.com/api/v3/users/ip/starred{/owner}{/repo}", + "subscriptions_url": "https://git.ahrefs.com/api/v3/users/ip/subscriptions", + "organizations_url": "https://git.ahrefs.com/api/v3/users/ip/orgs", + "repos_url": "https://git.ahrefs.com/api/v3/users/ip/repos", + "events_url": "https://git.ahrefs.com/api/v3/users/ip/events{/privacy}", + "received_events_url": "https://git.ahrefs.com/api/v3/users/ip/received_events", + "type": "User", + "site_admin": true + } + }, + { + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/statuses/0d95302addd66c1816bce1b1d495ed1c93ccd478", + "avatar_url": "https://git.ahrefs.com/avatars/oa/6?", + "id": 1447702, + "node_id": "MDEzOlN0YXR1c0NvbnRleHQxNDQ3NzAy", + "state": "pending", + "description": "Started...", + "target_url": "https://buildkite.com/ahrefs/notabot-test/builds/4#1e0475c9-d929-4a2d-876f-f49320780a7c", + "context": "buildkite/notabot-test/build", + "created_at": "2020-06-04T05:55:58Z", + "updated_at": "2020-06-04T05:55:58Z", + "creator": { + "login": "ip", + "id": 3, + "node_id": "MDQ6VXNlcjM=", + "avatar_url": "https://git.ahrefs.com/avatars/u/3?", + "gravatar_id": "", + "url": "https://git.ahrefs.com/api/v3/users/ip", + "html_url": "https://git.ahrefs.com/ip", + "followers_url": "https://git.ahrefs.com/api/v3/users/ip/followers", + "following_url": "https://git.ahrefs.com/api/v3/users/ip/following{/other_user}", + "gists_url": "https://git.ahrefs.com/api/v3/users/ip/gists{/gist_id}", + "starred_url": "https://git.ahrefs.com/api/v3/users/ip/starred{/owner}{/repo}", + "subscriptions_url": "https://git.ahrefs.com/api/v3/users/ip/subscriptions", + "organizations_url": "https://git.ahrefs.com/api/v3/users/ip/orgs", + "repos_url": "https://git.ahrefs.com/api/v3/users/ip/repos", + "events_url": "https://git.ahrefs.com/api/v3/users/ip/events{/privacy}", + "received_events_url": "https://git.ahrefs.com/api/v3/users/ip/received_events", + "type": "User", + "site_admin": true + } + }, + { + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/statuses/0d95302addd66c1816bce1b1d495ed1c93ccd478", + "avatar_url": "https://git.ahrefs.com/avatars/oa/6?", + "id": 1447700, + "node_id": "MDEzOlN0YXR1c0NvbnRleHQxNDQ3NzAw", + "state": "pending", + "description": "Build #4 started", + "target_url": "https://buildkite.com/ahrefs/notabot-test/builds/4", + "context": "buildkite/notabot-test", + "created_at": "2020-06-04T05:55:48Z", + "updated_at": "2020-06-04T05:55:48Z", + "creator": { + "login": "ip", + "id": 3, + "node_id": "MDQ6VXNlcjM=", + "avatar_url": "https://git.ahrefs.com/avatars/u/3?", + "gravatar_id": "", + "url": "https://git.ahrefs.com/api/v3/users/ip", + "html_url": "https://git.ahrefs.com/ip", + "followers_url": "https://git.ahrefs.com/api/v3/users/ip/followers", + "following_url": "https://git.ahrefs.com/api/v3/users/ip/following{/other_user}", + "gists_url": "https://git.ahrefs.com/api/v3/users/ip/gists{/gist_id}", + "starred_url": "https://git.ahrefs.com/api/v3/users/ip/starred{/owner}{/repo}", + "subscriptions_url": "https://git.ahrefs.com/api/v3/users/ip/subscriptions", + "organizations_url": "https://git.ahrefs.com/api/v3/users/ip/orgs", + "repos_url": "https://git.ahrefs.com/api/v3/users/ip/repos", + "events_url": "https://git.ahrefs.com/api/v3/users/ip/events{/privacy}", + "received_events_url": "https://git.ahrefs.com/api/v3/users/ip/received_events", + "type": "User", + "site_admin": true + } + }, + { + "url": "https://git.ahrefs.com/api/v3/repos/ahrefs/notabot_test/statuses/0d95302addd66c1816bce1b1d495ed1c93ccd478", + "avatar_url": "https://git.ahrefs.com/avatars/oa/6?", + "id": 1447698, + "node_id": "MDEzOlN0YXR1c0NvbnRleHQxNDQ3Njk4", + "state": "pending", + "description": "Build #4 scheduled", + "target_url": "https://buildkite.com/ahrefs/notabot-test/builds/4", + "context": "buildkite/notabot-test", + "created_at": "2020-06-04T05:55:43Z", + "updated_at": "2020-06-04T05:55:43Z", + "creator": { + "login": "ip", + "id": 3, + "node_id": "MDQ6VXNlcjM=", + "avatar_url": "https://git.ahrefs.com/avatars/u/3?", + "gravatar_id": "", + "url": "https://git.ahrefs.com/api/v3/users/ip", + "html_url": "https://git.ahrefs.com/ip", + "followers_url": "https://git.ahrefs.com/api/v3/users/ip/followers", + "following_url": "https://git.ahrefs.com/api/v3/users/ip/following{/other_user}", + "gists_url": "https://git.ahrefs.com/api/v3/users/ip/gists{/gist_id}", + "starred_url": "https://git.ahrefs.com/api/v3/users/ip/starred{/owner}{/repo}", + "subscriptions_url": "https://git.ahrefs.com/api/v3/users/ip/subscriptions", + "organizations_url": "https://git.ahrefs.com/api/v3/users/ip/orgs", + "repos_url": "https://git.ahrefs.com/api/v3/users/ip/repos", + "events_url": "https://git.ahrefs.com/api/v3/users/ip/events{/privacy}", + "received_events_url": "https://git.ahrefs.com/api/v3/users/ip/received_events", + "type": "User", + "site_admin": true + } + } +] \ No newline at end of file diff --git a/test/slack_payloads.expected b/test/slack_payloads.expected index fbcdd809..33d765da 100644 --- a/test/slack_payloads.expected +++ b/test/slack_payloads.expected @@ -538,6 +538,28 @@ will notify #default } ] } +===== file ../mock_payloads/status.success_test_different_steps_from_prev.json ===== +will notify #all-push-events +{ + "channel": "all-push-events", + "attachments": [ + { + "fallback": + " CI Build Status notification for : success", + "mrkdwn_in": [ "fields", "text" ], + "color": "good", + "pretext": + " CI Build Status notification for : success", + "text": "*Description*: Build #4 passed (5 minutes, 19 seconds).", + "fields": [ + { + "value": + "*Commit*: `` Update README.md - louis\n*Branch*: develop" + } + ] + } + ] +} ===== file ../mock_payloads/status.success_test_main_branch.json ===== will notify #all-push-events { @@ -582,3 +604,25 @@ will notify #default } ] } +===== file ../mock_payloads/status.success_test_not_affected_by_unrelated_success_with_different_steps.json ===== +will notify #all-push-events +{ + "channel": "all-push-events", + "attachments": [ + { + "fallback": + " CI Build Status notification for : success", + "mrkdwn_in": [ "fields", "text" ], + "color": "good", + "pretext": + " CI Build Status notification for : success", + "text": "*Description*: Build #2 passed (5 minutes, 19 seconds).", + "fields": [ + { + "value": + "*Commit*: `` Update README.md - louis\n*Branch*: develop" + } + ] + } + ] +}