Skip to content

GH-33241: [Archery] Replace github3 with pygithub#48886

Merged
raulcd merged 16 commits into
apache:mainfrom
fangchenli:crossbow-pygithub-migration
Jun 19, 2026
Merged

GH-33241: [Archery] Replace github3 with pygithub#48886
raulcd merged 16 commits into
apache:mainfrom
fangchenli:crossbow-pygithub-migration

Conversation

@fangchenli

@fangchenli fangchenli commented Jan 19, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

Archery currently uses both pygithub and github3. It's unnecessary and increases maintenance burden.

What changes are included in this PR?

Replace all github3 usage with pygithub.

Are these changes tested?

Yes, unittests added.

Are there any user-facing changes?

No.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #33241 has been automatically assigned in GitHub to PR creator.

@github-actions github-actions Bot added the awaiting review Awaiting review label Jan 19, 2026
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #33241 has been automatically assigned in GitHub to PR creator.

@fangchenli fangchenli marked this pull request as ready for review January 19, 2026 22:13

@raulcd raulcd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, awesome work. The changes look great in general. I'll have to take some time to do some validation as crossbow isn't extensively tested at the moment. Can you remove this one while I find some time to test it?

github3.py

Comment thread dev/archery/setup.py Outdated
@raulcd

raulcd commented Jan 20, 2026

Copy link
Copy Markdown
Member

Failures are unrelated, will be fixed once the following issue closed. It has a PR ready to be merged:

@fangchenli fangchenli requested a review from raulcd February 21, 2026 00:43

@raulcd raulcd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me. Thanks @fangchenli
@kou I plan to merge this and if we find any small issue not covered by tests during crossbow runs we can fix them.
I haven't validated manually the different cases but have reviewed the changes.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #33241 has been automatically assigned in GitHub to PR creator.

@kou kou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

It makes sense.

@fangchenli BTW, I'm not sure why you worked on this but are you interested in GitHub API related issue? We want to complete #47340 but we need to update our GitHub API usage too. (Changing Type: XXX issue label to XXX issue type in our development scripts.) Do you want to work on it?

Comment thread dev/archery/archery/crossbow/core.py Outdated
Comment thread dev/archery/archery/crossbow/core.py
Copilot AI review requested due to automatic review settings June 11, 2026 05:29
@fangchenli fangchenli requested a review from pitrou as a code owner June 11, 2026 05:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR migrates Crossbow’s GitHub integration from github3.py to PyGithub, updating dependency declarations and adapting the core/CLI codepaths plus tests around releases, PRs, and asset uploads.

Changes:

  • Replace github3.py usage with PyGithub in Crossbow core logic and CLI flows.
  • Update packaging/conda environment dependencies and remove the crossbow-upload extra.
  • Add/expand unit tests covering the new PyGithub-based behaviors (releases, PRs, assets, statuses).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
dev/archery/setup.py Switch Crossbow extra dependency from github3.py to pygithub and remove crossbow-upload extra.
dev/archery/archery/crossbow/core.py Port GitHub API interactions (login, releases, PRs, assets, statuses) from github3.py to PyGithub.
dev/archery/archery/crossbow/cli.py Update asset download and upload CLI commands to use PyGithub APIs; remove upload method option.
dev/archery/archery/crossbow/tests/test_core.py Add tests for new PyGithub-based Repo/TaskStatus/TaskAssets behaviors.
dev/archery/README.md Remove docs for the now-removed crossbow-upload extra.
ci/conda_env_crossbow.txt Replace github3.py with pygithub in Crossbow conda env.
ci/conda_env_archery.txt Remove github3.py from Archery conda env.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread dev/archery/archery/crossbow/core.py
Comment on lines +540 to +547
release = repo.get_release(tag_name)
release.delete_release()
except GithubException as e:
if e.status != 404:
raise

release = repo.create_git_release(tag_name, tag_name, "",
target_commitish=target_commitish)
Comment thread dev/archery/archery/crossbow/core.py
Comment on lines +522 to 524
except IOError as e:
# Catch network and file I/O errors (includes requests exceptions)
logger.error(f"Attempt {i + 1} has failed with message: {e}.")
Comment on lines +116 to +118
with mock.patch.object(Repo, 'as_github_repo') as mock_repo:
with mock.patch.object(Repo, 'default_branch_name', 'main'):
mock_pr = mock.MagicMock()
Comment thread dev/archery/setup.py Outdated
Comment on lines 32 to 33
'crossbow': ['pygithub', jinja_req, 'pygit2>=1.14.0', 'requests',
'ruamel.yaml', 'setuptools_scm>=8.0.0'],
Copilot AI review requested due to automatic review settings June 11, 2026 06:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Comment thread dev/archery/archery/crossbow/core.py
Comment on lines 535 to +541
# remove the whole release if it already exists
try:
release = repo.release_from_tag(tag_name)
except github3.exceptions.NotFoundError:
pass
else:
release.delete()

release = repo.create_release(tag_name, target_commitish)
release = repo.get_release(tag_name)
release.delete_release()
except GithubException as e:
if e.status != 404:
raise
Comment on lines +519 to 521
except IOError as e:
# Catch network and file I/O errors (includes requests exceptions)
logger.error(f"Attempt {i + 1} has failed with message: {e}.")
Comment thread ci/conda_env_archery.txt
@fangchenli fangchenli requested a review from kou June 11, 2026 06:07
@pitrou

pitrou commented Jun 11, 2026

Copy link
Copy Markdown
Member

@kszucs Would you like to review this?

@kszucs

kszucs commented Jun 11, 2026

Copy link
Copy Markdown
Member

Back then github3.py had wider feature support and better maintenance though some features were missing hence the pygithub dependency as well (at least if I recall correctly, it was a while ago / there could have been missing packages as well). Apparently pygithub is more actively maintained nowadays so it is indeed better to keep only pygithub.

@kszucs

kszucs commented Jun 11, 2026

Copy link
Copy Markdown
Member

Overall it looks good to me.

Copilot AI review requested due to automatic review settings June 12, 2026 09:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Comment on lines 481 to +488
def github_release(self, tag):
repo = self.as_github_repo()
try:
return repo.release_from_tag(tag)
except github3.exceptions.NotFoundError:
return None

def github_upload_asset_requests(self, release, path, name, mime,
max_retries=None, retry_backoff=None):
return repo.get_release(tag)
except GithubException as e:
if e.status == 404:
return None
raise
Comment on lines 528 to +541
@@ -560,13 +534,14 @@ def github_overwrite_release_assets(self, tag_name, target_commitish,

# remove the whole release if it already exists
try:
release = repo.release_from_tag(tag_name)
except github3.exceptions.NotFoundError:
pass
else:
release.delete()

release = repo.create_release(tag_name, target_commitish)
release = repo.get_release(tag_name)
release.delete_release()
except GithubException as e:
if e.status != 404:
raise
Comment on lines +519 to 521
except IOError as e:
# Catch network and file I/O errors (includes requests exceptions)
logger.error(f"Attempt {i + 1} has failed with message: {e}.")
@fangchenli fangchenli requested a review from kszucs June 12, 2026 10:31
@pitrou

pitrou commented Jun 15, 2026

Copy link
Copy Markdown
Member

@github-actions crossbow submit wheelcp313*

@github-actions

Copy link
Copy Markdown

Revision: b7ab6e7

Submitted crossbow builds: ursacomputing/crossbow @ actions-9dd6cd6454

Task Status
wheel-macos-monterey-cp313-cp313-amd64 GitHub Actions
wheel-macos-monterey-cp313-cp313-arm64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313-amd64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313-arm64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313-amd64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313-arm64 GitHub Actions
wheel-windows-cp313-cp313-amd64 GitHub Actions

@pitrou pitrou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two nits, I'll trust @raulcd and @kszucs otherwise

Comment thread ci/conda_env_crossbow.txt Outdated

click
github3.py
pygithub

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep this list alphabetically-ordered?

Comment thread dev/archery/setup.py Outdated
extras = {
'benchmark': ['pandas'],
'crossbow': ['github3.py', jinja_req, 'pygit2>=1.14.0', 'requests',
'crossbow': ['pygithub>=2.5.0', jinja_req, 'pygit2>=1.14.0', 'requests',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same nit: alphabetical order

@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Jun 15, 2026

@raulcd raulcd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fangchenli for the work here and the effort of keeping it alive. I am going to merge this. It will be tested by some CI jobs and thoroughly tested during the release (download and upload artifacts steps)

@github-actions github-actions Bot added awaiting merge Awaiting merge and removed awaiting committer review Awaiting committer review labels Jun 19, 2026
@raulcd raulcd merged commit 98ee71e into apache:main Jun 19, 2026
44 checks passed
@raulcd raulcd removed the awaiting merge Awaiting merge label Jun 19, 2026
@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 98ee71e.

There were 6 benchmark results indicating a performance regression:

The full Conbench report has more details. It also includes information about 556 possible false positives for unstable benchmarks that are known to sometimes produce them.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants