Skip to content

fix(automation): validate action ref existence and add major bump warnings#663

Open
abhimehro wants to merge 6 commits intomainfrom
fix/workflow-updater-validation-15796309238167997888
Open

fix(automation): validate action ref existence and add major bump warnings#663
abhimehro wants to merge 6 commits intomainfrom
fix/workflow-updater-validation-15796309238167997888

Conversation

@abhimehro
Copy link
Owner

This PR fixes a bug in the repository automation workflow updater. The updater was previously failing to check if the proposed latest major version tag (like v6) actually existed in the repository, resulting in broken updates like actions/checkout@v6. It also failed to warn users about major version bumps, silently hiding breaking changes.

Changes:

  1. Implemented ref_exists: In repository_automation_common.py, added a new ref_exists method that uses gh api to check if a proposed target tag exists by querying git/refs/tags/{ref} first and then falling back to git/refs/heads/{ref} (since many actions use branches for major updates).
  2. Refined Tag Filtering: Updated latest_tag_for_action to prioritize proper, non-prerelease tags by inspecting the .prerelease property on releases, filtering out API glitches (such as prereleases marked latest).
  3. Validated Target Refs: Updated workflow_file_plans in repository_automation_tasks.py to evaluate the proposed refs with ref_exists before appending them to the replacement plan. If it doesn't exist, the update is skipped.
  4. Major Version Bump Review Notes: Computed is_major_bump per update action. Added logic in run_workflow_updater to append a ### Compatibility review required section to the PR body with bullet points listing specific actions needing review before merging major upgrades.
  5. Added Unit Tests: Added tests/test_automation/test_workflow_updater.py mimicking GitHub API calls and checking proper skip behaviors based on internal configurations.

PR created automatically by Jules for task 15796309238167997888 started by @abhimehro

…nings

Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com>
@google-labs-jules
Copy link

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@trunk-io
Copy link

trunk-io bot commented Mar 23, 2026

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

mock_gh_text.side_effect = ["", "v1.2.3"]
mock_gh_json.return_value = "v2.0.0"

assert latest_tag_for_action("actions/checkout") == "v2.0.0"

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
mock_gh_text.side_effect = ["", ""]
mock_gh_json.return_value = None

assert latest_tag_for_action("actions/checkout") == ""

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

def test_target_ref_valid_and_invalid():
# Valid upgrades
assert target_ref("v4", "v5.0.0") == "v5"

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
def test_target_ref_valid_and_invalid():
# Valid upgrades
assert target_ref("v4", "v5.0.0") == "v5"
assert target_ref("v4.2.2", "v4.3.0") == "v4.3.0"

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert target_ref("v4", "v5.0.0") == "v5"
assert target_ref("v4.2.2", "v4.3.0") == "v4.3.0"
# When current is 'v4' and latest is 'v4.3.0', target_ref returns 'v4' which triggers a skip later
assert target_ref("v4", "v4.3.0") == "v4"

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
mock_target_ref.return_value = "v5"
mock_ref_exists.return_value = False
plans_missing = workflow_file_plans()
assert len(plans_missing) == 0 # Should be skipped because ref doesn't exist

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
mock_ref_exists.return_value = True
plans_exist = workflow_file_plans()

assert len(plans_exist) == 1

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
plans_exist = workflow_file_plans()

assert len(plans_exist) == 1
assert plans_exist[0]["replacements"][0]["target"] == "v4"

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.

assert len(plans_exist) == 1
assert plans_exist[0]["replacements"][0]["target"] == "v4"
assert plans_exist[0]["replacements"][0]["is_major_bump"] is True

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
assert fix_env.escape_val("value") == "value"
assert fix_env.escape_val('val"ue') == 'val\\"ue'
assert fix_env.escape_val('val\\ue') == 'val\\\\ue'
assert fix_env.escape_val("val\\ue") == "val\\\\ue"

Check notice

Code scanning / Bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the repository automation workflow updater by addressing critical issues related to GitHub Action version management. It introduces robust validation to ensure that proposed action references exist before applying updates and provides clear warnings for major version bumps, improving the reliability and safety of automated workflow updates.

Highlights

  • Action Reference Validation: Implemented a new ref_exists method in repository_automation_common.py to verify if a proposed target tag or branch for a GitHub Action actually exists in the repository, preventing updates to non-existent references.
  • Refined Latest Tag Filtering: Updated latest_tag_for_action to prioritize proper, non-prerelease tags by explicitly checking the .prerelease property and adding fallbacks for more robust version detection.
  • Major Version Bump Warnings: The workflow updater now detects major version bumps in GitHub Actions and adds a 'Compatibility review required' section to the pull request body, alerting users to potential breaking changes.
  • Workflow Update Logic Enhancement: Modified workflow_file_plans to use the new ref_exists method, skipping updates if the target reference is invalid, and incorporated major bump detection into the update plans.
  • Comprehensive Unit Tests: Added a new test file tests/test_automation/test_workflow_updater.py with unit tests covering the new ref_exists logic, latest_tag_for_action filtering, and workflow_file_plans behavior.
Ignored Files
  • Ignored by pattern: .github/workflows/** (3)
    • .github/workflows/agentics-maintenance.yml
    • .github/workflows/changelog.yml
    • .github/workflows/jules-daily-qa.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

codescene-delta-analysis[bot]

This comment was marked as outdated.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request significantly improves the repository automation workflow updater by adding validation for action references and introducing warnings for major version bumps. The logic is sound, and the inclusion of unit tests is a great addition. I've identified two edge cases in the jq queries for fetching latest tags that could lead to script failures when a repository has no stable releases or no tags. My review includes suggestions to make these queries more robust to prevent such crashes.

… code health

Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

…odeScene errors

Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

abhimehro and others added 2 commits March 23, 2026 17:21
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

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

Gates Failed
Prevent hotspot decline (1 hotspot with Complex Method)
Enforce critical code health rules (1 file with Low Cohesion)
Enforce advisory code health rules (2 files with Lines of Code in a Single File, Large Method, Complex Method)

Gates Passed
3 Quality Gates Passed

See analysis details in CodeScene

Reason for failure
Prevent hotspot decline Violations Code Health Impact
main.py 1 rule in this hotspot 1.61 → 1.61 Suppress
Enforce critical code health rules Violations Code Health Impact
repository_automation_tasks.py 1 critical rule 8.22 → 7.42 Suppress
Enforce advisory code health rules Violations Code Health Impact
repository_automation_tasks.py 2 advisory rules 8.22 → 7.42 Suppress
main.py 1 advisory rule 1.61 → 1.61 Suppress

Quality Gate Profile: Pay Down Tech Debt
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

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.

1 participant