Skip to content

Bug-2038705: Migrate the get_commit to pygithub - #9739

Open
moijes12 wants to merge 7 commits into
mozilla:masterfrom
moijes12:migrate-getcommit
Open

Bug-2038705: Migrate the get_commit to pygithub#9739
moijes12 wants to merge 7 commits into
mozilla:masterfrom
moijes12:migrate-getcommit

Conversation

@moijes12

Copy link
Copy Markdown
Contributor

Changes Introduced

  • Migrate the get_commit method in treeeherder/utils/github.py to use PyGithub object's
  • It continues to return a dictionary as we want to compatibility with downstream users - collector.py and ingest.py

Local Testing

  • Marginal performance improvement observed in update_changelog. See results below
================= With Changes =========================
root@ac48de19de68:/app# time python manage.py update_changelog 
{"logging.googleapis.com/diagnostic": {"instrumentation_source": [{"name": "python", "version": "3.16.0"}]},"severity": "INFO", "logging.googleapis.com/labels": {"python_logger": "google.cloud.logging_v2.handlers.structured_log"}, "logging.googleapis.com/trace": "", "logging.googleapis.com/spanId": "", "logging.googleapis.com/trace_sampled": false, "logging.googleapis.com/sourceLocation": {"line": 151, "file": "/usr/local/lib/python3.13/site-packages/google/cloud/logging_v2/handlers/structured_log.py", "function": "emit_instrumentation_info"}, "httpRequest": {} }
{"message": "Updating unified changelog (days=1)","severity": "INFO", "logging.googleapis.com/labels": {"python_logger": "treeherder.changelog.tasks"}, "logging.googleapis.com/trace": "", "logging.googleapis.com/spanId": "", "logging.googleapis.com/trace_sampled": false, "logging.googleapis.com/sourceLocation": {"line": 16, "file": "/app/treeherder/changelog/tasks.py", "function": "update_changelog"}, "httpRequest": {} }
{"message": "Found 6 items, 0 existed and 6 where created.","severity": "INFO", "logging.googleapis.com/labels": {"python_logger": "treeherder.changelog.tasks"}, "logging.googleapis.com/trace": "", "logging.googleapis.com/spanId": "", "logging.googleapis.com/trace_sampled": false, "logging.googleapis.com/sourceLocation": {"line": 34, "file": "/app/treeherder/changelog/tasks.py", "function": "update_changelog"}, "httpRequest": {} }

real    0m24.177s
user    0m4.342s
sys     0m0.471s


========================= Master Branch ========================

root@ac48de19de68:/app# time python manage.py update_changelog 
{"logging.googleapis.com/diagnostic": {"instrumentation_source": [{"name": "python", "version": "3.16.0"}]},"severity": "INFO", "logging.googleapis.com/labels": {"python_logger": "google.cloud.logging_v2.handlers.structured_log"}, "logging.googleapis.com/trace": "", "logging.googleapis.com/spanId": "", "logging.googleapis.com/trace_sampled": false, "logging.googleapis.com/sourceLocation": {"line": 151, "file": "/usr/local/lib/python3.13/site-packages/google/cloud/logging_v2/handlers/structured_log.py", "function": "emit_instrumentation_info"}, "httpRequest": {} }
{"message": "Updating unified changelog (days=1)","severity": "INFO", "logging.googleapis.com/labels": {"python_logger": "treeherder.changelog.tasks"}, "logging.googleapis.com/trace": "", "logging.googleapis.com/spanId": "", "logging.googleapis.com/trace_sampled": false, "logging.googleapis.com/sourceLocation": {"line": 16, "file": "/app/treeherder/changelog/tasks.py", "function": "update_changelog"}, "httpRequest": {} }
{"message": "Found 6 items, 0 existed and 6 where created.","severity": "INFO", "logging.googleapis.com/labels": {"python_logger": "treeherder.changelog.tasks"}, "logging.googleapis.com/trace": "", "logging.googleapis.com/spanId": "", "logging.googleapis.com/trace_sampled": false, "logging.googleapis.com/sourceLocation": {"line": 34, "file": "/app/treeherder/changelog/tasks.py", "function": "update_changelog"}, "httpRequest": {} }

real    0m28.431s
user    0m6.320s
sys     0m0.927s

@gmierz @Archaeopteryx

moijes12 added 2 commits July 31, 2026 01:18
Migrate get_commit to use pygithub
Add docstring to `get_commit` function
@netlify

netlify Bot commented Jul 31, 2026

Copy link
Copy Markdown

Deploy Preview for treeherder ready!

Name Link
🔨 Latest commit 6fc9434
🔍 Latest deploy log https://app.netlify.com/projects/treeherder/deploys/6a6c5ef434bad20008682636
😎 Deploy Preview https://deploy-preview-9739--treeherder.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

moijes12 added 5 commits July 31, 2026 06:47
Added mocks for mocking PyGithub Commit objects
Added tests for testing get_commit scenarios:
- Standard commit
- Initial commit without parents
- Commit without files
Update the tests in tests/changelog/ to reflect changes
in github.py
Fixed return value of get_commit mock in tests and typo in
committer.
prepare_responses no longer returns commit. It only patches
get_commits
@moijes12
moijes12 marked this pull request as ready for review July 31, 2026 08:54
@moijes12

Copy link
Copy Markdown
Contributor Author

@gmierz @Archaeopteryx This PR is now ready for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant