Class: Fbe::FakeOctokit
- Inherits:
-
Object
- Object
- Fbe::FakeOctokit
- Defined in:
- lib/fbe/octo.rb
Overview
All methods return static or pseudo-random data
No actual API calls are made
Fake GitHub client for testing purposes.
This class provides mock implementations of Octokit methods for testing. It returns predictable, deterministic data structures that mimic GitHub API responses without making actual API calls. The mock data uses consistent patterns:
-
IDs are generated from string names using character code sums
-
Timestamps are random but within recent past
-
Repository and user data follows GitHub’s JSON structure
Instance Method Summary collapse
-
#accept_repository_invitation(id) ⇒ Boolean
Accepts a repository invitation.
- #add_comment(_repo, _issue, _text) ⇒ Object
- #check_runs_for_ref(repo, sha) ⇒ Object
- #commit(_repo, sha) ⇒ Object
-
#commit_pulls(repo, _sha) ⇒ Array<Hash>
Lists pull requests associated with a commit.
- #commits_since(repo, _since) ⇒ Object
- #compare(_repo, _start, _end) ⇒ Object
- #contributors(_repo, _anon = nil, _options = {}) ⇒ Object
- #create_commit_comment(_repo, sha, text) ⇒ Object
-
#issue(repo, number) ⇒ Hash
Gets a single issue.
- #issue_comment_reactions(_name, _comment) ⇒ Object
- #issue_comments(_name, _number) ⇒ Object
- #issue_events(_repo, _number) ⇒ Object
- #issue_timeline(_repo, _issue, _options = {}) ⇒ Object
-
#list_issues(repo, _options = {}) ⇒ Array<Hash>
Lists issues for a repository.
-
#name_to_number(name) ⇒ Integer, String
Converts a string name to a deterministic integer.
-
#organization_memberships(_options = {}) ⇒ Array<Hash>
Gets organization memberships for the authenticated user.
-
#pull_request(repo, number) ⇒ Hash
Gets a single pull request.
- #pull_request_comments(_name, _number) ⇒ Object
- #pull_request_review_comment_reactions(_name, _comment) ⇒ Object
- #pull_request_reviews(_repo, _number) ⇒ Object
-
#pull_requests(_repo, _options = {}) ⇒ Array<Hash>
Lists pull requests for a repository.
-
#random_time ⇒ Time
Generates a random time in the past.
-
#rate_limit ⇒ Object
(also: #rate_limit!)
Returns a mock rate limit object.
-
#release(_url) ⇒ Hash
Gets a single release.
-
#releases(_repo, _opts = {}) ⇒ Array<Hash>
Lists releases for a repository.
-
#remove_organization_membership(_org, _user = nil) ⇒ Boolean
Removes a user from an organization.
-
#repositories(_user = nil) ⇒ Array<Hash>
Lists repositories for a user or organization.
-
#repository(name) ⇒ Hash
Gets repository information.
- #repository_events(repo, _options = {}) ⇒ Object
-
#repository_workflow_runs(repo, _opts = {}) ⇒ Hash
Gets workflow runs for a repository.
- #review_comments(_repo, _number) ⇒ Object
- #search_commits(_query, _options = {}) ⇒ Object
- #search_issues(query, _options = {}) ⇒ Object
-
#star(_repo) ⇒ Boolean
Gives a star to a repository.
- #tree(_repo, _tree_sha, _options = {}) ⇒ Object
-
#update_organization_membership(org, _options = {}) ⇒ Hash
Updates the authenticated user’s organization membership.
-
#user(uid) ⇒ Hash
Gets details of a GitHub user.
-
#user_repository_invitations(_options = {}) ⇒ Array<Hash>
Gets repository invitations for the authenticated user.
- #workflow_run(repo, id) ⇒ Object
- #workflow_run_job(_repo, job) ⇒ Object
-
#workflow_run_usage(_repo, _id) ⇒ Hash
Gets usage information for a specific workflow run.
Instance Method Details
#accept_repository_invitation(id) ⇒ Boolean
Accepts a repository invitation.
rubocop:disable Naming/PredicateMethod
458 459 460 461 |
# File 'lib/fbe/octo.rb', line 458 def accept_repository_invitation(id) raise Octokit::NotFound if id == 404_000 true end |
#add_comment(_repo, _issue, _text) ⇒ Object
857 858 859 860 861 |
# File 'lib/fbe/octo.rb', line 857 def add_comment(_repo, _issue, _text) { id: 42 } end |
#check_runs_for_ref(repo, sha) ⇒ Object
1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 |
# File 'lib/fbe/octo.rb', line 1443 def check_runs_for_ref(repo, sha) data = { 'zerocracy/baza' => { total_count: 7, check_runs: [ { id: 28_907_016_501, name: 'make', head_sha: sha, started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z', app: { slug: 'github-actions' } }, { id: 28_906_596_603, name: 'copyrights', head_sha: sha, started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z', app: { slug: 'github-actions' } }, { id: 28_906_596_550, name: 'markdown-lint', head_sha: sha, started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z', app: { slug: 'github-actions' } }, { id: 28_906_596_483, name: 'pdd', head_sha: sha, started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z', app: { slug: 'github-actions' } }, { id: 28_906_596_433, name: 'rake', head_sha: sha, started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z', app: { slug: 'github-actions' } }, { id: 28_906_596_405, name: 'shellcheck', head_sha: sha, started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z', app: { slug: 'github-actions' } }, { id: 28_906_596_379, name: 'yamllint', head_sha: sha, started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z', app: { slug: 'github-actions' } } ] }, 'zerocracy/judges-action' => { total_count: 7, check_runs: [ { id: 28_907_016_501, name: 'Codacy Static Code Analysis', head_sha: sha, started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z', app: { slug: 'codacy-production' } }, { id: 28_906_596_603, name: 'copyrights', head_sha: sha, started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z', app: { slug: 'github-actions' } }, { id: 28_906_596_550, name: 'markdown-lint', head_sha: sha, started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z', app: { slug: 'github-actions' } }, { id: 28_906_596_483, name: 'pdd', head_sha: sha, started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z', app: { slug: 'github-actions' } }, { id: 28_906_596_433, name: 'rake', head_sha: sha, started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z', app: { slug: 'github-actions' } }, { id: 28_906_596_405, name: 'shellcheck', head_sha: sha, started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z', app: { slug: 'github-actions' } }, { id: 28_906_596_379, name: 'yamllint', head_sha: sha, started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z', app: { slug: 'github-actions' } } ] } } data.fetch(repo) do { total_count: 0, check_runs: [] } end end |
#commit(_repo, sha) ⇒ Object
947 948 949 950 951 952 953 954 |
# File 'lib/fbe/octo.rb', line 947 def commit(_repo, sha) { sha:, stats: { total: 123 } } end |
#commit_pulls(repo, _sha) ⇒ Array<Hash>
Lists pull requests associated with a commit.
632 633 634 635 636 |
# File 'lib/fbe/octo.rb', line 632 def commit_pulls(repo, _sha) [ pull_request(repo, 42) ] end |
#commits_since(repo, _since) ⇒ Object
940 941 942 943 944 945 |
# File 'lib/fbe/octo.rb', line 940 def commits_since(repo, _since) [ commit(repo, 'a1b2c3d4e5f6a1b2c3d4e5f6'), commit(repo, 'a1b2c3d4e5fff1b2c3d4e5f6') ] end |
#compare(_repo, _start, _end) ⇒ Object
1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 |
# File 'lib/fbe/octo.rb', line 1740 def compare(_repo, _start, _end) { base_commit: { sha: '498464613c0b9', commit: { author: { name: 'Yegor Bugayenko', email: '[email protected]', date: Time.parse('2024-09-04 15:23:25 UTC') }, committer: { name: 'Yegor Bugayenko', email: '[email protected]', date: Time.parse('2024-09-04 15:23:25 UTC') }, message: 'Some text', tree: { sha: '51aee236ba884' }, comment_count: 0, verification: { verified: false, reason: 'unsigned', signature: nil, payload: nil } }, author: { login: 'yegor256', id: 526_301, type: 'User', site_admin: false }, committer: { login: 'yegor256', id: 526_301, type: 'User', site_admin: false }, parents: [{ sha: '9763dab47b50a12f59c3630690ec2c0f6bdda0b3' }] }, merge_base_commit: { sha: '8e4348746638595a7e', commit: { author: { name: 'Yegor Bugayenko', email: '[email protected]', date: Time.parse('2024-08-25 15:57:35 UTC') }, committer: { name: 'Yegor Bugayenko', email: '[email protected]', date: Time.parse('2024-08-25 15:57:35 UTC') }, message: 'Some text', tree: { sha: '7145fc122e70bf51e1d' }, comment_count: 0, verification: { verified: true, reason: 'valid', signature: '', payload: '' } }, author: { login: 'yegor256', id: 526_301, type: 'User', site_admin: false }, committer: { login: 'yegor256', id: 526_301, type: 'User', site_admin: false }, parents: [ { sha: '8c8278efedbd795e70' }, { sha: '7dfd2e0186113f66f' } ] }, status: 'diverged', ahead_by: 1, behind_by: 30, total_commits: 1, commits: [ { sha: 'ee04386901692abb', commit: { author: { name: 'Yegor Bugayenko', email: '[email protected]', date: Time.parse('2024-08-25 15:57:35 UTC') }, committer: { name: 'Yegor Bugayenko', email: '[email protected]', date: Time.parse('2024-08-25 15:57:35 UTC') }, message: 'Some text', tree: { sha: '7a6124a500aed8c92' }, comment_count: 0, verification: { verified: false, reason: 'unsigned', signature: nil, payload: nil } }, author: { login: 'yegor256', id: 526_301, type: 'User', site_admin: false }, committer: { login: 'yegor256', id: 526_301, type: 'User', site_admin: false }, parents: [{ sha: '8e4348746638595a7e' }] } ], files: [ { sha: '9e100c7246c0cc9', filename: 'file.txt', status: 'modified', additions: 1, deletions: 1, changes: 2, patch: '@@ -24,7 +24,7 @@ text ...' }, { sha: 'f97818271059e5455', filename: 'file2.txt', status: 'modified', additions: 1, deletions: 1, changes: 2, patch: '@@ -25,7 +25,7 @@ text ...' }, { sha: '5a957c57d090bfeccb', filename: 'file3.txt', status: 'modified', additions: 1, deletions: 1, changes: 2, patch: '@@ -27,7 +27,7 @@ text ...' } ] } end |
#contributors(_repo, _anon = nil, _options = {}) ⇒ Object
1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 |
# File 'lib/fbe/octo.rb', line 1895 def contributors(_repo, _anon = nil, = {}) [ { login: 'yegor256', id: 526_301, type: 'User', contributions: 500 }, { login: 'renovate[bot]', id: 29_139_614, type: 'Bot', contributions: 320 }, { login: 'user1', id: 2_476_362, type: 'User', contributions: 120 }, { login: 'rultor', id: 8_086_956, type: 'Bot', contributions: 87 }, { login: 'user2', id: 5_427_638, type: 'User', contributions: 49 }, { login: 'user3', id: 2_648_875, type: 'User', contributions: 10 }, { login: 'user4', id: 7_125_293, type: 'User', contributions: 1 } ] end |
#create_commit_comment(_repo, sha, text) ⇒ Object
863 864 865 866 867 868 869 870 871 872 |
# File 'lib/fbe/octo.rb', line 863 def create_commit_comment(_repo, sha, text) { commit_id: sha, id: 42, body: text, path: 'something.txt', line: 1, position: 1 } end |
#issue(repo, number) ⇒ Hash
Gets a single issue.
661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 |
# File 'lib/fbe/octo.rb', line 661 def issue(repo, number) if number == 142 { id: 655, number:, repo: { full_name: repo }, user: { login: 'yegor256', id: 526_301, type: 'User' }, created_at: Time.parse('2025-06-01 12:00:55 UTC'), updated_at: Time.parse('2025-06-01 15:47:18 UTC'), closed_at: Time.parse('2025-06-02 15:00:00 UTC'), closed_by: { id: 526_301, login: 'yegor256' } } elsif number == 143 { id: 656, number:, repo: { full_name: repo }, user: { login: 'yegor256', id: 526_301, type: 'User' }, pull_request: { merged_at: nil }, created_at: Time.parse('2025-05-29 17:00:55 UTC'), updated_at: Time.parse('2025-05-29 19:00:00 UTC'), closed_at: Time.parse('2025-06-01 18:20:00 UTC'), closed_by: { id: 526_301, login: 'yegor256' } } else { id: 42, number:, repo: { full_name: repo }, pull_request: { merged_at: nil }, created_at: Time.parse('2024-09-20 19:00:00 UTC') } end end |
#issue_comment_reactions(_name, _comment) ⇒ Object
1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 |
# File 'lib/fbe/octo.rb', line 1417 def issue_comment_reactions(_name, _comment) [ { id: 248_923_574, user: { login: 'user', id: 8_086_956 }, content: 'heart' } ] end |
#issue_comments(_name, _number) ⇒ Object
1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 |
# File 'lib/fbe/octo.rb', line 1357 def issue_comments(_name, _number) [ { pull_request_review_id: 2_227_372_510, id: 1_709_082_320, path: 'test/baza/test_locks.rb', commit_id: 'a9f5f94cf28f29a64d5dd96d0ee23b4174572847', original_commit_id: 'e8c6f94274d14ed3cb26fe71467a9c3f229df59c', user: { login: 'Reviewer', id: 2_566_462 }, body: 'reviewer comment', created_at: '2024-08-08T09:41:46Z', updated_at: '2024-08-08T09:42:46Z', reactions: { url: 'https://api.github.com/repos/zerocracy/baza/pulls/comments/1709082320/reactions', total_count: 1 }, start_line: 'null', original_start_line: 'null', start_side: 'null', line: 'null', original_line: 62, side: 'RIGHT', original_position: 25, position: 'null', subject_type: 'line' }, { pull_request_review_id: 2_227_372_510, id: 1_709_082_321, path: 'test/baza/test_locks.rb', commit_id: 'a9f5f94cf28f29a64d5dd96d0ee23b4174572847', original_commit_id: 'e8c6f94274d14ed3cb26fe71467a9c3f229df59c', user: { login: 'test', id: 88_084_038 }, body: 'author comment', created_at: '2024-08-08T09:42:46Z', updated_at: '2024-08-08T09:42:46Z', reactions: { url: 'https://api.github.com/repos/zerocracy/baza/pulls/comments/1709082321/reactions', total_count: 1 }, start_line: 'null', original_start_line: 'null', start_side: 'null', line: 'null', original_line: 62, side: 'RIGHT', original_position: 25, in_reply_to_id: 1_709_082_318, position: 'null', subject_type: 'line' } ] end |
#issue_events(_repo, _number) ⇒ Object
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 |
# File 'lib/fbe/octo.rb', line 1258 def issue_events(_repo, _number) [ { id: 126, actor: { login: 'user', id: 411, type: 'User' }, event: 'labeled', created_at: Time.parse('2025-05-30 14:41:00 UTC'), label: { name: 'bug', color: 'd73a4a' } }, { id: 206, actor: { login: 'user', id: 411, type: 'User' }, event: 'mentioned', created_at: Time.parse('2025-05-30 14:41:10 UTC') }, { id: 339, actor: { login: 'user2', id: 422, type: 'User' }, event: 'subscribed', created_at: Time.parse('2025-05-30 14:41:10 UTC') }, { id: 490, actor: { login: 'github-actions[bot]', id: 41_898_282, type: 'Bot' }, event: 'renamed', created_at: Time.parse('2025-05-30 14:41:30 UTC'), rename: { from: 'some title', to: 'some title 2' } }, { id: 505, actor: { login: 'user', id: 411, type: 'User' }, event: 'subscribed', created_at: Time.parse('2025-05-30 16:18:24 UTC') }, { id: 608, actor: { login: 'user2', id: 422, type: 'User', test: 123 }, event: 'assigned', created_at: Time.parse('2025-05-30 17:59:08 UTC'), assignee: { login: 'user2', id: 422, type: 'User' }, assigner: { login: 'user', id: 411, type: 'User' } }, { id: 776, actor: { login: 'user2', id: 422, type: 'User' }, event: 'referenced', commit_id: '4621af032170f43d', commit_url: 'https://api.github.com/repos/foo/foo/commits/4621af032170f43d', created_at: Time.parse('2025-05-30 19:57:50 UTC') } ] end |
#issue_timeline(_repo, _issue, _options = {}) ⇒ Object
1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 |
# File 'lib/fbe/octo.rb', line 1013 def issue_timeline(_repo, _issue, = {}) [ { event: 'renamed', actor: { id: 888, login: 'torvalds' }, repository: { id: name_to_number('yegor256/judges'), full_name: 'yegor256/judges' }, rename: { from: 'before', to: 'after' }, created_at: random_time }, { event: 'labeled', actor: { id: 888, login: 'torvalds' }, repository: { id: name_to_number('yegor256/judges'), full_name: 'yegor256/judges' }, label: { name: 'bug' }, created_at: random_time }, { node_id: 'ITAE_examplevq862Ga8lzwAAAAQZanzv', event: 'issue_type_added', actor: { id: 526_301, login: 'yegor256' }, repository: { id: name_to_number('yegor256/judges'), full_name: 'yegor256/judges' }, created_at: random_time }, { node_id: 'ITCE_examplevq862Ga8lzwAAAAQZbq9S', event: 'issue_type_changed', actor: { id: 526_301, login: 'yegor256' }, repository: { id: name_to_number('yegor256/judges'), full_name: 'yegor256/judges' }, created_at: random_time } ] end |
#list_issues(repo, _options = {}) ⇒ Array<Hash>
Lists issues for a repository.
646 647 648 649 650 651 |
# File 'lib/fbe/octo.rb', line 646 def list_issues(repo, = {}) [ issue(repo, 42), issue(repo, 43) ] end |
#name_to_number(name) ⇒ Integer, String
Converts a string name to a deterministic integer.
247 248 249 250 |
# File 'lib/fbe/octo.rb', line 247 def name_to_number(name) return name unless name.is_a?(String) name.chars.sum(&:ord) end |
#organization_memberships(_options = {}) ⇒ Array<Hash>
Gets organization memberships for the authenticated user.
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/fbe/octo.rb', line 324 def organization_memberships( = {}) [ { url: 'https://api.github.com/orgs/zerocracy/memberships/yegor256', state: 'active', role: 'admin', organization_url: 'https://api.github.com/orgs/zerocracy', organization: { login: 'zerocracy', id: 24_234_201, node_id: 'MDEyOk9yZ2FuaXphdGlvbjI0MjM0MjAx', url: 'https://api.github.com/orgs/zerocracy', avatar_url: 'https://avatars.githubusercontent.com/u/24234201?v=4', description: 'AI-managed software development', name: 'Zerocracy', company: nil, blog: 'https://www.zerocracy.com', location: nil, email: '[email protected]', twitter_username: nil, is_verified: false, has_organization_projects: true, has_repository_projects: true, public_repos: 30, public_gists: 0, followers: 0, following: 0, html_url: 'https://github.com/zerocracy', created_at: random_time, updated_at: random_time, type: 'Organization' }, user: user(526_301) }, { url: 'https://api.github.com/orgs/objectionary/memberships/yegor256', state: 'active', role: 'member', organization_url: 'https://api.github.com/orgs/objectionary', organization: { login: 'objectionary', id: 80_033_603, node_id: 'MDEyOk9yZ2FuaXphdGlvbjgwMDMzNjAz', url: 'https://api.github.com/orgs/objectionary', avatar_url: 'https://avatars.githubusercontent.com/u/80033603?v=4', description: 'EO/EOLANG, an object-oriented language', name: 'Objectionary', company: nil, blog: 'https://www.eolang.org', location: nil, email: nil, twitter_username: nil, is_verified: false, has_organization_projects: true, has_repository_projects: true, public_repos: 15, public_gists: 0, followers: 0, following: 0, html_url: 'https://github.com/objectionary', created_at: random_time, updated_at: random_time, type: 'Organization' }, user: user(526_301) } ] end |
#pull_request(repo, number) ⇒ Hash
Gets a single pull request.
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |
# File 'lib/fbe/octo.rb', line 708 def pull_request(repo, number) { id: 42, number:, repo: { full_name: repo }, base: { repo: { full_name: repo } }, state: 'closed', user: { login: 'yegor256', id: 526_301, type: 'User' }, head: { ref: 'master', sha: '6dcb09b5b57875f334f61aebed695e2e4193db5e' }, additions: 12, deletions: 5, changed_files: 3, comments: 2, review_comments: 2, closed_at: Time.parse('2024-12-20'), merged_at: Time.parse('2024-12-20'), created_at: Time.parse('2024-09-20') } end |
#pull_request_comments(_name, _number) ⇒ Object
1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 |
# File 'lib/fbe/octo.rb', line 1297 def pull_request_comments(_name, _number) [ { pull_request_review_id: 2_227_372_510, id: 1_709_082_318, path: 'test/baza/test_locks.rb', commit_id: 'a9f5f94cf28f29a64d5dd96d0ee23b4174572847', original_commit_id: 'e8c6f94274d14ed3cb26fe71467a9c3f229df59c', user: { login: 'Reviewer', id: 2_566_462 }, body: 'Most likely, parentheses were missed here.', created_at: '2024-08-08T09:41:46Z', updated_at: '2024-08-08T09:42:46Z', reactions: { url: 'https://api.github.com/repos/zerocracy/baza/pulls/comments/1709082318/reactions', total_count: 0 }, start_line: 'null', original_start_line: 'null', start_side: 'null', line: 'null', original_line: 62, side: 'RIGHT', original_position: 25, position: 'null', subject_type: 'line' }, { pull_request_review_id: 2_227_372_510, id: 1_709_082_319, path: 'test/baza/test_locks.rb', commit_id: 'a9f5f94cf28f29a64d5dd96d0ee23b4174572847', original_commit_id: 'e8c6f94274d14ed3cb26fe71467a9c3f229df59c', user: { login: 'test', id: 88_084_038 }, body: 'definitely a typo', created_at: '2024-08-08T09:42:46Z', updated_at: '2024-08-08T09:42:46Z', reactions: { url: 'https://api.github.com/repos/zerocracy/baza/pulls/comments/1709082319/reactions', total_count: 0 }, start_line: 'null', original_start_line: 'null', start_side: 'null', line: 'null', original_line: 62, side: 'RIGHT', original_position: 25, in_reply_to_id: 1_709_082_318, position: 'null', subject_type: 'line' } ] end |
#pull_request_review_comment_reactions(_name, _comment) ⇒ Object
1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 |
# File 'lib/fbe/octo.rb', line 1430 def pull_request_review_comment_reactions(_name, _comment) [ { id: 248_923_574, user: { login: 'user', id: 8_086_956 }, content: 'heart' } ] end |
#pull_request_reviews(_repo, _number) ⇒ Object
805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 |
# File 'lib/fbe/octo.rb', line 805 def pull_request_reviews(_repo, _number) [ { id: 22_449_327, user: { login: 'yegor256', id: 526_301, type: 'User' }, body: 'Some text 2', state: 'CHANGES_REQUESTED', author_association: 'CONTRIBUTOR', submitted_at: Time.parse('2024-08-22 10:00:00 UTC'), commit_id: 'b15c2893f1b5453' }, { id: 22_449_326, user: { login: 'yegor256', id: 526_301, type: 'User' }, body: 'Some text 1', state: 'CHANGES_REQUESTED', author_association: 'CONTRIBUTOR', submitted_at: Time.parse('2024-08-21 22:00:00 UTC'), commit_id: 'a15c2893f1b5453' } ] end |
#pull_requests(_repo, _options = {}) ⇒ Array<Hash>
Lists pull requests for a repository.
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 |
# File 'lib/fbe/octo.rb', line 742 def pull_requests(_repo, = {}) [ { id: 2_072_543_250, number: 100, state: 'closed', locked: false, title: '#90: some title', user: { login: 'yegor256', id: 526_301, type: 'User' }, body: 'Closes #90', created_at: Time.parse('2024-09-15 09:32:49 UTC'), updated_at: Time.parse('2024-09-15 10:06:23 UTC'), closed_at: Time.parse('2024-09-15 10:05:34 UTC'), merged_at: Time.parse('2024-09-15 10:05:34 UTC'), merge_commit_sha: '0527cc188b0495e', draft: false, head: { label: 'yegor256:90', ref: '90', sha: '0527cc188b049', user: { login: 'yegor256', id: 526_301, type: 'User' }, repo: repository('yegor256/repo') }, base: { label: 'zerocracy:master', ref: 'master', sha: '4643eb3c7a0ccb3c', user: { login: 'zerocracy', id: 24_234_201, type: 'Organization' }, repo: repository('zerocracy/repo') } }, { id: 2_072_543_240, number: 95, state: 'open', locked: false, title: '#80: some title', user: { login: 'yegor256', id: 526_301, type: 'User' }, body: 'Closes #80', created_at: Time.parse('2024-09-14 09:32:49 UTC'), updated_at: Time.parse('2024-09-14 10:06:23 UTC'), closed_at: nil, merged_at: nil, merge_commit_sha: '0627cc188b0497e', draft: false, head: { label: 'yegor256:80', ref: '80', sha: '1527cc188b040', user: { login: 'yegor256', id: 526_301, type: 'User' }, repo: repository('yegor256/repo') }, base: { label: 'zerocracy:master', ref: 'master', sha: '5643eb3c7a0ccb3b', user: { login: 'zerocracy', id: 24_234_201, type: 'Organization' }, repo: repository('zerocracy/repo') } } ] end |
#random_time ⇒ Time
Generates a random time in the past.
235 236 237 |
# File 'lib/fbe/octo.rb', line 235 def random_time Time.now - rand(10_000) end |
#rate_limit ⇒ Object Also known as: rate_limit!
Returns a mock rate limit object.
258 259 260 261 262 263 264 |
# File 'lib/fbe/octo.rb', line 258 def rate_limit o = Object.new def o.remaining 100 end o end |
#release(_url) ⇒ Hash
Gets a single release.
563 564 565 566 567 568 569 570 571 572 573 574 575 |
# File 'lib/fbe/octo.rb', line 563 def release(_url) { node_id: 'RE_kwDOL6GCO84J7Cen', tag_name: '0.19.0', target_commitish: 'master', name: 'just a fake name', draft: false, prerelease: false, created_at: random_time, published_at: random_time, assets: [] } end |
#releases(_repo, _opts = {}) ⇒ Array<Hash>
Lists releases for a repository.
549 550 551 552 553 554 |
# File 'lib/fbe/octo.rb', line 549 def releases(_repo, _opts = {}) [ release('https://github...'), release('https://gith') ] end |
#remove_organization_membership(_org, _user = nil) ⇒ Boolean
Removes a user from an organization.
rubocop:disable Naming/PredicateMethod
445 446 447 |
# File 'lib/fbe/octo.rb', line 445 def remove_organization_membership(_org, _user = nil) true end |
#repositories(_user = nil) ⇒ Array<Hash>
Lists repositories for a user or organization.
274 275 276 277 278 279 |
# File 'lib/fbe/octo.rb', line 274 def repositories(_user = nil) [ repository('yegor256/judges'), repository('yegor256/factbase') ] end |
#repository(name) ⇒ Hash
Gets repository information.
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 |
# File 'lib/fbe/octo.rb', line 585 def repository(name) raise Octokit::NotFound if [404_123, 404_124].include?(name) { id: name_to_number(name), full_name: name.is_a?(Integer) ? 'yegor256/test' : name, default_branch: 'master', private: false, owner: { login: name.to_s.split('/')[0], id: 526_301, site_admin: false }, html_url: "https://github.com/#{name}", description: 'something', fork: false, url: "https://github.com/#{name}", created_at: random_time, updated_at: random_time, pushed_at: random_time, size: name == 'yegor256/empty-repo' ? 0 : 470, stargazers_count: 1, watchers_count: 1, language: 'Ruby', has_issues: true, has_projects: true, has_downloads: true, has_wiki: true, has_pages: false, has_discussions: false, forks_count: 0, archived: name == 'zerocracy/datum', disabled: false, open_issues_count: 6, license: { key: 'mit', name: 'MIT License' }, allow_forking: true, is_template: false, visibility: 'public', forks: 0, open_issues: 6, watchers: 1 } end |
#repository_events(repo, _options = {}) ⇒ Object
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 |
# File 'lib/fbe/octo.rb', line 1075 def repository_events(repo, = {}) [ { id: '123', type: 'PushEvent', repo: { id: name_to_number(repo), name: repo, url: "https://api.github.com/repos/#{repo}" }, payload: { push_id: 42, ref: 'refs/heads/master', size: 1, distinct_size: 0, head: 'b7089c51cc2526a0d2619d35379f921d53c72731', before: '12d3bff1a55bad50ee2e8f29ade7f1c1e07bb025' }, actor: { id: 888, login: 'torvalds', display_login: 'torvalds' }, created_at: random_time, public: true }, { id: '124', type: 'IssuesEvent', repo: { id: name_to_number(repo), name: repo, url: "https://api.github.com/repos/#{repo}" }, payload: { action: 'closed', issue: { number: 42 } }, actor: { id: 888, login: 'torvalds', display_login: 'torvalds' }, created_at: random_time, public: true }, { id: '125', type: 'IssuesEvent', repo: { id: name_to_number(repo), name: repo, url: "https://api.github.com/repos/#{repo}" }, payload: { action: 'opened', issue: { number: 42 } }, actor: { id: 888, login: 'torvalds', display_login: 'torvalds' }, created_at: random_time, public: true }, { id: 42, created_at: Time.now, actor: { id: 42 }, type: 'PullRequestEvent', repo: { id: repo }, payload: { action: 'closed', number: 172, ref_type: 'tag', ref: 'foo', pull_request: { url: 'https://api.github.com/repos/yegor256/judges/pulls/93', id: 1_990_323_142, node_id: 'PR_kwDOL6GCO852oevG', number: 172, state: 'closed', locked: false, title: '#999 new feature', user: { login: 'test', id: 88_084_038, node_id: 'MDQ6VXNlcjE2NDYwMjA=', type: 'User', site_admin: false }, base: { label: 'zerocracy:master', ref: 'master', user: { login: 'zerocracy', id: 24_234_201 }, repo: { id: repo, node_id: 'R_kgDOK2_4Aw', name: 'baza', full_name: 'zerocracy/baza', private: false } }, head: { ref: 'zerocracy/baza', sha: '74d0c234967de0f690805c6943e78db42a294c1a' }, merged_at: Time.now, comments: 2, review_comments: 2, commits: 1, additions: 3, deletions: 3, changed_files: 2 } } }, { id: 43, created_at: Time.now, actor: { id: 42 }, type: 'PullRequestEvent', repo: { id: repo }, payload: { action: 'closed', number: 172, ref_type: 'tag', ref: 'foo', pull_request: { url: 'https://api.github.com/repos/yegor256/judges/pulls/93', id: 1_990_323_142, node_id: 'PR_kwDOL6GCO852oevG', number: 172, state: 'closed', locked: false, title: '#999 new feature', user: { login: 'test', id: 88_084_038, node_id: 'MDQ6VXNlcjE2NDYwMjA=', type: 'User', site_admin: false }, base: { label: 'zerocracy:master', ref: 'master', user: { login: 'zerocracy', id: 24_234_201 }, repo: { id: repo, node_id: 'R_kgDOK2_4Aw', name: 'judges-action', full_name: 'zerocracy/judges-action', private: false } }, head: { ref: 'zerocracy/judges-action', sha: '74d0c234967de0f690805c6943e78db42a294c1a' }, merged_at: Time.now, comments: 2, review_comments: 2, commits: 1, additions: 3, deletions: 3, changed_files: 2 } } } ] end |
#repository_workflow_runs(repo, _opts = {}) ⇒ Hash
Gets workflow runs for a repository.
504 505 506 507 508 509 510 511 512 |
# File 'lib/fbe/octo.rb', line 504 def repository_workflow_runs(repo, _opts = {}) { total_count: 2, workflow_runs: [ workflow_run(repo, 42), workflow_run(repo, 7) ] } end |
#review_comments(_repo, _number) ⇒ Object
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 |
# File 'lib/fbe/octo.rb', line 828 def review_comments(_repo, _number) [ { pull_request_review_id: 22_687_249, id: 17_361_949, body: 'Some comment 1', user: { login: 'yegor256', id: 526_301, type: 'User' }, created_at: Time.parse('2024-09-05 15:31:06 UTC'), updated_at: Time.parse('2024-09-05 15:33:04 UTC') }, { pull_request_review_id: 22_687_503, id: 17_361_950, body: 'Some comment 2', user: { login: 'yegor256', id: 526_301, type: 'User' }, created_at: Time.parse('2024-09-06 14:20:00 UTC'), updated_at: Time.parse('2024-09-06 14:20:50 UTC') }, { pull_request_review_id: 22_687_255, id: 17_361_970, body: 'Some comment 3', user: { login: 'yegor256', id: 526_301, type: 'User' }, created_at: Time.parse('2024-09-06 20:45:30 UTC'), updated_at: Time.parse('2024-09-06 20:45:30 UTC') } ] end |
#search_commits(_query, _options = {}) ⇒ Object
956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 |
# File 'lib/fbe/octo.rb', line 956 def search_commits(_query, = {}) { total_count: 3, incomplete_results: false, items: [ { commit: { author: { name: 'Yegor', email: '[email protected]', date: Time.parse('2024-09-15 12:23:25 UTC') }, committer: { name: 'Yegor', email: '[email protected]', date: Time.parse('2024-09-15 12:23:25 UTC') }, message: 'Some text', tree: { sha: '6e04579960bf67610d' }, comment_count: 0 }, author: { login: 'yegor256', id: 526_301, type: 'User', site_admin: false }, committer: { login: 'yegor256', id: 526_301, type: 'User', site_admin: false }, parents: [{ sha: '60cff20bdb66' }], repository: { id: 799_177_290, name: 'judges-action', full_name: 'zerocracy/judges-action', owner: { login: 'zerocracy', id: 24_234_201, type: 'Organization', site_admin: false } } }, { commit: { author: { name: 'Yegor', email: '[email protected]', date: Time.parse('2024-09-14 12:23:25 UTC') }, committer: { name: 'Yegor', email: '[email protected]', date: Time.parse('2024-09-14 12:23:25 UTC') }, message: 'Some text 2', tree: { sha: 'defa18e4e2250987' }, comment_count: 0 }, author: { login: 'yegor257', id: 526_302, type: 'User', site_admin: false }, committer: { login: 'yegor257', id: 526_302, type: 'User', site_admin: false }, parents: [{ sha: 'a04c15bb34fddbba' }], repository: { id: 799_177_290, name: 'judges-action', full_name: 'zerocracy/judges-action', owner: { login: 'zerocracy', id: 24_234_201, type: 'Organization', site_admin: false } } }, { commit: { author: { name: 'Yegor', email: '[email protected]', date: Time.parse('2024-09-13 12:23:25 UTC') }, committer: { name: 'Yegor', email: '[email protected]', date: Time.parse('2024-09-13 12:23:25 UTC') }, message: 'Some text 3', tree: { sha: 'bb7277441139739b902a' }, comment_count: 0 }, author: { login: 'yegor258', id: 526_303, type: 'User', site_admin: false }, committer: { login: 'yegor258', id: 526_303, type: 'User', site_admin: false }, parents: [{ sha: '18db84d469bb727' }], repository: { id: 799_177_290, name: 'judges-action', full_name: 'zerocracy/judges-action', owner: { login: 'zerocracy', id: 24_234_201, type: 'Organization', site_admin: false } } } ] } end |
#search_issues(query, _options = {}) ⇒ Object
874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 |
# File 'lib/fbe/octo.rb', line 874 def search_issues(query, = {}) if query.include?('type:pr') && query.include?('is:unmerged') { total_count: 1, incomplete_results: false, items: [ { id: 42, number: 10, title: 'Awesome PR 10' } ] } elsif query.include?('type:pr') && query.include?('is:merged') { total_count: 1, incomplete_results: false, items: [ { id: 42, number: 10, title: 'Awesome PR 10', created_at: Time.parse('2024-08-21 19:00:00 UTC'), pull_request: { merged_at: Time.parse('2024-08-23 19:00:00 UTC') } } ] } elsif query.include?('type:pr') { total_count: 2, incomplete_results: false, items: [ { id: 42, number: 10, title: 'Awesome PR 10', created_at: Time.parse('2024-08-21 19:00:00 UTC') }, { id: 43, number: 11, title: 'Awesome PR 11', created_at: Time.parse('2024-08-21 20:00:00 UTC') } ] } else { total_count: 1, incomplete_results: false, items: [ { number: 42, labels: [ { name: 'bug' } ], user: { login: 'yegor256', id: 526_301, type: 'User' }, created_at: Time.parse('2024-08-20 19:00:00 UTC') } ] } end end |
#star(_repo) ⇒ Boolean
Gives a star to a repository.
rubocop:disable Naming/PredicateMethod
472 473 474 |
# File 'lib/fbe/octo.rb', line 472 def star(_repo) true end |
#tree(_repo, _tree_sha, _options = {}) ⇒ Object
1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 |
# File 'lib/fbe/octo.rb', line 1825 def tree(_repo, _tree_sha, = {}) { sha: '492072971ad3c8644a191f62426bd3', tree: [ { path: '.github', mode: '040000', type: 'tree', sha: '438682e07e45ccbf9ca58f294a' }, { path: '.github/workflows', mode: '040000', type: 'tree', sha: 'dea8a01c236530cc92a63c5774' }, { path: '.github/workflows/actionlint.yml', mode: '100644', type: 'blob', sha: 'ffed2deef2383d6f685489b289', size: 1671 }, { path: '.github/workflows/copyrights.yml', mode: '100644', type: 'blob', sha: 'ab8357cfd94e0628676aff34cd', size: 1293 }, { path: '.github/workflows/zerocracy.yml', mode: '100644', type: 'blob', sha: '5c224c7742e5ebeeb176b90605', size: 2005 }, { path: '.gitignore', mode: '100644', type: 'blob', sha: '9383e7111a173b44baa0692775', size: 27 }, { path: '.rubocop.yml', mode: '100644', type: 'blob', sha: 'cb9b62eb1979589daa18142008', size: 1963 }, { path: 'README.md', mode: '100644', type: 'blob', sha: '8011ad43c37edbaf1969417b94', size: 4877 }, { path: 'Rakefile', mode: '100644', type: 'blob', sha: 'a0ac9bf2643d9f5392e1119301', size: 1805 } ], truncated: false } end |
#update_organization_membership(org, _options = {}) ⇒ Hash
Updates the authenticated user’s organization membership.
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
# File 'lib/fbe/octo.rb', line 401 def update_organization_membership(org, = {}) { url: "https://api.github.com/orgs/#{org}/memberships/yegor256", state: 'active', role: 'member', organization_url: "https://api.github.com/orgs/#{org}", organization: { login: org, id: 24_234_201, node_id: 'MDEyOk9yZ2FuaXphdGlvbjI0MjM0MjAx', url: "https://api.github.com/orgs/#{org}", avatar_url: 'https://avatars.githubusercontent.com/u/24234201?v=4', description: 'Organization description', name: org.capitalize, company: nil, blog: "https://www.#{org}.com", location: nil, email: "team@#{org}.com", twitter_username: nil, is_verified: false, has_organization_projects: true, has_repository_projects: true, public_repos: 30, public_gists: 0, followers: 0, following: 0, html_url: "https://github.com/#{org}", created_at: random_time, updated_at: random_time, type: 'Organization' }, user: user(526_301) } end |
#user(uid) ⇒ Hash
Gets details of a GitHub user.
485 486 487 488 489 490 491 492 493 |
# File 'lib/fbe/octo.rb', line 485 def user(uid) raise Octokit::NotFound if [404_001, 404_002].include?(uid) login = (uid == 526_301 ? 'yegor256' : 'torvalds') if uid.is_a?(Integer) { id: 444, login:, type: uid == 29_139_614 ? 'Bot' : 'User' } end |
#user_repository_invitations(_options = {}) ⇒ Array<Hash>
Gets repository invitations for the authenticated user.
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'lib/fbe/octo.rb', line 288 def user_repository_invitations( = {}) [ { id: 1, node_id: 'INV_kwDOJRF-Hq4B_yXr', repository: repository('zerocracy/fbe'), invitee: user(526_301), inviter: user(888), permissions: 'write', created_at: random_time, url: 'https://api.github.com/user/repository_invitations/1', html_url: 'https://github.com/zerocracy/fbe/invitations', expired: false }, { id: 2, node_id: 'INV_kwDOJRF-Hq4B_yXs', repository: repository('yegor256/takes'), invitee: user(526_301), inviter: user(888), permissions: 'admin', created_at: random_time, url: 'https://api.github.com/user/repository_invitations/2', html_url: 'https://github.com/yegor256/takes/invitations', expired: false } ] end |
#workflow_run(repo, id) ⇒ Object
1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 |
# File 'lib/fbe/octo.rb', line 1661 def workflow_run(repo, id) [ { id: 10_438_531_072, event: 'pull_request', conclusion: 'success', name: 'make', started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z' }, { id: 10_438_531_073, event: 'pull_request', conclusion: 'success', name: 'copyrights', started_at: '2024-08-18T08:04:44Z', run_started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z' }, { id: 10_438_531_074, event: 'pull_request', conclusion: 'success', name: 'markdown-lint', started_at: '2024-08-18T08:04:44Z', run_started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z' }, { id: 10_438_531_075, event: 'pull_request', conclusion: 'failure', name: 'pdd', started_at: '2024-08-18T08:04:44Z', run_started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z' }, { id: 10_438_531_076, event: 'pull_request', conclusion: 'success', name: 'rake', started_at: '2024-08-18T08:04:44Z', run_started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z' }, { id: 10_438_531_077, event: 'commit', conclusion: 'success', name: 'shellcheck', started_at: '2024-08-18T08:04:44Z', run_started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z' }, { id: 10_438_531_078, event: 'pull_request', conclusion: 'failure', name: 'yamllint', started_at: '2024-08-18T08:04:44Z', run_started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z' } ].find { |json| json[:id] == id } || { id:, name: 'copyrights', head_branch: 'master', head_sha: '7d34c53e6743944dbf6fc729b1066bcbb3b18443', event: 'push', status: 'completed', conclusion: 'success', workflow_id: id, created_at: random_time, run_started_at: random_time, repository: repository(repo) } end |
#workflow_run_job(_repo, job) ⇒ Object
1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 |
# File 'lib/fbe/octo.rb', line 1601 def workflow_run_job(_repo, job) [ { id: 28_907_016_501, run_id: 10_438_531_072, name: 'make', started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z' }, { id: 28_906_596_603, run_id: 10_438_531_073, name: 'copyrights', started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z' }, { id: 28_906_596_550, run_id: 10_438_531_074, name: 'markdown-lint', started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z' }, { id: 28_906_596_483, run_id: 10_438_531_075, name: 'pdd', started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z' }, { id: 28_906_596_433, run_id: 10_438_531_076, name: 'rake', started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z' }, { id: 28_906_596_405, run_id: 10_438_531_077, name: 'shellcheck', started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z' }, { id: 28_906_596_379, run_id: 10_438_531_078, name: 'yamllint', started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z' } ].find { |json| json[:id] == job } || { id: job, run_id: 1234, name: 'run job', started_at: '2024-08-18T08:04:44Z', completed_at: '2024-08-18T08:20:17Z' } end |
#workflow_run_usage(_repo, _id) ⇒ Hash
Gets usage information for a specific workflow run.
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 |
# File 'lib/fbe/octo.rb', line 523 def workflow_run_usage(_repo, _id) { billable: { UBUNTU: { total_ms: 0, jobs: 1, job_runs: [ { job_id: 1, duration_ms: 0 } ] } }, run_duration_ms: 53_000 } end |