Add CLI tests #22

Merged
torjus merged 6 commits from cli-tests into master 2025-01-06 22:25:16 +00:00
7 changed files with 48658 additions and 11 deletions
Showing only changes of commit 1894b809a8 - Show all commits

View File

@ -9,8 +9,9 @@ from nixprstatus.output import OutputFormat
DEFAULT_HEADERS = { DEFAULT_HEADERS = {
"Accept": "application/vnd.github.text+json", "Accept": "application/vnd.github.text+json",
} }
DEFAULT_BRANCHES = ["master", "nixos-unstable-small", "nixos-unstable", "nixos-24.05"] DEFAULT_BRANCHES = ["master", "nixos-unstable-small", "nixos-unstable", "nixos-24.11"]
BACKPORT_LABEL = "backport release-24.05" STABLE_BRANCH = "nixos-24.11"
BACKPORT_LABEL = "backport release-24.11"
class PRStatus(BaseModel): class PRStatus(BaseModel):
@ -110,7 +111,7 @@ def pr_merge_status(
in_branch = commit_in_branch(commit_sha, branch) in_branch = commit_in_branch(commit_sha, branch)
results[branch] = in_branch results[branch] = in_branch
if check_backport and has_backport_label and "nixos-24.05" in branches: if check_backport and has_backport_label and STABLE_BRANCH in branches:
# Check comments for message about backport # Check comments for message about backport
comment_url = f"https://api.github.com/repos/NixOS/nixpkgs/issues/{pr}/comments" comment_url = f"https://api.github.com/repos/NixOS/nixpkgs/issues/{pr}/comments"
comment_response = requests.get(comment_url, headers=DEFAULT_HEADERS) comment_response = requests.get(comment_url, headers=DEFAULT_HEADERS)
@ -128,12 +129,12 @@ def pr_merge_status(
backport_response = requests.get(backport_url, headers=DEFAULT_HEADERS) backport_response = requests.get(backport_url, headers=DEFAULT_HEADERS)
backport_sha = backport_response.json().get("merge_commit_sha") backport_sha = backport_response.json().get("merge_commit_sha")
if backport_sha is None: if backport_sha is None:
results[f"nixos-24.05 (#{backport_pr})"] = False results[f"{STABLE_BRANCH} (#{backport_pr})"] = False
return PRStatus(title=title, merged=True, branches=results) return PRStatus(title=title, merged=True, branches=results)
results.pop("nixos-24.05") results.pop(STABLE_BRANCH)
results[f"nixos-24.05 (#{backport_pr})"] = commit_in_branch( results[f"{STABLE_BRANCH} (#{backport_pr})"] = commit_in_branch(
backport_sha, "nixos-24.05" backport_sha, STABLE_BRANCH
) )
return PRStatus(title=title, merged=True, branches=results) return PRStatus(title=title, merged=True, branches=results)

View File

@ -0,0 +1,186 @@
{
"url": "https://api.github.com/repos/NixOS/nixpkgs/compare/nixos-24.05...1e6376619b9192dc7603e07d7187572c45048dd7",
"html_url": "https://github.com/NixOS/nixpkgs/compare/nixos-24.05...1e6376619b9192dc7603e07d7187572c45048dd7",
"permalink_url": "https://github.com/NixOS/nixpkgs/compare/NixOS:ecbc1ca...NixOS:1e63766",
"diff_url": "https://github.com/NixOS/nixpkgs/compare/nixos-24.05...1e6376619b9192dc7603e07d7187572c45048dd7.diff",
"patch_url": "https://github.com/NixOS/nixpkgs/compare/nixos-24.05...1e6376619b9192dc7603e07d7187572c45048dd7.patch",
"base_commit": {
"sha": "ecbc1ca8ffd6aea8372ad16be9ebbb39889e55b6",
"node_id": "C_kwDOAEVQ_NoAKGVjYmMxY2E4ZmZkNmFlYTgzNzJhZDE2YmU5ZWJiYjM5ODg5ZTU1YjY",
"commit": {
"author": {
"name": "OTABI Tomoya",
"email": "tomoya.otabi@gmail.com",
"date": "2024-10-06T05:47:56Z"
},
"committer": {
"name": "GitHub",
"email": "noreply@github.com",
"date": "2024-10-06T05:47:56Z"
},
"message": "[Backport release-24.05] brave: 1.70.119 -> 1.70.123 (#346428)",
"tree": {
"sha": "f0b5ae7d234fd6c2d86f5603b4522f2ba74eda5b",
"url": "https://api.github.com/repos/NixOS/nixpkgs/git/trees/f0b5ae7d234fd6c2d86f5603b4522f2ba74eda5b"
},
"url": "https://api.github.com/repos/NixOS/nixpkgs/git/commits/ecbc1ca8ffd6aea8372ad16be9ebbb39889e55b6",
"comment_count": 0,
"verification": {
"verified": true,
"reason": "valid",
"signature": "-----BEGIN PGP SIGNATURE-----\n\nwsFcBAABCAAQBQJnAiSMCRC1aQ7uu5UhlAAA0TYQAKRPy/FYu1l+CaEVlEayD+7E\ngFboJbXErmlX5/5lmwW/J3VQb2t3wlhlP5R82Utb66Gucy49vSbKcWAC3DgAT0fG\n2UOozKXq6bAJ+tzBPX/lFNNJHYmTFN3uGifkP+cHZdh7CE0EHH8IFE7rWOfYSMpK\n7Syjl1DsJ72j6ZNdWB3c1J4jCnGQKJRtgJI5yw7feqt6MYVUNLIENuo/RZHZtEF8\nCLZwx9a950pXPLUAH3HyTnoV76H9wC2ahWGUq3Mum/Cdf3WqPi0nuw+rqtjQvvCh\nK1cuS/wOlSTPqVt9S1U4GgUIdE1u82o2Zkxm/b8hOAxBNNg7nCf8RYyITL3gkubc\nIM4UgiOxL/ybpsYmNZ7zzpi8z1N28SrbGlfVG0Zp/7asniKCe/uJoXTQlxR+2GsN\nTld9B272Ttvrnyfokb05+DbTqEPV7NEG7HzXRIKcIYvcP0QdFFYch893n/t1fbFP\niOyqV3FJB68Dcjsr35zqQBPMcGNUtoo2hQFbmCZV3xYWKRfgUD6RnP+oFyIqrw5s\ne1WBwaiAbVnlCACkugGSXNF8s563cHauQkJi7553o75hqXsE8ezHCW12C4OUAQM8\nIspE3A8C/yC137IdAz3L/CpG6Qdp11AZQ1EG0oO0v7TtxQQHR3cBEUTO1vknG5iV\nuWuPBHuc5atQWRe2eVco\n=gGAX\n-----END PGP SIGNATURE-----\n",
"payload": "tree f0b5ae7d234fd6c2d86f5603b4522f2ba74eda5b\nparent 17ae88b569bb15590549ff478bab6494dde4a907\nparent d4eb7924598b8bd830e85c93aeb6aa7c5294de9a\nauthor OTABI Tomoya <tomoya.otabi@gmail.com> 1728193676 +0900\ncommitter GitHub <noreply@github.com> 1728193676 +0900\n\n[Backport release-24.05] brave: 1.70.119 -> 1.70.123 (#346428)\n\n"
}
},
"url": "https://api.github.com/repos/NixOS/nixpkgs/commits/ecbc1ca8ffd6aea8372ad16be9ebbb39889e55b6",
"html_url": "https://github.com/NixOS/nixpkgs/commit/ecbc1ca8ffd6aea8372ad16be9ebbb39889e55b6",
"comments_url": "https://api.github.com/repos/NixOS/nixpkgs/commits/ecbc1ca8ffd6aea8372ad16be9ebbb39889e55b6/comments",
"author": {
"login": "natsukium",
"id": 25083790,
"node_id": "MDQ6VXNlcjI1MDgzNzkw",
"avatar_url": "https://avatars.githubusercontent.com/u/25083790?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/natsukium",
"html_url": "https://github.com/natsukium",
"followers_url": "https://api.github.com/users/natsukium/followers",
"following_url": "https://api.github.com/users/natsukium/following{/other_user}",
"gists_url": "https://api.github.com/users/natsukium/gists{/gist_id}",
"starred_url": "https://api.github.com/users/natsukium/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/natsukium/subscriptions",
"organizations_url": "https://api.github.com/users/natsukium/orgs",
"repos_url": "https://api.github.com/users/natsukium/repos",
"events_url": "https://api.github.com/users/natsukium/events{/privacy}",
"received_events_url": "https://api.github.com/users/natsukium/received_events",
"type": "User",
"site_admin": false
},
"committer": {
"login": "web-flow",
"id": 19864447,
"node_id": "MDQ6VXNlcjE5ODY0NDQ3",
"avatar_url": "https://avatars.githubusercontent.com/u/19864447?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/web-flow",
"html_url": "https://github.com/web-flow",
"followers_url": "https://api.github.com/users/web-flow/followers",
"following_url": "https://api.github.com/users/web-flow/following{/other_user}",
"gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}",
"starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/web-flow/subscriptions",
"organizations_url": "https://api.github.com/users/web-flow/orgs",
"repos_url": "https://api.github.com/users/web-flow/repos",
"events_url": "https://api.github.com/users/web-flow/events{/privacy}",
"received_events_url": "https://api.github.com/users/web-flow/received_events",
"type": "User",
"site_admin": false
},
"parents": [
{
"sha": "17ae88b569bb15590549ff478bab6494dde4a907",
"url": "https://api.github.com/repos/NixOS/nixpkgs/commits/17ae88b569bb15590549ff478bab6494dde4a907",
"html_url": "https://github.com/NixOS/nixpkgs/commit/17ae88b569bb15590549ff478bab6494dde4a907"
},
{
"sha": "d4eb7924598b8bd830e85c93aeb6aa7c5294de9a",
"url": "https://api.github.com/repos/NixOS/nixpkgs/commits/d4eb7924598b8bd830e85c93aeb6aa7c5294de9a",
"html_url": "https://github.com/NixOS/nixpkgs/commit/d4eb7924598b8bd830e85c93aeb6aa7c5294de9a"
}
]
},
"merge_base_commit": {
"sha": "1e6376619b9192dc7603e07d7187572c45048dd7",
"node_id": "C_kwDOAEVQ_NoAKDFlNjM3NjYxOWI5MTkyZGM3NjAzZTA3ZDcxODc1NzJjNDUwNDhkZDc",
"commit": {
"author": {
"name": "Martin Weinelt",
"email": "mweinelt@users.noreply.github.com",
"date": "2024-10-04T00:25:13Z"
},
"committer": {
"name": "GitHub",
"email": "noreply@github.com",
"date": "2024-10-04T00:25:13Z"
},
"message": "[Backport release-24.05] Firefox: 130.0.1 -> 131.0; 128.2.0esr -> 128.3.0esr; 115.15.0esr -> 115.16.0esr (#346022)",
"tree": {
"sha": "ca267bfaced108f8b846f36b4222f50bcbea132e",
"url": "https://api.github.com/repos/NixOS/nixpkgs/git/trees/ca267bfaced108f8b846f36b4222f50bcbea132e"
},
"url": "https://api.github.com/repos/NixOS/nixpkgs/git/commits/1e6376619b9192dc7603e07d7187572c45048dd7",
"comment_count": 0,
"verification": {
"verified": true,
"reason": "valid",
"signature": "-----BEGIN PGP SIGNATURE-----\n\nwsFcBAABCAAQBQJm/zXpCRC1aQ7uu5UhlAAAwfYQAKQ+YS049CLiRZX5L6663sip\nQ0lB49M6NgX6cx/uzDP2wkNdPZ+Ft/76Fngki9B3UBvJsdfgYsWMZ0L8lNCJPV5v\n65FCH0yzbwHz2gCgE2dTPMbd1qQGFaO1rSqksmLlovoA5NTHLrkoN7PEdNt97YQm\nvsJKHNAMzBgwmdom7OyxcBQfAmvNT4nijFqDW0AJ8VzS72EYW2il0S/uVzK2EE0k\nZdVX+oK2pYYYwaWchPofOalDLgXY5dteqNU7cQRdSI1saxoFbXVyLqo2N/lSm4/b\nv9+Uwwycjl7FyRCwucWXVBuMbbDsJW68xHSg060HbxBUEL3os8CleTiRWcXVa64d\nc619UC4/PQM+7pQFhOvATVBX+jWe508PQX5RCWIzQJWoOu+xcBbNeSImstM6jFWB\nDhKRYGM56+nPH+WRliTK6w07KAOhYMFDRAGHbUm3x5L03oqXowVjYx9UfdFBeNqW\noeETR77F6zfH/lBcW68JQMWM4ZG/sCo4HM81DY4vR99EPNKOPKNycjmV2Jb3WHRN\nO1DSmEeiCt7lgeuGmvIOXA5Z+QvAEGv8ZWRZ/K276GuK9kePh6xbu0ntAXRvy5iw\n/f426Ikzy7UM/yEL7458jrhyyqHlxiOXm+B+TSwbNSjLXHJdH5Ap3seIQjdo+num\nTWeoCrlH/oi+Tv83Iiye\n=G4zI\n-----END PGP SIGNATURE-----\n",
"payload": "tree ca267bfaced108f8b846f36b4222f50bcbea132e\nparent 0799dfba72420acad00f6c6b643e42f14589da6f\nparent 0010c39a77012492a1602258ad8e3fd5e9377bf6\nauthor Martin Weinelt <mweinelt@users.noreply.github.com> 1728001513 +0200\ncommitter GitHub <noreply@github.com> 1728001513 +0200\n\n[Backport release-24.05] Firefox: 130.0.1 -> 131.0; 128.2.0esr -> 128.3.0esr; 115.15.0esr -> 115.16.0esr (#346022)\n\n"
}
},
"url": "https://api.github.com/repos/NixOS/nixpkgs/commits/1e6376619b9192dc7603e07d7187572c45048dd7",
"html_url": "https://github.com/NixOS/nixpkgs/commit/1e6376619b9192dc7603e07d7187572c45048dd7",
"comments_url": "https://api.github.com/repos/NixOS/nixpkgs/commits/1e6376619b9192dc7603e07d7187572c45048dd7/comments",
"author": {
"login": "mweinelt",
"id": 131599,
"node_id": "MDQ6VXNlcjEzMTU5OQ==",
"avatar_url": "https://avatars.githubusercontent.com/u/131599?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/mweinelt",
"html_url": "https://github.com/mweinelt",
"followers_url": "https://api.github.com/users/mweinelt/followers",
"following_url": "https://api.github.com/users/mweinelt/following{/other_user}",
"gists_url": "https://api.github.com/users/mweinelt/gists{/gist_id}",
"starred_url": "https://api.github.com/users/mweinelt/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/mweinelt/subscriptions",
"organizations_url": "https://api.github.com/users/mweinelt/orgs",
"repos_url": "https://api.github.com/users/mweinelt/repos",
"events_url": "https://api.github.com/users/mweinelt/events{/privacy}",
"received_events_url": "https://api.github.com/users/mweinelt/received_events",
"type": "User",
"site_admin": false
},
"committer": {
"login": "web-flow",
"id": 19864447,
"node_id": "MDQ6VXNlcjE5ODY0NDQ3",
"avatar_url": "https://avatars.githubusercontent.com/u/19864447?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/web-flow",
"html_url": "https://github.com/web-flow",
"followers_url": "https://api.github.com/users/web-flow/followers",
"following_url": "https://api.github.com/users/web-flow/following{/other_user}",
"gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}",
"starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/web-flow/subscriptions",
"organizations_url": "https://api.github.com/users/web-flow/orgs",
"repos_url": "https://api.github.com/users/web-flow/repos",
"events_url": "https://api.github.com/users/web-flow/events{/privacy}",
"received_events_url": "https://api.github.com/users/web-flow/received_events",
"type": "User",
"site_admin": false
},
"parents": [
{
"sha": "0799dfba72420acad00f6c6b643e42f14589da6f",
"url": "https://api.github.com/repos/NixOS/nixpkgs/commits/0799dfba72420acad00f6c6b643e42f14589da6f",
"html_url": "https://github.com/NixOS/nixpkgs/commit/0799dfba72420acad00f6c6b643e42f14589da6f"
},
{
"sha": "0010c39a77012492a1602258ad8e3fd5e9377bf6",
"url": "https://api.github.com/repos/NixOS/nixpkgs/commits/0010c39a77012492a1602258ad8e3fd5e9377bf6",
"html_url": "https://github.com/NixOS/nixpkgs/commit/0010c39a77012492a1602258ad8e3fd5e9377bf6"
}
]
},
"status": "behind",
"ahead_by": 0,
"behind_by": 68,
"total_commits": 0,
"commits": [
],
"files": [
]
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -106,7 +106,7 @@
"id": 6984924132, "id": 6984924132,
"node_id": "LA_kwDOAEVQ_M8AAAABoFV75A", "node_id": "LA_kwDOAEVQ_M8AAAABoFV75A",
"url": "https://api.github.com/repos/NixOS/nixpkgs/labels/backport%20release-24.05", "url": "https://api.github.com/repos/NixOS/nixpkgs/labels/backport%20release-24.05",
"name": "backport release-24.05", "name": "backport release-24.11",
"color": "0fafaa", "color": "0fafaa",
"default": false, "default": false,
"description": "Backport PR automatically" "description": "Backport PR automatically"

View File

@ -46,7 +46,7 @@ class TestCli(unittest.TestCase):
"master": True, "master": True,
"nixos-unstable-small": True, "nixos-unstable-small": True,
"nixos-unstable": True, "nixos-unstable": True,
"nixos-24.05 (#346022)": True, "nixos-24.11": False,
}, },
} }
output = json.loads(result.output) output = json.loads(result.output)

View File

@ -20,11 +20,11 @@ class TestPRMergeStatus(unittest.TestCase):
@unittest.mock.patch("requests.get", side_effect=mocked_requests_get) @unittest.mock.patch("requests.get", side_effect=mocked_requests_get)
def test_pr_merge_status_backport_345769(self, mock_get): def test_pr_merge_status_backport_345769(self, mock_get):
pr = 345769 pr = 345769
branches = ["nixos-24.05"] branches = ["nixos-24.11"]
res = pr_merge_status(pr, branches, check_backport=True) res = pr_merge_status(pr, branches, check_backport=True)
self.assertTrue(res.merged) self.assertTrue(res.merged)
self.assertTrue(res.branches["nixos-24.05 (#346022)"]) self.assertTrue(res.branches["nixos-24.11 (#346022)"])
@unittest.mock.patch("requests.get", side_effect=mocked_requests_get) @unittest.mock.patch("requests.get", side_effect=mocked_requests_get)
def test_pr_merge_status_title_345769(self, mock_get): def test_pr_merge_status_title_345769(self, mock_get):