Skip to content

ci: harden Gradle caches, handle no-op auto-fix edits, and test create_pr.py - #1093

Merged
kikoso merged 2 commits into
mainfrom
ci/auto-fix-followups
Nov 24, 2026
Merged

kikoso merged 2 commits into
mainfrom
ci/auto-fix-followups

Conversation

@dkhawk

@dkhawk dkhawk commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #1090 addressing defense-in-depth validation isolation, remaining cache-poisoning exposure, no-op edit edge cases, job timeouts, and unit test coverage for create_pr.py.

Changes

  • Isolate --verify-applied validator in publish:
    • .github/workflows/auto-fix.yml: copy .github/scripts/create_pr.py to $RUNNER_TEMP/verify_create_pr.py before running git apply -- "$PATCH" and invoke Python in isolated mode (python -I), so a tampered patch cannot overwrite the validator or shadow stdlib modules in .github/scripts/ or the repository root.
  • Close cache-poisoning exposure in remaining credentialed workflows: Set cache-disabled: true on gradle/actions/setup-gradle in:
    • .github/workflows/coverage-history.yml (persists SYNCED_GITHUB_TOKEN_REPO in coverage-data/.git/config before Gradle runs on every push to main)
    • .github/workflows/baseline-profiles.yml (holds ACTIONS_API_KEY and SYNCED_GITHUB_TOKEN_REPO)
    • .github/workflows/instrumentation-test.yml (holds ACTIONS_API_KEY and SYNCED_GITHUB_TOKEN_REPO)
    • .github/workflows/demo-smoke-test.yml (holds ACTIONS_API_KEY)
  • Handle no-op edits and empty patches:
    • .github/scripts/create_pr.py: skip writing/recording files whose generated content is identical to existing disk content, avoiding mismatches between pr_metadata.json and git diff during --verify-applied.
    • .github/workflows/auto-fix.yml: fail fast in Package Patch if autofix.patch is empty so compile doesn't fail at git apply and trigger a misleading compilation-failure comment.
  • Bound job runtimes & clarify generate permissions:
    • .github/workflows/auto-fix.yml: add explicit timeout-minutes (15/20/10) to generate, compile, and publish.
    • .github/workflows/auto-fix.yml & .github/scripts/create_pr.py: clarify comments to reflect contents:read and issues:write (used for early branch-exists notices).
  • Add unit tests for create_pr.py: Added stdlib-only .github/scripts/test_create_pr.py covering idempotent sanitization, path sandboxing, --verify-applied (including isolated python -I tamper/shadow-module resistance), and partial/full/create no-op filtering, and wired it into .github/workflows/test.yml (python3 -B -m unittest).

Verification

  • python3 -B -m unittest discover -s .github/scripts -p 'test_*.py' -v — 14/14 passed
  • Validated YAML syntax across all 15 .github/workflows/*.yml files
  • Ran .github/scripts/check_agent_leftovers.py — clean

…e_pr.py

Follow-up to #1090:

- Disable Gradle cache restoration (cache-disabled: true) in remaining
  credentialed workflows (coverage-history.yml, baseline-profiles.yml,
  instrumentation-test.yml, and demo-smoke-test.yml) so jobs holding
  SYNCED_GITHUB_TOKEN_REPO or ACTIONS_API_KEY never restore main cache
  entries written from the auto-fix compile context.
- Skip recording unchanged files in create_pr.py and fail fast on empty
  patches in auto-fix.yml so partial or full no-op edits do not break
  git apply in compile or --verify-applied in publish.
- Clarify generate job permissions (contents:read + issues:write) in
  auto-fix.yml and create_pr.py comments.
- Add stdlib unit tests for create_pr.py (.github/scripts/test_create_pr.py)
  and run them in test.yml.
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Coverage (unit tests)

Compared against f88706f on main (#1092).

Module Line % Change Branch % Change
maps-compose 15.32% no change 3.97% no change
maps-compose-utils 26.29% no change 12.70% no change
maps-compose-widgets 3.87% no change 0.00% no change
TOTAL 17.38% no change 5.62% no change

Line and branch coverage from unit test reports. History is recorded on the coverage-history branch after each merge to main.

@dkhawk
dkhawk marked this pull request as ready for review November 24, 2026 00:18
@dkhawk
dkhawk requested review from a team and kikoso as code owners November 24, 2026 00:18
@dkhawk
dkhawk requested a review from LoyalAbbas November 24, 2026 00:18
@googlemaps-bot

googlemaps-bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Coverage (instrumentation tests)

Overall Project 45.95% 🍏

There is no coverage information present for the Files changed

- name: Checkout Repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Run GitHub script unit tests

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

My two cents: this job still restores the main Gradle cache while holding a pull-requests: write token for the coverage comment. The impact is small, but should we disable the cache here too, for consistency with the other workflows?

@kikoso kikoso left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@kikoso
kikoso merged commit 0293633 into main Nov 24, 2026
14 checks passed
@kikoso
kikoso deleted the ci/auto-fix-followups branch November 24, 2026 05:59
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.

3 participants