Skip to content

ci(small): Resolve CI Squash and Wait workflow failure#7822

Closed
arii wants to merge 36 commits intoleaderfrom
fix/ci-squash-failure-16189483617843542037
Closed

ci(small): Resolve CI Squash and Wait workflow failure#7822
arii wants to merge 36 commits intoleaderfrom
fix/ci-squash-failure-16189483617843542037

Conversation

@arii
Copy link
Copy Markdown
Owner

@arii arii commented Feb 11, 2026

Description

This PR resolves a failure in the 'Trigger PR Squash and Wait' step of the test_pr_squash job within the E2E CI workflow. The issue stemmed from two primary problems:

  1. Missing explicit permissions in the workflow file, which caused 403 errors due to restricted GITHUB_TOKEN default permissions.
  2. The use of GITHUB_TOKEN for making PR comments, which prevented those comments from triggering subsequent automated workflows, such as the Gemini Orchestrator responsible for handling the squash operation.

To address these, the following changes were implemented:

  • An explicit permissions block was added to .github/workflows/e2e-ci-tests.yml to grant necessary permissions.
  • The gh CLI operations in the E2E tests were updated to use GH_TOKEN: ${{ secrets.ARI_PAT || secrets.GITHUB_TOKEN }} to ensure that comments made by the workflow can trigger other workflows.
  • The logic for extracting the PR number was refactored from awk to a more robust grep regex for improved reliability.

These modifications ensure that the E2E tests have the required permissions to execute successfully and that their actions correctly trigger the automated workflows they are designed to test.

Fixes #7809

Change Type: 🐛 Bug fix (non-breaking change fixing an issue)

PR Scope Checklist

This checklist is mandatory for all PRs.

  • PR has a clear, single purpose: The title and description of the PR clearly state the purpose of the change.
  • All changes relate to the stated objective: The code changes should be directly related to the purpose of the PR.
  • No unrelated cleanup or refactoring: The PR should not contain any changes that are not directly related to the stated objective.
  • Title and description match the actual changes: The title and description should accurately reflect the changes in the PR.
  • Tests cover the specific change scope: The tests should be focused on the changes in the PR and should not include unrelated tests.

Impact Assessment

  • Changes are backward compatible (or breaking changes are documented)
  • Tests are added/updated for new functionality
  • Documentation is updated if needed
  • ADR is created/updated for significant architectural changes
Original PR Body

Investigated the failure in the 'Trigger PR Squash and Wait' step of the test_pr_squash job.

Identified two main issues:

  1. Missing explicit permissions in the workflow file, which could lead to 403 errors if the default GITHUB_TOKEN is restricted.
  2. The use of GITHUB_TOKEN to make PR comments, which prevents those comments from triggering other workflows (like Gemini Orchestrator that handles the squash).

Resolved these issues by:

  • Adding an explicit permissions block to .github/workflows/e2e-ci-tests.yml.
  • Switching to GH_TOKEN: ${{ secrets.ARI_PAT || secrets.GITHUB_TOKEN }} for all gh CLI operations in the E2E tests.
  • Refactoring the PR number extraction from awk to a more robust grep regex.

These changes ensure that the E2E tests have the necessary permissions and that their actions correctly trigger the automated workflows they are designed to test.

Fixes #7809


PR created automatically by Jules for task 16189483617843542037 started by @arii

…ions and implementing a Personal Access Token. Here are the specific changes I made:

- Added top-level permissions (contents: write, pull-requests: write, issues: write) to the `.github/workflows/e2e-ci-tests.yml` file.
- Updated all E2E CI jobs to use `ARI_PAT` as the `GH_TOKEN` to ensure PR comments correctly trigger downstream workflows.
- Improved the robustness of the PR number extraction logic.
- Standardized the use of the `GH_TOKEN` environment variable for all GitHub CLI calls.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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.

@github-actions github-actions Bot changed the title Resolve CI Squash and Wait workflow failure ci(small): Resolve CI Squash and Wait workflow failure Feb 11, 2026
@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 11, 2026

🤖 AI Technical Audit

Anti-AI-Slop Directives

  1. OVERLY VERBOSE COMMENTS: None found.
  2. OVER-ENGINEERING: None found. The logic change is minimal and targeted.
  3. DUPLICATE HOOKS/TYPES: None.
  4. CODE RATIO: Violation Found. The environment variable GH_TOKEN is redefined in 8 separate steps within the same job. Moving this to the job level env block would remove approximately 7-10 lines of code and improve maintainability.
  5. STALE FEATURES: The awk parsing logic is correctly removed.

Code Review

.github/workflows/e2e-ci-tests.yml

1. Violation of DRY (Don't Repeat Yourself) - Code Ratio

You are setting GH_TOKEN: ${{ secrets.ARI_PAT || secrets.GITHUB_TOKEN }} in every single step (Create PR, Trigger Squash, Verify Squash, Cleanup, etc.). Since this token is required for the gh CLI across the entire job, it should be defined once at the job level.

  • Problem: Unnecessary repetition increases noise and makes future updates to the token logic error-prone.
  • Implementation Sample:
    jobs:
      test_pr_squash:
        runs-on: ubuntu-latest
        # Define strictly once here
        env:
          GH_TOKEN: ${{ secrets.ARI_PAT || secrets.GITHUB_TOKEN }}
        steps:
          # Remove env: GH_TOKEN from all individual steps below

2. Brittle Secret Naming (ARI_PAT)

Using a specific user's name in a secret (e.g., ARI_PAT) is bad infrastructure practice. If 'Ari' leaves the project or rotates keys, this creates confusion.

  • Recommendation: Rename the secret to something functional like CI_BOT_PAT or E2E_WORKFLOW_TOKEN in the repository settings and this workflow.

3. Logic Fallback Risk

The construct ${{ secrets.ARI_PAT || secrets.GITHUB_TOKEN }} is dangerous here. The PR states that GITHUB_TOKEN causes the failure because it cannot trigger subsequent workflows. If secrets.ARI_PAT is missing (e.g., in a fork or if not configured), the workflow will silently fall back to GITHUB_TOKEN and likely fail with the same obscure error you are trying to fix, or worse, pass the 'create' step but time out waiting for the orchestrator.

  • Recommendation: If the PAT is strictly required for the test to pass (by triggering the orchestrator), the workflow should probably fail fast or warn if it is missing, rather than silently degrading to a broken state.

4. Regex Robustness

The change to grep -oE "[0-9]+$" is good, but be aware that if gh pr create output format changes (e.g. adds whitespace), the $ anchor might fail. However, gh is generally stable, so this is an acceptable improvement over awk.

Review automatically published via RepoAuditor.

@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 11, 2026

Reviewed commit: 7d08b9e0ba8eb220be3e27b08abc8aa612af3278

This PR effectively addresses the reported CI workflow failures by enhancing the permissions and token handling within the e2e-ci-tests.yml workflow.

Strengths

  • Explicit Permissions: The addition of permissions: write for contents, pull-requests, and issues is a crucial and correct step to ensure the workflow has the necessary authorization to perform its tasks, such as creating and managing pull requests.
  • Robust Token Handling: Switching to GH_TOKEN for the gh CLI is standard practice, and the fallback to secrets.ARI_PAT provides a practical solution for potential GITHUB_TOKEN permission limitations, directly resolving workflow failures related to insufficient permissions.
  • Improved PR Number Extraction: The change from awk to grep -oE "[0-9]+$" for extracting the PR number is a minor but robust improvement, ensuring reliable parsing of the PR URL.
  • Focused Change: The changes are well-scoped to the CI workflow file, demonstrating a clear understanding of the problem and a targeted solution without introducing unrelated modifications.

Suggested Issues

  • Title: Centralize GitHub Actions Token Management
  • Description: The current implementation uses secrets.ARI_PAT || secrets.GITHUB_TOKEN as a workaround for GITHUB_TOKEN permission limitations in the E2E CI workflow. While functional, relying on a personal access token (PAT) in a shared workflow can introduce security risks if the PAT has broad permissions or is not regularly rotated. Investigate and implement a more secure and scalable solution for granting necessary permissions to GitHub Actions workflows, such as using GitHub Apps with fine-grained permissions or exploring GitHub's built-in GITHUB_TOKEN enhancements for specific write scopes. This would reduce reliance on individual PATs and improve overall security posture.
  • Type: technical-debt
  • Priority: medium

Reviewed at commit: 7d08b9e0ba8eb220be3e27b08abc8aa612af3278

@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 11, 2026

🤖 AI Technical Audit

Code Review: PR #7822

General Assessment

This PR correctly identifies and resolves the root cause of the workflow failures: the GITHUB_TOKEN limitations regarding recursive workflow triggers and permission scopes. The switch to a Personal Access Token (PAT) via GH_TOKEN enables the E2E tests to trigger downstream workflows (like Gemini Orchestrator), and the explicit permissions block fixes the 403 errors.

⛔ Anti-AI-Slop Directives

  1. CODE RATIO / DUPLICATION: The PR introduces significant repetition. The GH_TOKEN environment variable is defined identically in 11 separate steps. This violates the "Don't Repeat Yourself" (DRY) principle and clutters the workflow file.
  2. OVER-ENGINEERING: While the fallback logic (secrets.ARI_PAT || secrets.GITHUB_TOKEN) is clever, repeating it everywhere is unnecessary usage of step-level configuration when a global or job-level scope exists.

Key Feedback

1. Workflow Optimization (High Priority)

Instead of defining GH_TOKEN in every single step, define it once at the global env level (or job level). This will remove approximately 10-15 lines of configuration and make future token updates easier.

Problem:

- name: Create Test Branch and PR
  env:
    GH_TOKEN: ${{ secrets.ARI_PAT || secrets.GITHUB_TOKEN }}
  run: ...

- name: Trigger PR Squash and Wait
  env:
    GH_TOKEN: ${{ secrets.ARI_PAT || secrets.GITHUB_TOKEN }}
  run: ...
# Repeated 9 more times...

Implementation Sample (Proposed Fix):

name: E2E CI Tests

permissions:
  contents: write
  pull-requests: write
  issues: write

# Define once here
env:
  GH_TOKEN: ${{ secrets.ARI_PAT || secrets.GITHUB_TOKEN }}

jobs:
  test_pr_squash:
    # ... steps utilize the global env automatically

2. Regex Robustness

The change from awk to grep -oE "[0-9]+$" is a good improvement for robustness. However, ensure that gh pr create output is strictly validated or captured, as grep will return an empty string (and potentially fail silent downstream) if the URL format changes unexpectedly.

Security Note

The reliance on secrets.ARI_PAT hardcodes a dependency on a specific user's token. While acceptable for a fix, consider moving to a GitHub App installation token or a generic BOT_PAT in the future to decouple the CI from an individual's account.

Review automatically published via RepoAuditor.

@arii arii added the refactor label Feb 11, 2026
google-labs-jules Bot and others added 2 commits February 11, 2026 08:44
- Moved GH_TOKEN definition to job level for all E2E jobs.
- Implemented fail-fast validation for required PAT (CI_BOT_PAT or ARI_PAT).
- Removed redundant env blocks and unnecessary BRANCH_NAME mappings.
- Improved robustness of PR number extraction.
- Ensured consistent use of GH_TOKEN for GitHub CLI.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
- Removed 'exit 1' from token validation to allow CI to pass in fork PRs.
- Improved secret validation with clear warnings.
- Maintained job-level GH_TOKEN for DRY compliance.
- Support both CI_BOT_PAT and ARI_PAT for triggering downstream workflows.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 11, 2026

Reviewed commit: 4818ff8c2b22c62bbe32964636139c5bfa166a09

This PR effectively resolves the CI Squash and Wait workflow failures by implementing several key improvements to the GitHub Actions configuration.

Strengths

  • Improved Token Handling: The GH_TOKEN is now defined at the job level with a robust fallback mechanism (CI_BOT_PAT || ARI_PAT || GITHUB_TOKEN). This ensures that the gh CLI commands have the necessary permissions, which was likely the root cause of the previous CI failures.
  • Explicit Permissions: The addition of a permissions block explicitly grants write access for contents, pull-requests, and issues. This is a best practice for GitHub Actions, enhancing security and making required permissions transparent.
  • Token Validation: The new Validate Token step provides crucial early feedback. If the required PATs are missing, the workflow will fail immediately, preventing silent failures and aiding in quicker debugging.
  • Robust PR Number Extraction: The update to grep -oE "[0-9]+$" for extracting the PR number is more precise and resilient than the previous awk command.
  • Reduced Redundancy: By defining GH_TOKEN at the job level, redundant GITHUB_TOKEN environment variable declarations have been removed from individual steps, leading to cleaner and more maintainable workflow definitions.

Verdict

The changes are well-implemented, directly address the described CI failures, and significantly improve the robustness and clarity of the E2E test workflows. This PR is ready for approval.

Reviewed at commit: 4818ff8c2b22c62bbe32964636139c5bfa166a09

@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 11, 2026

🤖 AI Technical Audit

Code Review: PR #7822 - CI Squash and Wait Workflow Fix

This PR correctly identifies and resolves the root cause of the E2E workflow failures: the lack of permissions and the inability of GITHUB_TOKEN to trigger downstream workflows. The switch to a Personal Access Token (PAT) via GH_TOKEN is the correct architectural solution for triggering the 'Squash and Wait' orchestrator.

ANTI-AI-SLOP DIRECTIVES

  1. OVERLY VERBOSE COMMENTS: None found. The scripts are concise.
  2. OVER-ENGINEERING: The "Validate Token" step, while useful, is pasted identically three times. For a workflow file, this increases maintenance burden.
  3. DUPLICATE HOOKS/TYPES: The GH_TOKEN environment variable definition is duplicated in every job.
  4. CODE RATIO: The PR adds ~50 lines. By hoisting the env definition to the workflow level, we can remove ~6 lines of repetitive configuration.
  5. STALE FEATURES: The PR removes the specific GITHUB_TOKEN env vars from steps, which is correct.

File-by-File Analysis

.github/workflows/e2e-ci-tests.yml

1. DRY Violation: Global Environment Variables

Problem: You define GH_TOKEN identically in test_pr_squash, test_conflict_resolver, and test_pr_squash_rebase. This violates the DRY principle and makes future updates to the token logic error-prone.

Implementation Sample:
Move the env block to the top level of the workflow, right after permissions:

permissions:
  contents: write
  pull-requests: write
  issues: write

env:
  GH_TOKEN: ${{ secrets.CI_BOT_PAT || secrets.ARI_PAT || secrets.GITHUB_TOKEN }}

jobs:
  test_pr_squash:
    # env: removed from here

2. Hardcoded Personal Secret Name

Problem: The secret ARI_PAT appears to be named after a specific user. While useful for immediate debugging, committing personal identifiers into shared CI configuration creates "bus factor" risks and confusion about ownership.

Recommendation: Standardize on CI_BOT_PAT or a generic E2E_TEST_PAT. If ARI_PAT is needed for transition, ensure it is documented as deprecated.

3. Robustness of Regex

Observation: The change from awk to grep -oE "[0-9]+$" is generally safe, but assumes gh pr create output contains only the URL with no trailing whitespace.

Best Practice: Ensure the gh command output is trimmed or the regex accounts for potential whitespace (though grep usually handles the line end anchor $ well against echo output).

Architectural Impact

  • Security: Granting contents: write and pull-requests: write to the entire workflow is broad but acceptable for this specific E2E testing context. Ensuring GH_TOKEN falls back to GITHUB_TOKEN prevents complete failure if PATs rotate, though functionality will degrade (orchestrators won't trigger).
  • Reliability: The explicit token validation step improves debuggability significantly.

Review automatically published via RepoAuditor.

@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 11, 2026

🤖 AI Technical Audit

Principal Architect Review

This PR correctly addresses the core CI failure by elevating permissions and utilizing a Personal Access Token (PAT) to ensure recursive workflow triggering. The shift from step-level GITHUB_TOKEN to job-level GH_TOKEN significantly reduces boilerplate.

🛡️ ANTI-AI-SLOP DIRECTIVES

  1. DUPLICATE HOOKS/TYPES: The Validate Token step is copy-pasted identically across three jobs (test_pr_squash, test_conflict_resolver, test_pr_squash_rebase). This violates DRY principles.
  2. CODE RATIO: The PR adds ~48 lines. You can remove the else block in the new Validate Token step (3 lines per instance = 9 lines total). We only need to know if it's missing; success is the default expected state.
  3. STALE FEATURES: The awk parsing logic is correctly removed and replaced by grep.
  4. OVER-ENGINEERING: The fallback logic for GH_TOKEN is complex but necessary for the requirement. However, the direct injection of secrets into the shell script is insecure (see below).

📁 File-by-File Analysis

.github/workflows/e2e-ci-tests.yml

Problem 1: unsafe Secret Injection
Injecting secrets directly into the run script using ${{ secrets... }} is risky. If the secret contains a double quote or special shell character, it can break the script syntax or lead to unintended behavior.

  • Location: Validate Token step (all 3 instances).
  • Current Code:
    if [ -z "${{ secrets.CI_BOT_PAT }}" ] ...
  • Recommended Fix: Map secrets to environment variables first.

Problem 2: Implicit Dependency on $GITHUB_ENV
You removed BRANCH_NAME: ${{ env.BRANCH_NAME }} from the Verify Squash and Cleanup steps. This is cleaner, but relies on BRANCH_NAME having been written to $GITHUB_ENV in the creation step. While PR_NUMBER is explicitly echoed to GITHUB_ENV in the diff, BRANCH_NAME is not shown in the diff context. Please verify BRANCH_NAME is indeed exported to $GITHUB_ENV in the Create Test Branch step, otherwise, subsequent steps will fail.

Problem 3: Trailing Slash Fragility
The regex grep -oE "[0-9]+$" expects the URL to end strictly in a number. If gh ever outputs a trailing slash (e.g., .../pull/123/), this regex will fail to match anything.

  • Recommended Fix: Allow for an optional trailing slash.
    grep -oE "[0-9]+/?$" | sed 's/\///g'
    # Or simpler given the context:
    grep -oE "[0-9]+"

🏗️ Architectural Impact

The move to GH_TOKEN at the job level is a best practice for this scenario. It ensures that all gh CLI commands within the job context share the same authentication authority, resolving the "workflow trigger" issue effectively.

✅ GitHub Checks

No checks found. Ensure this workflow runs successfully in a staging environment before merging, as permission changes can often behave differently between forks and base repositories.

Review automatically published via RepoAuditor.

@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 11, 2026

🤖 AI Technical Audit

Code Review: PR #7822 - CI Squash and Wait Fix

🛑 ANTI-AI-SLOP DIRECTIVES

  1. DUPLICATE HOOKS (Code Duplication): The Validate Token step is copy-pasted identically across three jobs (test_pr_squash, test_conflict_resolver, test_pr_squash_rebase). This adds maintenance burden and noise.
  2. CODE RATIO: The PR introduces ~20 lines of validation logic (shell scripts in YAML) that are purely informational. These should be removed to reduce verbosity. The failure mode (timeout or 403) is sufficient signal for engineers debugging CI.
  3. OVER-ENGINEERING: The conditional fallback logic for GH_TOKEN combined with a manual validation step is slightly redundant. Trust the environment variable expansion.

📂 File-by-File Analysis

.github/workflows/e2e-ci-tests.yml

1. Redundant Validation Logic (Problem)
The Validate Token step runs a shell script just to echo a warning or notice. This logic is repeated three times. In a CI environment, if the token is missing, the subsequent gh commands will fail or the test will time out, which provides the necessary signal without this boilerplate.

Implementation Sample (Proposed Deletion):

# REMOVE THIS BLOCK FROM ALL 3 JOBS
- name: Validate Token
  run: |
    if [ -z "${{ secrets.CI_BOT_PAT }}" ] && [ -z "${{ secrets.ARI_PAT }}" ]; then
      echo "::warning::Required PAT (CI_BOT_PAT or ARI_PAT) is missing..."
    else
      echo "::notice::Required PAT is present."
    fi

2. Robust Regex Implementation (Praise)
The switch from awk to grep is a good robustness improvement.

  • Old: awk -F'/' '{print $NF}' (Fragile to trailing slashes)
  • New: grep -oE "[0-9]+$" (Strictly matches trailing ID)

3. Environment Variable Scope (Best Practice)
Defining GH_TOKEN at the job level is the correct architectural choice here. It cleans up the individual steps.

env:
  GH_TOKEN: ${{ secrets.CI_BOT_PAT || secrets.ARI_PAT || secrets.GITHUB_TOKEN }}

Note: This hybrid approach ensures that gh CLI commands have the capacity to trigger downstream workflows (via PAT), while standard git operations handled by actions/checkout can still rely on the elevated GITHUB_TOKEN permissions defined at the top of the file.

4. Permission Scoping (Security)
The addition of global permissions is necessary but broad.

permissions:
  contents: write
  pull-requests: write
  issues: write

Given this is a dedicated E2E test workflow file, this scope is acceptable. However, verify that this workflow cannot be triggered by external forks in a way that abuses these write permissions (GitHub Actions generally protects against this by treating fork PRs with read-only tokens unless configured otherwise).

🏗 Architectural Impact

  • Event Chaining: The primary architectural fix here is enabling "Event Chaining". By using a PAT (CI_BOT_PAT) instead of GITHUB_TOKEN, the comments created by this test suite will successfully trigger on: issue_comment or on: pull_request workflows. This is critical for E2E testing bots/orchestrators.

✅ GitHub Checks Status

  • Status: No checks found.
  • Correlation: Since this PR modifies the CI workflow itself, manual verification or a self-test run is required to ensure the syntax changes (specifically the GH_TOKEN expansion) are valid.

Review automatically published via RepoAuditor.

@arii arii added the ci label Feb 11, 2026
- Hoisted GH_TOKEN to the top-level env block for better DRY compliance.
- Secured secret validation by mapping CI_BOT_PAT and ARI_PAT to step-level env vars.
- Improved PR number extraction regex to handle potential trailing slashes.
- Simplified token validation by removing redundant else blocks and logging.
- Maintained fail-fast warning behavior to support fork PRs.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 11, 2026

Reviewed commit: aba424423001f41a585009a893cbd9c7dfe2ea08

This PR introduces targeted improvements to the E2E CI workflows, specifically addressing potential failures in the squash, wait, and conflict resolution tests. The changes enhance the robustness and reliability of these critical CI steps.

Strengths

  • Improved Token Handling: Centralizing the GH_TOKEN environment variable and providing fallback options (CI_BOT_PAT, ARI_PAT, GITHUB_TOKEN) makes token management more flexible and resilient. Removing redundant env blocks from individual steps reduces verbosity.
  • Robust PR Number Extraction: The update to grep and sed for extracting the PR number is more robust than the previous awk command, preventing potential failures due to variations in URL structure.
  • Enhanced Debugging: The new "Validate Token" step provides a clear warning if critical PATs are missing, which is highly beneficial for debugging workflow failures related to permissions.
  • Necessary Permissions: Explicitly defining contents: write, pull-requests: write, and issues: write permissions at the workflow level ensures that the gh commands have the necessary access to create and manage PRs and branches.

Verdict

This PR significantly improves the stability of the E2E CI workflows. The changes are well-implemented and directly address the stated goal of resolving workflow failures. No new issues or regressions were introduced. Verified that the token handling is more robust and PR number extraction is more reliable. Ready for approval.

Reviewed at commit: aba424423001f41a585009a893cbd9c7dfe2ea08

- Ensured all environment variables (BRANCH_NAME, PR_NUMBER, etc.) are explicitly mapped in steps.
- Hardened PR number extraction using tail -n 1 to handle any output variations.
- Maintained global GH_TOKEN and explicit permissions for event chaining.
- Cleaned up redundant validation boilerplate while preserving security best practices.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 11, 2026

Reviewed commit: e8cd3af05cc95395cd2111b5fb4d123c36e2241a

This PR effectively resolves the CI Squash and Wait workflow failure by implementing several key improvements to the .github/workflows/e2e-ci-tests.yml file.

Strengths

  • Centralized Token Management: The introduction of a global GH_TOKEN environment variable with fallback options (secrets.CI_BOT_PAT || secrets.ARI_PAT || secrets.GITHUB_TOKEN) significantly enhances the security and maintainability of the workflow. This reduces redundancy and simplifies token management across multiple steps.
  • Improved Shell Scripting Robustness: The consistent use of double quotes for shell variables (e.g., "$BRANCH_NAME", "$PR_NUMBER") prevents potential issues with word splitting and globbing, making the workflow scripts more reliable and less prone to unexpected failures.
  • Accurate PR Number Extraction: The corrected method for extracting the PR_NUMBER using grep -oE "[0-9]+" | tail -n 1 is more robust and resilient to variations in GitHub PR URL structures, directly addressing a likely cause of the previous workflow failures.
  • Explicit Permissions: Clearly defining permissions at the workflow level (contents: write, pull-requests: write, issues: write) is a good security practice, ensuring the workflow operates with the minimum necessary privileges.

Issues

No issues were found with the proposed changes. The modifications are precise, directly address the problem, and improve the overall quality of the CI workflow.

Verdict

This PR is well-executed, directly addresses the reported CI failure, and improves the robustness and security of the workflow. It is ready for approval.

Reviewed at commit: e8cd3af05cc95395cd2111b5fb4d123c36e2241a

@arii arii added the bug-fix label Feb 11, 2026
- Implemented global GH_TOKEN with PAT fallback (CI_BOT_PAT, ARI_PAT) to enable triggering downstream workflows.
- Added explicit workflow permissions (contents: write, pull-requests: write, issues: write).
- Refactored all E2E jobs to use explicit environment variable mapping for BRANCH_NAME and PR_NUMBER, ensuring persistence across steps.
- Hardened PR number extraction logic using robust text parsing and processing for resilience.
- Improved shell script safety by double-quoting variables and cleaned up redundant boilerplate validation.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 11, 2026

Reviewed commit: f848c254d790ee8075225de45aba1899063d69cc

This PR effectively resolves the CI Squash and Wait workflow failure by enhancing the robustness and security of the GitHub Actions workflows. The changes centralize token management, improve shell script reliability, and clarify permissions.

Strengths

  • Centralized Token Management: The introduction of a global env block for GH_TOKEN with a clear priority order (CI_BOT_PAT, ARI_PAT, GITHUB_TOKEN) significantly improves security and maintainability. It reduces redundancy by removing GITHUB_TOKEN declarations from individual steps.
  • Explicit Permissions: Adding the permissions block at the workflow level is a good practice, explicitly defining the necessary access for the workflow to function.
  • Robust Shell Scripting: Using double quotes around shell variables (e.g., "$BRANCH_NAME", "$PR_NUMBER") prevents potential word splitting and globbing issues, making the scripts more reliable.
  • Improved PR Number Extraction: The updated PR_NUMBER extraction logic (grep -oE "[0-9]+" | tail -n 1) is more robust than the previous awk command, ensuring correct parsing of PR URLs.
  • Technical Debt Acknowledgment: The comment regarding the deprecation of secrets.ARI_PAT is a good practice for tracking and planning future cleanup.

Test Coverage

The changes are within a GitHub Actions workflow file, which itself serves as a test for CI functionality. The workflow's purpose is to test other CI orchestrators (squash, conflict resolver), and the modifications directly address issues within these tests. Therefore, the "Test Coverage Alert" is not applicable in the context of application code testing.

Reviewed at commit: f848c254d790ee8075225de45aba1899063d69cc

- Added 'Validate Token' step to fail fast if PAT is missing.
- Added explicit validation for extracted PR_NUMBER to prevent silent failures.
- Unified PAT fallback logic across all E2E jobs.
- Cleaned up step-level env definitions to follow DRY principles.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 11, 2026

Reviewed commit: c91656474dee5826e01b44181efedc6f21686af3

This pull request effectively resolves the CI Squash and Wait workflow failure by implementing several key improvements to the .github/workflows/e2e-ci-tests.yml file. The changes enhance the robustness, security, and maintainability of the E2E testing pipeline.

Strengths

  • Improved Token Handling: The introduction of a GH_TOKEN environment variable with a clear fallback mechanism (CI_BOT_PAT || ARI_PAT || GITHUB_TOKEN) ensures that the workflow consistently uses the most appropriate token for triggering downstream actions. The deprecation note for ARI_PAT is a good practice for future maintenance.
  • Robust Token Validation: The new Validate Token step proactively checks for the presence of required Personal Access Tokens (PATs). This prevents silent failures and provides immediate feedback if the workflow lacks the necessary permissions to interact with GitHub APIs, which is crucial for recursive workflow triggers.
  • Enhanced Shell Script Robustness: Consistent quoting of shell variables (e.g., "$BRANCH_NAME", "$PR_NUMBER") throughout the workflow's run steps significantly improves the reliability of the scripts. This prevents potential issues with word splitting or globbing, making the commands more predictable.
  • Reliable PR Number Extraction: The method for extracting the PR number from the URL has been improved from awk to grep -oE "[0-9]+" | tail -n 1. This is a more resilient approach that specifically targets the numerical PR ID, reducing fragility against potential URL format changes.
  • Code Cleanup: Redundant GITHUB_TOKEN environment declarations within individual steps have been removed, leading to a cleaner and more concise workflow definition.

Verdict

The changes are well-executed, directly address the stated problem, and improve the overall quality of the CI workflow. No new issues or regressions were introduced.

✅ Verified that the token handling is more robust, variable quoting is consistent, and PR number extraction is more reliable. No regressions found. Ready for approval.

Reviewed at commit: c91656474dee5826e01b44181efedc6f21686af3

- Added 'Validate Token' step to fail fast if PAT is missing.
- Added explicit validation for extracted PR_NUMBER to prevent silent failures.
- Unified PAT fallback logic across all E2E jobs.
- Cleaned up step-level env definitions to follow DRY principles.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 11, 2026

Reviewed commit: 78357a176bdc68299e348b11c37b96ce89b17451

Review Summary

This PR effectively resolves the CI Squash and Wait workflow failure by enhancing the robustness and reliability of the E2E test workflows. The changes primarily focus on improving GitHub token handling, adding explicit token validation, and refining shell scripting practices within the workflow definitions.

Strengths

  • Improved Token Handling: The introduction of a prioritized GH_TOKEN environment variable (CI_BOT_PAT || ARI_PAT || GITHUB_TOKEN) at the job level, combined with the removal of redundant GITHUB_TOKEN declarations in individual steps, significantly streamlines token management and aligns with best practices for GitHub Actions.
  • Explicit Token Validation: The added Validate Token step ensures that a valid Personal Access Token (PAT) is present before attempting to trigger downstream workflows. This prevents silent failures and provides clear error messages, improving debugging.
  • Robust PR Number Extraction: The change from awk to grep -oE "[0-9]+" | tail -n 1 for extracting the PR number is more resilient to potential variations in PR URL formats.
  • Enhanced Shell Scripting: Consistent quoting of shell variables (e.g., "$BRANCH_NAME") prevents unexpected word splitting or globbing, making the scripts more robust and less prone to errors.
  • Clear Deprecation Notice: The comment regarding secrets.ARI_PAT is a good practice for documenting technical debt and guiding future updates.

Issues

No blocking issues found. The changes are well-implemented and directly address the stated problem.

Test Coverage

This PR modifies a GitHub Actions workflow file, which does not typically have associated unit or integration tests in the traditional sense. The workflow itself serves as a form of E2E test for the PR squash/rebase/conflict resolution features. The changes improve the reliability of these E2E tests.

Recommendations

None, the changes are solid.

Verdict

approve

Reviewed at commit: 78357a176bdc68299e348b11c37b96ce89b17451

- Mapped secrets to environment variables in 'Validate Token' steps to avoid unsafe shell injection.
- Removed success messages in 'Validate Token' steps to reduce CI log noise, following architectural recommendations.
- Ensured all shell variables remain double-quoted for robustness.
- Re-verified regex-based PR number extraction.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 11, 2026

🤖 AI Technical Audit

Code Review: CI Workflow Enhancements for Squash & Wait

This PR effectively addresses the permission issues and token scope limitations preventing the 'Squash and Wait' workflow from triggering downstream actions. By implementing a PAT-based authentication strategy (GH_TOKEN with fallback) and explicit permission scopes, it ensures the E2E tests function as intended.

However, the implementation introduces significant code duplication across the three test jobs and includes redundant environment variable mappings that clutter the workflow file.

⛔ ANTI-AI-SLOP DIRECTIVES

  1. CODE RATIO (Redundant env blocks):
    You are mapping environment variables in the env: block of individual steps (e.g., PR_NUMBER: ${{ env.PR_NUMBER }}) that are already available in the shell environment because they were written to $GITHUB_ENV in previous steps. This adds ~15 lines of noise across the file. Delete these blocks.

  2. DUPLICATE LOGIC (Token Validation):
    The "Validate Token" step is copy-pasted identically into three separate jobs. While a composite action might be overkill for a quick fix, this highlights the need for refactoring these nearly identical jobs into a Matrix strategy or a Reusable Workflow in the future.

  3. STALE FEATURES:
    The PR correctly removes the brittle awk parsing logic in favor of grep. This is verified.

File-by-File Analysis

.github/workflows/e2e-ci-tests.yml

1. Redundant Environment Mapping (Problem)
Variables written to $GITHUB_ENV are automatically available to subsequent steps in the same job. explicitly re-declaring them in the env section using ${{ env.VAR }} is unnecessary.

  • Location: Trigger PR Squash and Wait step (and similar steps in other jobs).
  • Recommendation: Remove the env block entirely for these variables.
# Current (Verbose)
- name: Trigger PR Squash and Wait
  env:
    PR_NUMBER: ${{ env.PR_NUMBER }} # ❌ Redundant
  run: |
    gh pr comment "$PR_NUMBER" ...

# Recommended (Clean)
- name: Trigger PR Squash and Wait
  # env block removed; $PR_NUMBER is already in the environment
  run: |
    gh pr comment "$PR_NUMBER" ...

2. Token Validation & Logic Coupling (Architectural Impact)
The GH_TOKEN definition at the top level uses a fallback chain (CI_BOT_PAT || ARI_PAT || GITHUB_TOKEN). The validation step manually checks CI_BOT_PAT and ARI_PAT. If you ever add a third PAT option to the top-level GH_TOKEN, you must remember to update the validation logic in three places. This coupling is brittle.

3. Regex Robustness (Best Practice)
The switch to grep -oE "[0-9]+" | tail -n 1 is an improvement over awk, but strictly speaking, it assumes the PR number is the last number in the URL. If gh output changes to include metadata with numbers at the end, this breaks.

  • Better Regex: grep -oE "/pull/[0-9]+" | grep -oE "[0-9]+" (ensures the number is actually part of the pull path).
  • Note: The current implementation is likely acceptable for gh pr create output, but be aware of this edge case.

4. Security (Best Practice)
Good job adding permissions: contents: write etc. This adheres to the principle of least privilege for the default token, while explicitly elevating the CLI operations via the PAT.

GitHub Checks Status

No checks found (as per prompt context). However, ensure the new PAT secrets (CI_BOT_PAT) are actually present in the repository secrets, otherwise, the new validation step will immediately fail the build.

Review automatically published via RepoAuditor.

@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 11, 2026

Reviewed commit: 909ae2e7d4828730137e94589c0a938300ce7d5a

This PR effectively resolves the CI Squash and Wait workflow failure by implementing several crucial improvements to the .github/workflows/e2e-ci-tests.yml file.

Strengths

  • Robust Token Handling: The introduction of a global GH_TOKEN with a clear fallback mechanism (CI_BOT_PAT > ARI_PAT > GITHUB_TOKEN) and an explicit validation step (Validate Token) significantly enhances the reliability of GitHub CLI commands within the workflow. This directly addresses the root cause of previous failures related to insufficient permissions.
  • Improved Shell Scripting: Consistent use of double quotes for shell variables (e.g., "$BRANCH_NAME", "$PR_NUMBER") prevents potential issues with whitespace or special characters, making the workflow more robust.
  • Reliable PR Number Extraction: The updated PR_NUMBER extraction logic using grep -oE "[0-9]+" | tail -n 1 combined with a null check ensures that the PR number is correctly identified, preventing subsequent steps from failing.
  • Necessary Permissions: Adding contents: write, pull-requests: write, and issues: write permissions is essential for an E2E workflow that creates, comments on, and closes PRs, ensuring the workflow has the capabilities it needs.

Issues

No blocking issues were found. The changes are well-implemented and directly address the reported CI failures.

Test Coverage

This PR modifies a CI workflow, which itself is a form of testing. The changes are designed to make the E2E tests run reliably, and no additional unit/integration tests are applicable for this type of change.

Verdict

✅ Verified the changes. The PR correctly addresses the CI workflow failure and improves the robustness of the E2E tests. Ready for approval.

Reviewed at commit: 909ae2e7d4828730137e94589c0a938300ce7d5a

- Secured 'Validate Token' steps by mapping secrets to environment variables.
- Removed informational success messages to reduce CI log noise.
- Verified all shell variables are double-quoted for security and reliability.
- Confirmed resilient regex-based PR number extraction with safety checks.
- Addressed all technical audit feedback regarding DRY and secure coding practices.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 11, 2026

🤖 AI Technical Audit

Code Review: PR #7822 - Resolve CI Squash and Wait workflow failure

This is a solid infrastructure fix that correctly identifies and resolves the root cause of the CI failures (permissions and token scope). The move to explicit permissions and GH_TOKEN configuration is excellent. However, there are opportunities to make the script logic significantly more robust by leveraging native CLI features rather than text parsing.

ANTI-AI-SLOP DIRECTIVES

  1. OVERLY VERBOSE COMMENTS: None found. The comments explaining GH_TOKEN priority are necessary context.
  2. OVER-ENGINEERING: The manual string parsing (grep | tail) for the PR number is arguably over-engineered compared to using the tool's native JSON output.
  3. DUPLICATE HOOKS/TYPES: The "Validate Token" step is copied identically across three jobs (test_pr_squash, test_conflict_resolver, test_pr_squash_rebase). This violates DRY principles.
  4. CODE RATIO: By switching to gh ... --json number, you can remove approximately 15-20 lines of code related to URL parsing and error checking across the three jobs.
  5. STALE FEATURES: The awk parsing logic is correctly replaced, though the replacement itself can be improved.

File-by-File Analysis

.github/workflows/e2e-ci-tests.yml

1. Fragile PR Number Extraction (Problem)
Parsing the standard output (URL) of the gh CLI using grep and tail is brittle. If the repository name contains numbers or the output format changes (e.g., warnings are printed to stdout), this logic may fail or capture the wrong ID.

Implementation Sample (Recommended):
Use the native --json and --jq flags provided by the GitHub CLI. This guarantees you get exactly the number field, removing the need for PR_URL variables and regex parsing.

# Replace the PR_URL, PR_NUMBER, and error checking block with:
run: |
  # ... existing git setup ...
  PR_NUMBER=$(gh pr create --title "E2E Test PR" --body "Test PR" --base leader --head "$BRANCH_NAME" --json number --jq ".number")
  
  echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
  echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT

2. Robustness of Cleanup Step (Problem)
The Cleanup step runs if: always(). If the job fails before the PR is created (e.g., during git push), the PR_NUMBER environment variable might be empty. Running gh pr close "" will result in an error, potentially masking the original failure reason in the logs or causing confusion.

Implementation Sample:
Add a check to ensure variables exist before attempting operations.

if [[ -n "$PR_NUMBER" ]]; then
  gh pr close "$PR_NUMBER"
fi
if [[ -n "$BRANCH_NAME" ]]; then
  git push origin --delete "$BRANCH_NAME" || true # Prevent fail if branch doesn't exist
fi

3. Code Duplication (Architecture)
The "Validate Token" step is identical in all three jobs. While acceptable for this small fix, for long-term maintenance, consider moving common setup steps to a local composite action (e.g., .github/actions/e2e-setup) to reduce noise and duplication in the main workflow file.

Architectural Impact

  • Security: The addition of the permissions block follows the principle of least privilege, which is a significant improvement.
  • Reliability: Switching to a PAT for GH_TOKEN ensures downstream workflows (like the Gemini Orchestrator) trigger correctly, fixing the core architectural blocker.

GitHub Checks Validation

No checks were provided in the prompt, but the changes to permissions and GH_TOKEN are standard fixes for the described 403 and "workflow not triggering" issues. The logic is sound assuming secrets.CI_BOT_PAT exists.

Review automatically published via RepoAuditor.

- Mapped secrets to environment variables in 'Validate Token' steps to avoid unsafe shell injection.
- Consolidated 'Validate Token' step across all jobs for consistency.
- Ensured all shell variables remain double-quoted for robustness.
- Verified regex-based PR number extraction with explicit safety checks.
- Addressed technical audit feedback regarding DRY and secure coding practices.
- Fixed duplication errors in previous commit.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 12, 2026

🤖 AI Technical Audit

Deep Code Review: PR #7822

This PR correctly identifies the root cause of the CI failure (permissions and token scope) but introduces unnecessary boilerplate and brittle text parsing logic that ignores existing CLI capabilities.

⚠️ ANTI-AI-SLOP DIRECTIVES ⚠️

  1. OVER-ENGINEERING (Regex vs. Native JSON): The switch from awk to grep regex for extracting the PR number is a brittle workaround. The gh CLI natively supports JSON output. Using text processing tools (grep, awk, cut) on structured CLI data is an anti-pattern.
  2. CODE RATIO / DUPLICATION: The "Validate Token" step (9 lines) is copy-pasted identically across three jobs (test_pr_squash, test_conflict_resolver, test_pr_squash_rebase). This adds ~27 lines of maintenance burden. This check should either be a prerequisite job or simply allowed to fail naturally at the gh command step with a clearer error message.
  3. LOGIC CONTRADICTION: You define GH_TOKEN with a fallback to secrets.GITHUB_TOKEN (... || secrets.GITHUB_TOKEN), but then immediately add a Validation Step that exit 1 if the PATs are missing. This makes the || secrets.GITHUB_TOKEN fallback dead code in the context of this workflow. If the validation passes, the fallback is never reached; if it fails, the script exits.

File-by-File Analysis

.github/workflows/e2e-ci-tests.yml

1. Problem: Brittle PR Number Extraction
Parsing the URL output of gh pr create is fragile. If the repository name contains numbers or the output format changes, grep -oE "[0-9]+" | tail -n 1 may yield incorrect results.

Implementation Sample (Best Practice):
Use the --json and --jq flags to get the number directly.

# Remove grep/tail logic entirely
- PR_URL=$(gh pr create ...)
- PR_NUMBER=$(echo "$PR_URL" | grep ...)
# Replace with:
- PR_NUMBER=$(gh pr create --title "..." --body "..." --base leader --head "$BRANCH_NAME" --json number --jq '.number')

2. Problem: Repetitive Token Validation
The manual check for CI_BOT_PAT is WET (Write Everything Twice). Since you have set GH_TOKEN globally with a priority chain, the gh command will fail with a standard authentication error if no valid token is present. The custom validation adds lines without significant value over the standard error.

Recommendation:
Remove the "Validate Token" steps entirely. If GH_TOKEN resolves to empty or an invalid token, the gh pr create step will fail, which is sufficient for CI failure signaling.

3. Problem: Global Permission Scope

permissions:
  contents: write
  pull-requests: write
  issues: write

While necessary for GITHUB_TOKEN operations, granting write on contents and issues globally is broad. Since you are shifting to use a PAT (CI_BOT_PAT) for the interactions that matter, verify if you can scope these permissions down to specific jobs or if they are only needed as a fallback.

4. Security Note: Environment Variable Injection
In your env block:

GH_TOKEN: ${{ secrets.CI_BOT_PAT || secrets.ARI_PAT || secrets.GITHUB_TOKEN }}

This injects the highly privileged PAT into the environment of every step in the workflow. While common in E2E tests, ensure that no untrusted code (e.g., from npm install scripts in the checked-out PR) runs in this workflow. Since this is a test on the leader branch or trusted PRs, it is acceptable, but be aware of the risk.

Summary

This PR fixes the issue but needs cleanup. Please switch to gh ... --json for robustness and remove the repetitive validation steps to improve the code ratio.

Review automatically published via RepoAuditor.

- Refactored PR number extraction to use 'gh pr create ... --json number --jq ".number"'.
- Removed redundant 'Validate Token' steps to follow DRY and improve code ratio.
- Hardened 'Cleanup' steps with existence checks for PR_NUMBER and BRANCH_NAME.
- Ensured consistent double-quoting of shell variables.
- Maintained global GH_TOKEN fallback with PAT priority for downstream triggers.
- Verified all changes pass linting and unit tests.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 12, 2026

Reviewed commit: cc9c1c37cf69555c6fe95dc37e68ab35ceb4046d

This PR significantly improves the robustness and security of the E2E CI workflows by addressing several key areas. The changes are well-justified and contribute to a more stable and maintainable CI pipeline.

Strengths

  • Explicit Permissions: The addition of a permissions block (contents: write, pull-requests: write, issues: write) explicitly defines the necessary permissions for the workflow, adhering to the principle of least privilege and improving security.
  • Centralized Token Management: The introduction of a global GH_TOKEN environment variable with a clear fallback mechanism (CI_BOT_PAT || ARI_PAT || GITHUB_TOKEN) centralizes token handling. This reduces redundancy and makes the workflow easier to manage.
  • Improved Shell Script Robustness: Variables in shell commands are now properly quoted (e.g., "$BRANCH_NAME"), preventing unexpected behavior due to spaces or special characters. This is a critical best practice for shell scripting.
  • Robust PR Number Extraction: The gh pr create command now uses --json number --jq ".number" for direct and reliable extraction of the PR number, which is more resilient than string parsing.
  • Resilient Cleanup: The cleanup steps now include conditional checks (if [[ -n "$PR_NUMBER" ]]) before attempting to close PRs or delete branches, and uses || true for git push --delete. This prevents cleanup failures if earlier steps did not fully succeed, making the workflow more fault-tolerant.
  • Code Clarity: The removal of redundant GITHUB_TOKEN environment variables from individual steps, thanks to the global GH_TOKEN definition, makes the workflow definition cleaner and easier to read.

Suggested Improvements

  • Deprecation of ARI_PAT: The comment correctly identifies secrets.ARI_PAT as legacy. While the CI_BOT_PAT is prioritized, a clear plan or issue to fully transition away from ARI_PAT and eventually remove it would be beneficial for long-term security and maintainability.

Verdict

This PR is a solid improvement to the CI infrastructure. The changes enhance security, reliability, and maintainability without introducing new issues.

Reviewed at commit: cc9c1c37cf69555c6fe95dc37e68ab35ceb4046d

- Refactored PR number extraction to use native 'gh pr create ... --json number --jq ".number"'.
- Removed redundant 'Validate Token' steps to follow DRY and improve code ratio.
- Hardened 'Cleanup' steps with existence checks for PR_NUMBER and BRANCH_NAME to prevent failures on partial job runs.
- Ensured consistent double-quoting of shell variables across all scripts.
- Maintained global GH_TOKEN fallback with PAT priority for downstream trigger support.
- Verified all changes pass linting and unit tests.

This version incorporates all architectural and technical audit feedback.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 12, 2026

Reviewed commit: 5a3180aac9a6cfc89882f05b5e6dc2bc60860949

This PR addresses critical reliability issues in the E2E CI workflows, specifically for the squash and wait, and conflict resolver tests. The changes significantly improve the robustness and correctness of these workflows.

Strengths

  • Improved Robustness: The workflow now correctly quotes shell variables (e.g., "$BRANCH_NAME"), preventing potential issues with word splitting and globbing in branch names or other dynamic values. This is a fundamental shell scripting best practice.
  • Reliable PR Number Extraction: The use of gh pr create ... --json number --jq ".number" is a significant improvement over parsing the PR URL string. This makes the extraction of the PR number much more reliable and less prone to breakage if the GitHub CLI output format changes.
  • Centralized Token Management: Consolidating the GH_TOKEN definition at the job level with a robust fallback mechanism (secrets.CI_BOT_PAT || secrets.ARI_PAT || secrets.GITHUB_TOKEN) enhances security and maintainability by reducing redundancy and ensuring the correct token is always used.
  • Resilient Cleanup: The cleanup steps now conditionally close PRs and delete branches only if the relevant variables (PR_NUMBER, BRANCH_NAME) are set. Additionally, using || true for git push origin --delete makes the cleanup more fault-tolerant, preventing the workflow from failing if a branch has already been deleted.
  • Net Zero Lines Changed: The PR achieves significant improvements in reliability and correctness without increasing the overall lines of code, aligning with the "Less code, more clarity" guiding principle.

Suggested Issues

  • Title: Remove legacy ARI_PAT from CI workflows
  • Description: The e2e-ci-tests.yml workflow still references secrets.ARI_PAT as a fallback for GH_TOKEN, with a deprecation note. This legacy PAT should be fully removed once secrets.CI_BOT_PAT is confirmed to be stable and in full use, to streamline token management and remove deprecated credentials.
  • Type: technical-debt
  • Priority: medium

Verdict

✅ Verified that the changes correctly resolve the CI workflow failures by improving shell scripting practices, token management, and cleanup logic. No regressions or new issues were introduced. The PR is ready for approval.

Reviewed at commit: 5a3180aac9a6cfc89882f05b5e6dc2bc60860949

@arii arii added the e2e-tests label Feb 12, 2026
…cleanup

- Refactored PR number extraction to use native 'gh pr create ... --json number --jq ".number"'.
- Hardened 'Cleanup' steps with existence checks for PR_NUMBER and BRANCH_NAME.
- Removed redundant validation boilerplate to improve code ratio.
- Maintained global GH_TOKEN fallback with PAT priority for downstream triggers.
- Verified all changes pass linting and unit tests.

This commit addresses all feedback from recent architect reviews and technical audits.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 12, 2026

Reviewed commit: 03d918c3788286dc0ca40c8c353005675f8b16b2

This PR effectively resolves the CI Squash and Wait workflow failures by enhancing the robustness and reliability of the E2E test workflow. The changes are well-executed and align with best practices for GitHub Actions.

Strengths

  • Explicit Permissions: The addition of permissions block is a significant security improvement, explicitly granting only necessary permissions for the workflow to interact with contents, pull requests, and issues.
  • Centralized GH_TOKEN Management: Defining GH_TOKEN globally with a clear fallback mechanism (CI_BOT_PAT || ARI_PAT || GITHUB_TOKEN) centralizes token management and improves clarity. The deprecation comment for ARI_PAT is also a good practice.
  • Robust Shell Scripting: Quoting shell variables ("$BRANCH_NAME", "$PR_NUMBER") in run steps prevents unexpected behavior due to word splitting or globbing, making the workflow more resilient.
  • Improved PR Number Extraction: Using --json number --jq ".number" for gh pr create is more reliable than awk for extracting the PR number.
  • Resilient Cleanup: The conditional cleanup logic (if [[ -n "$PR_NUMBER" ]]) and the addition of || true to git push origin --delete commands ensure that cleanup steps do not fail the workflow if previous steps (like PR creation or branch push) encountered issues. This significantly improves the workflow's stability.
  • DRY Principle: Removing redundant GITHUB_TOKEN environment definitions from individual steps, now that GH_TOKEN is defined globally, adheres to the DRY principle and makes the workflow more concise.

Issues

No blocking issues found. The changes are solid and directly address the stated problem.

Test Coverage

The changes are to a CI workflow file, which itself orchestrates E2E tests. The modifications improve the reliability of these orchestration steps. The "Test Coverage Alert" is not applicable in this context as no application source code was modified.

Verdict

✅ Verified the changes improve the robustness and reliability of the CI E2E test workflows. No regressions or new issues found. Ready for approval.

Reviewed at commit: 03d918c3788286dc0ca40c8c353005675f8b16b2

- Refactored PR number extraction to use native 'gh pr create ... --json number --jq ".number"'.
- Removed redundant 'Validate Token' steps to follow DRY and improve code ratio.
- Hardened 'Cleanup' steps with existence checks for PR_NUMBER and BRANCH_NAME to prevent failures on partial job runs.
- Ensured consistent double-quoting of shell variables across all scripts.
- Removed redundant environment variable mappings for variables already in $GITHUB_ENV.
- Maintained global GH_TOKEN fallback with PAT priority for downstream trigger support.
- Verified all changes pass linting and unit tests.

This version incorporates all architectural and technical audit feedback, including recent nitpicks regarding redundant environment mappings.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
@arii
Copy link
Copy Markdown
Owner Author

arii commented Feb 12, 2026

Reviewed commit: f540730857ffa2c51ac080fdbcb6f3fd6b76f633

This PR significantly improves the robustness and reliability of the E2E CI workflows. The changes address potential points of failure and enhance the security posture by centralizing token management and explicitly defining permissions.

Strengths

  • Improved Token Management: Centralizing GH_TOKEN definition and prioritizing CI_BOT_PAT over ARI_PAT is a good step towards better security and maintainability. Explicit permissions are also correctly defined.
  • Robust PR Number Extraction: Switching to gh pr create ... --json number --jq ".number" is more reliable than parsing the URL, reducing potential script failures.
  • Defensive Cleanup: Adding checks (if [[ -n "$VAR" ]]) before closing PRs or deleting branches, and using || true for git push --delete commands, makes the cleanup steps more resilient to previous failures.
  • Shell Scripting Best Practices: Quoting shell variables ("$BRANCH_NAME") prevents unexpected behavior due to spaces or special characters.

Suggested Issues

  • Title: Fully deprecate and remove ARI_PAT from CI workflows
    • Description: The GH_TOKEN environment variable now prioritizes secrets.CI_BOT_PAT and notes secrets.ARI_PAT as legacy. A follow-up task is needed to ensure CI_BOT_PAT is fully configured and then remove all references to secrets.ARI_PAT from the workflow, including the deprecation comment.
    • Type: technical-debt
    • Priority: medium

Reviewed at commit: f540730857ffa2c51ac080fdbcb6f3fd6b76f633

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: arii <342438+arii@users.noreply.github.com>
@arii arii marked this pull request as ready for review February 13, 2026 08:48
@arii arii closed this Feb 13, 2026
@arii arii deleted the fix/ci-squash-failure-16189483617843542037 branch February 17, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: Investigate and resolve 'Trigger PR Squash and Wait' workflow execution failure

1 participant