diff --git a/.github/workflows/new_versions.yaml b/.github/workflows/new_versions.yaml index 966d7c163..8cdb9d197 100644 --- a/.github/workflows/new_versions.yaml +++ b/.github/workflows/new_versions.yaml @@ -7,10 +7,17 @@ on: jobs: update_versions: + strategy: + matrix: + branch: [main, emscripten-3.1.73] + + if: (github.event_name == 'schedule' && github.repository == 'emscripten-forge/recipes') || (github.event_name != 'schedule') runs-on: [ubuntu-latest] steps: - uses: actions/checkout@v4 + with: + ref: ${{ matrix.branch }} - name: Install micromamba uses: mamba-org/setup-micromamba@v1 diff --git a/emci/bot/bump_recipes_versions.py b/emci/bot/bump_recipes_versions.py index 5346b5406..e3fef0190 100644 --- a/emci/bot/bump_recipes_versions.py +++ b/emci/bot/bump_recipes_versions.py @@ -113,7 +113,7 @@ def update_recipe_version(recipe_file, new_version, new_sha256, is_ratler): def make_pr_title(name, old_version, new_version): return f"Update {name} from {old_version} to {new_version}" -def bump_recipe_version(recipe_dir): +def bump_recipe_version(recipe_dir, target_pr_branch_name): recipe_locations = [ ("recipe.yaml", True)] @@ -164,7 +164,9 @@ def bump_recipe_version(recipe_dir): # commit the changes and make a PR pr_title = make_pr_title(name, current_version, new_version) print(f"Making PR for {name} with title: {pr_title}") - make_pr_for_recipe(recipe_dir=recipe_dir, pr_title=pr_title, branch_name=branch_name, automerge=automerge) + make_pr_for_recipe(recipe_dir=recipe_dir, pr_title=pr_title, branch_name=branch_name, + target_branch_name=target_pr_branch_name, + automerge=automerge) return True , current_version, new_version @@ -248,11 +250,27 @@ def empty_context_manager(): # get all opened PRs with user_ctx(): + # get current branch name + current_branch_name = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode('utf-8').strip() + + print(f"Current branch name: {current_branch_name}") + # Check for opened PRs and merge them if the CI passed print("Checking opened PRs and merge them if green!") - prs = subprocess.check_output( + all_prs = subprocess.check_output( ['gh', 'pr', 'list', '--author', 'emscripten-forge-bot'], ).decode('utf-8').split('\n') + prs = [] + for pr in all_prs: + + # gh pr view #1479 --json baseRefName -q '.baseRefName' + target_branch_name = subprocess.check_output( + ['gh', 'pr', 'view', pr, '--json', 'baseRefName', '-q', '.baseRefName'] + ).decode('utf-8').strip() + if target_branch_name == current_branch_name: + prs.append(pr) + else: + print(f"skip PR {pr} [ current branch {current_branch_name} but PR is for {target_branch_name}]") all_recipes = [recipe for recipe in Path(recipe_dir).iterdir() if recipe.is_dir()] # map from folder names to recipe-dir @@ -282,7 +300,7 @@ def empty_context_manager(): total_bumped = 0 for recipe in all_recipes: try: - bumped_version, old_version, new_version = bump_recipe_version(recipe) + bumped_version, old_version, new_version = bump_recipe_version(recipe, current_branch_name) if bumped_version: print(f"Bumped {recipe} from {old_version} to {new_version}") total_bumped += int(bumped_version) diff --git a/emci/git_utils.py b/emci/git_utils.py index c61f18f46..8b186e91c 100644 --- a/emci/git_utils.py +++ b/emci/git_utils.py @@ -98,7 +98,7 @@ def automerge_is_enabled(pr): -def make_pr_for_recipe(recipe_dir, pr_title, branch_name, automerge): +def make_pr_for_recipe(recipe_dir, pr_title, target_branch_name, branch_name, automerge): # git commit subprocess.check_output(['git', 'add', recipe_dir]) @@ -111,7 +111,7 @@ def make_pr_for_recipe(recipe_dir, pr_title, branch_name, automerge): # call gh to create a PR subprocess.check_call([ 'gh', 'pr', 'create', - '-B', 'main', + '-B', target_branch_name, '--title', pr_title, '--body', 'Beep-boop-beep! Whistle-whistle-woo!', '--label', 'Automerge' if automerge else 'Needs Tests'