Skip to content

Workflow migrator issues #3972

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

Closed
3 tasks
germa89 opened this issue May 29, 2025 · 0 comments · Fixed by #3973
Closed
3 tasks

Workflow migrator issues #3972

germa89 opened this issue May 29, 2025 · 0 comments · Fixed by #3973
Assignees

Comments

@germa89
Copy link
Collaborator

germa89 commented May 29, 2025

  • If there is more text in the comment, it fails
  • If it is not updated, it might show merge conflicts
  • It does not update before opening the PR.

If there is more text in the comment, it fails:

Details

with:
    github-token: ***
    script: const eventName = 'issue_comment';
  core.debug(`Event name: ${eventName}`);
  
  let prNumber, userTriggering, commentBody;
  
  if (eventName === "workflow_dispatch") {
    core.info('Running in workflow_dispatch mode');
  
    prNumber = '';
    userTriggering = '';
    commentBody = '';
    commentId = '';
  } else {
    core.info('Running in issue_comment mode');
  
    prNumber = '3968';
    userTriggering = 'germa89';
    commentBody = 'Since this PR is coming from a fork, let's migrate it to PyMAPDL repo.
  
  @*** migrate';
    commentId = '2919715036';
  }
  core.debug(`PR Number: ${prNumber}`);
  core.debug(`User triggering: ${userTriggering}`);
  core.debug(`Comment body: ${commentBody}`);
  core.debug(`Comment ID: ${commentId}`);
  
  // Export variables for later steps
  core.exportVariable('PR_NUMBER', prNumber);
  core.exportVariable('USER_TRIGGERING', userTriggering);
  core.exportVariable('COMMENT_ID', commentId);
  
  // Three modes of operation:
  // 1. auto - automatically resolves conflicts if possible, otherwise exits
  // 2. theirs - resolves conflicts by taking changes from the head branch
  // 3. ours - resolves conflicts by taking changes from the base branch
  let mode = '';
  if (
    commentBody.includes('*** sync theirs') ||
    commentBody.includes('*** migrate theirs')
  ) {
    core.info("Resolving conflicts by taking 'theirs' changes");
    mode = '--theirs';
  } else if (
    commentBody.includes('*** sync ours') ||
    commentBody.includes('*** migrate ours')
  ) {
    core.info("Resolving conflicts by taking 'ours' changes");
    mode = '--ours';
  } else {
    core.info("No specific sync mode provided, defaulting to 'auto' which will exit if there are conflicts.");
  }
  core.exportVariable('MODE', mode);
  
    debug: false
    user-agent: actions/github-script
    result-encoding: json
    retries: 0
    retry-exempt-status-codes: 400,401,403,404,422
SyntaxError: Unexpected identifier 's'
    at new AsyncFunction (<anonymous>)
    at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v7/dist/index.js:35424:16)
    at main (/home/runner/work/_actions/actions/github-script/v7/dist/index.js:35522:26)
    at /home/runner/work/_actions/actions/github-script/v7/dist/index.js:35497:1
    at /home/runner/work/_actions/actions/github-script/v7/dist/index.js:35553:3
    at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/v7/dist/index.js:35556:12)
    at Module._compile (node:internal/modules/cjs/loader:1529:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1613:10)
    at Module.load (node:internal/modules/cjs/loader:1275:32)
    at Module._load (node:internal/modules/cjs/loader:1096:12)
Error: Unhandled error: SyntaxError: Unexpected identifier 's'

If it is not updated, it might show merge conflicts

Details

echo "Setting up git configuration"
  git config --global user.name "***"
  git config --global user.email "***"
  git config pull.rebase true
  
  echo "Adding tkoyama010/pymapdl as remote"
  git remote add head_repo ***github.com/tkoyama010/pymapdl.git
  
  echo "Fetching 'maint/taplo' branch from 'tkoyama010/pymapdl'"
  git fetch head_repo maint/taplo
  git pull head_repo maint/taplo
  
  echo "Checking out 'migration/pr-3968' branch from 'tkoyama010/pymapdl/maint/taplo'"
  git checkout -b migration/pr-3968 head_repo/maint/taplo
  
  echo "\033[1;92m[INFO] Merging 'maint/taplo' branch into 'migration/pr-3968' \033[0m"
  git merge head_repo/maint/taplo
  CONFLICTS=$(git ls-files -u | wc -l)
  echo "CONFLICTS=$CONFLICTS"
  
  if [[ "$CONFLICTS" -gt 0 && -n "" ]]; then
    echo "::warning:: Conflicts trying to solve using mode ''."
  
    # Show conflicting files
    echo "Conflicting files:"
    git status
    echo ""
  
    # Resolve conflicts by taking "theirs" changes (optional, depending on your strategy)
    echo "Resolving conflicts by taking 'theirs' changes"
    git checkout  .
    git add .
  
    # Verify if conflicts are resolved
    REMAINING_CONFLICTS=$(git ls-files -u | wc -l)
    if [ "$REMAINING_CONFLICTS" -gt 0 ]; then
      echo "::error:: Conflicts remain after resolution. Aborting."
      exit 1
    fi
  
    # Continue the merge
    git merge --continue || { echo "::error:: Merge failed. Aborting."; exit 1; }
  else
    echo "No merge conflicts detected."
  fi
  
  echo "Pushing changes to 'ansys/pymapdl' repo"
  git push origin migration/pr-3968 --force-with-lease || { echo "::error:: Push failed. Aborting."; exit 1; }
  
  if [[ "" == "--ours" ]]; then
    echo "Sync mode is 'ours'. Pushing to head_repo/maint/taplo with 'ours' changes"
    git push origin head_repo/maint/taplo --force-with-lease || { echo "::error:: Push to head_repo/maint/taplo failed. Aborting."; exit 1; }
  fi
  shell: /usr/bin/bash -e {0}
  env:
    PR_NUMBER: 3968
    USER_TRIGGERING: germa89
    COMMENT_ID: 2919739388
    MODE: 
    CONTINUE: true
    PR_HEAD_BRANCH: maint/taplo
    PR_HEAD_REPO: tkoyama010/pymapdl
    PR_BASE_BRANCH: migration/pr-3968
    PR_BASE_REPO: ansys/pymapdl
    GITHUB_TOKEN: ***
Setting up git configuration
Adding tkoyama010/pymapdl as remote
Fetching 'maint/taplo' branch from 'tkoyama010/pymapdl'
From https://github.com/tkoyama010/pymapdl
 * branch              maint/taplo -> FETCH_HEAD
 * [new branch]        maint/taplo -> head_repo/maint/taplo
From https://github.com/tkoyama010/pymapdl
 * branch              maint/taplo -> FETCH_HEAD
Auto-merging .github/actions/pytest-summary/action.yml
CONFLICT (add/add): Merge conflict in .github/actions/pytest-summary/action.yml
Auto-merging .github/workflows/ci.yml
CONFLICT (add/add): Merge conflict in .github/workflows/ci.yml
Auto-merging .github/workflows/migrator.yml
CONFLICT (add/add): Merge conflict in .github/workflows/migrator.yml
Auto-merging .pre-commit-config.yaml
CONFLICT (add/add): Merge conflict in .pre-commit-config.yaml
Auto-merging pyproject.toml
CONFLICT (add/add): Merge conflict in pyproject.toml
Auto-merging src/ansys/mapdl/core/errors.py
CONFLICT (add/add): Merge conflict in src/ansys/mapdl/core/errors.py
Rebasing (1/1)
error: could not apply cce7ad16... ci: implementing migrator workflow (#3878)
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Could not apply cce7ad16... ci: implementing migrator workflow (#3878)
Error: Process completed with exit code 1.

@germa89 germa89 self-assigned this May 29, 2025
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 a pull request may close this issue.

1 participant