-
Notifications
You must be signed in to change notification settings - Fork 32
Model GitHub PR submission #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lehors
wants to merge
9
commits into
lfai:main
Choose a base branch
from
lehors:feature/github-pr-submission
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit implements automatic PR submission functionality that allows users to submit their evaluated models directly to the MOT GitHub repository. Features: - Automatic fork creation and branch management - Seamless GitHub OAuth integration using existing social_auth_github - User-friendly button with real-time feedback - Comprehensive error handling and user messaging - Login prompt for unauthenticated users Files Added: - web/modules/mof/js/submit_pr.js: JavaScript for PR submission handling - web/modules/mof/src/Services/GitHubPullRequestManager.php: GitHub API service - TESTING_PR_FEATURE.md: Comprehensive testing guide - PR_SUBMISSION_IMPLEMENTATION.md: Implementation documentation Files Modified: - web/modules/mof/src/Controller/ModelController.php: Added submitPullRequest() method - web/modules/mof/src/ModelViewBuilder.php: Added PR submission button - web/modules/mof/mof.services.yml: Registered github_pr_manager service - web/modules/mof/mof.routing.yml: Added PR submission route - web/modules/mof/mof.libraries.yml: Registered JavaScript library - README.md: Updated documentation with PR submission instructions Technical Details: - Uses authenticated user's OAuth token from social_auth entity - Creates unique branch names with timestamps - Generates PR with model details and MOF classification - Handles fork creation for first-time contributors - Includes comprehensive error handling and logging Signed-off-by: Bob <AskBob@ibm.com> Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
This guide provides step-by-step instructions for configuring the social_auth_github module with OAuth credentials needed for the PR submission feature. Includes: - Creating GitHub OAuth App - Configuring required scopes (repo, user:email) - Drupal module configuration via UI and Drush - Testing procedures - Troubleshooting common issues - Security best practices - Environment-specific configurations Signed-off-by: Bob <AskBob@ibm.com> Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
- Updated GitHubSubscriber to fetch email from GitHub API - Added fallback to username@users.noreply.github.com - Fixed getGitHubUsername to check multiple data locations - Added fetchGitHubUsername to get username from API - Injected HTTP client and logger dependencies - Added comprehensive logging for debugging - Created troubleshooting guide Fixes issues where users with private emails or missing username data couldn't use the PR submission feature. Signed-off-by: Bob <AskBob@ibm.com> Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
- Created GitHubApiHelper service for shared GitHub API operations - Moved fetchPrimaryEmail from GitHubSubscriber to GitHubApiHelper - Added fetchUserName method to retrieve user's name from GitHub - Updated GitHubSubscriber to use GitHubApiHelper - Updated GitHubPullRequestManager to: - Inject GitHubApiHelper service - Add getGitHubEmail() method - Add getGitHubName() method - Add addSignedOffBy() method to append Signed-off-by line - Automatically add Signed-off-by to all commits - Updated service definitions in mof.services.yml - Uses GitHub name and email for Signed-off-by line - Fallback to username if name not available This ensures all commits made via PR submission include proper DCO sign-off using the contributor's GitHub identity. Signed-off-by: Bob <AskBob@ibm.com> Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
When users click 'Login with GitHub to Submit PR' from the evaluation results page, they should return to the results page after authentication, not the empty evaluation form. The issue was that the PHP session is destroyed during the GitHub OAuth redirect flow, so we cannot rely on session data alone. Solution: - Added 'show_results=1' query parameter to the destination URL - Updated ModelEvaluateForm::buildForm() to check for this parameter - If parameter is present and session has model_session_data, rebuild the evaluation results from session data - This works because Drupal's session is re-established after OAuth login Changes: - ModelViewBuilder: Add show_results parameter to login destination URL - ModelEvaluateForm: Check for show_results parameter and rebuild evaluation This ensures users see their evaluation results after logging in with GitHub, providing a seamless experience for PR submission. Signed-off-by: Bob <AskBob@ibm.com> Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
This troubleshooting guide is no longer needed as the email retrieval issues have been resolved in the implementation. Signed-off-by: Bob <AskBob@ibm.com> Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
Cleaned up trailing whitespaces from all files modified in this branch to maintain code quality standards. Signed-off-by: Bob <AskBob@ibm.com> Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
Instead of waiting a fixed 2 seconds for the fork to be ready, we now poll the GitHub API to check if the fork is accessible. Changes: - Added waitForFork() method to GitHubPullRequestManager - Polls up to 10 times with 1 second intervals (max 10 seconds) - Returns early if fork becomes ready - Updated submitPullRequest() to use waitForFork() - Added timeout error handling if fork doesn't become ready This provides a more reliable and efficient approach than fixed delays, typically completing in 2-3 seconds instead of always waiting 2 seconds. Signed-off-by: Bob <AskBob@ibm.com> Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
d7a9368 to
8ca53bf
Compare
getEmail() is unknown and we don't want the email from the Drupal account Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With great help from the amazing IBM Bob coding assistant I was able to implement in about a day the ability to automatically submit a PR to add or update a model after evaluation.
This closes issue #124.