Skip to content

Conversation

ChrisRackauckas-Claude
Copy link
Contributor

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Aug 8, 2025

Summary

This PR adds gh_cli_jll as a fallback option for LinearSolveAutotune.jl when the GitHub CLI (gh) is not installed on the system, and adds automatic authentication prompts to make sharing results easier. This ensures that LinearSolveAutotune's telemetry features work seamlessly regardless of whether users have gh installed or configured.

Changes

Part 1: JLL Fallback Support

  • Added gh_cli_jll as a dependency to LinearSolveAutotune's Project.toml
  • Implemented get_gh_command() function that intelligently selects between system gh and JLL-provided gh
  • Updated all gh CLI calls in telemetry.jl to use the new wrapper function

Part 2: Automatic Authentication (New!)

  • Modified setup_github_authentication() to offer interactive authentication when not configured
  • Added auto_login parameter to control authentication prompts
  • If gh is not authenticated, the function now:
    • Prompts the user if they want to authenticate
    • Runs gh auth login interactively if they agree
    • Verifies authentication succeeded
    • Falls back to local file saving if authentication is skipped or fails
  • Updated share_results() to use the new auto-login feature

Implementation Details

gh Command Selection

The new get_gh_command() function follows this logic:

  1. First checks if gh is installed on the system using Sys.which("gh")
  2. If found, uses the system gh for better performance and compatibility
  3. If not found, falls back to the JLL-provided gh binary from gh_cli_jll

Auto-Authentication Flow

When share_results() is called:

  1. Checks for existing gh authentication or GITHUB_TOKEN
  2. If not authenticated and auto_login=true (default):
    • Prompts user: "Would you like to authenticate with GitHub now?"
    • If yes, runs gh auth login interactively
    • User completes browser-based authentication
    • Verifies authentication succeeded
  3. If authentication fails or is skipped, saves results locally

All existing gh CLI calls have been updated to use this wrapper:

  • setup_github_authentication() - for checking auth status
  • upload_plots_to_gist_gh() - for creating and managing gists
  • comment_on_issue_gh() - for adding comments to issues
  • create_benchmark_issue_gh() - for creating new issues

Testing

Added test file test_gh_fallback.jl that verifies:

  • The get_gh_command() function returns a valid command
  • Both system gh and JLL gh can execute successfully
  • Authentication setup function works with the wrapper
  • Auto-login prompt behavior works correctly

Tested locally with both scenarios:

  • ✅ System gh installed: Uses system gh
  • ✅ System gh not available: Falls back to JLL gh
  • ✅ Not authenticated: Prompts for authentication
  • ✅ Already authenticated: Proceeds directly

Benefits

  • Zero-friction sharing: Users are guided through authentication when needed
  • Improved user experience: Users don't need to manually install or configure gh CLI
  • Broader compatibility: Works on systems where gh installation might be restricted
  • Seamless fallback: Prefers system gh when available, ensuring existing workflows are unchanged
  • Zero configuration: Works out of the box after package installation
  • Interactive setup: Walks users through authentication step-by-step

Example Usage

# Run benchmarks
results = autotune_setup()

# Share results - will prompt for auth if needed
share_results(results)  # Interactive auth prompt if not configured

# Or skip auth prompt
share_results(results; auto_login=false)  # No prompt, saves locally if not authenticated

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

- Added gh_cli_jll as a dependency to LinearSolveAutotune
- Implemented get_gh_command() function that prefers system gh if available, falls back to JLL
- Updated all gh CLI calls to use the get_gh_command() wrapper
- Added tests to verify both system and JLL gh work correctly

This ensures LinearSolveAutotune works even when gh CLI is not installed on the system.
@ChrisRackauckas ChrisRackauckas merged commit 6abda9e into SciML:main Aug 8, 2025
105 of 118 checks passed
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.

2 participants