Skip to content

ci: make the required build checks fail closed - #106

Open
borisr-code-ibm wants to merge 2 commits into
android:mainfrom
borisr-code-ibm:chore/ci-build-gate
Open

borisr-code-ibm wants to merge 2 commits into
android:mainfrom
borisr-code-ibm:chore/ci-build-gate

Conversation

@borisr-code-ibm

Copy link
Copy Markdown
Contributor

What I have done and why

rules-main requires the checks Agent build & test and ChatApp build & test (#99). They were the build jobs themselves, which the changes job skips when a PR doesn't touch the project. GitHub counts a skipped required check as passing (docs; #101 and #102 merged with both checks skipped). So the check also passed whenever change detection went wrong, and a PR that doesn't compile could be merged:

PR Before (main) After (this PR)
Compile error in agent/ build fails, merge blocked build fails, gate fails, merge blocked
No agent/ files changed build skipped, check passes build skipped, gate passes
git diff fails in Check changes (e.g. no origin/<base> or no merge base) run_ci=false, build skipped, check passes step fails, gate fails, merge blocked
Check changes job fails or is cancelled build skipped, check passes gate fails, merge blocked
Moves a file out of agent/ only the new path is listed, build skipped, check passes old path is listed too, build runs
Changes a path git quotes (agent/…/Über.kt, a"b.kt) "agent/… misses ^agent/, build skipped, check passes quoted form matches, build runs

The same applies to ChatApp.

Changes, in both agent.yaml and chatapp.yaml:

  1. A small gate job now carries the required name (Agent build & test / ChatApp build & test), so rules-main needs no change. It runs with if: always() and has permissions: {}. It passes only when changes succeeded and the build either passed or was skipped because the PR touches no project files. A failed or cancelled run, a missing output or an unexpected skip all fail the check.
  2. The build jobs keep their steps and are renamed to Agent spotless, tests & APKs / ChatApp spotless, tests & APKs. They still get cancelled when a newer push supersedes them.
  3. changes stores git diff --no-renames --name-only in a variable first, so a git error fails the step under the default bash -e shell. Its patterns also accept git's quoted path form (^"?).

Testing

  • actionlint 1.7.12 (with shellcheck): no errors. zizmor 1.33.1: same findings as on main, nothing new.
  • A local script runs the gate and detection scripts from both workflows with bash -e, as the runner does: 136/136 cases pass.
    • Gate: every combination of changes result × run_ci × build result (96).
    • Detection, in temp git repos: changes per project, moves out of and between projects, non-ASCII paths, paths with ", \ or a tab, empty diffs, push events, and a missing base ref (40).
    • On main's scripts, the same cases reproduce the four fail-open rows marked in the table.
  • This PR changes both workflow files, so its own CI runs both full builds behind the new gate jobs.

Notes for maintainers

  • When a newer push cancels a run, the gate now shows as failed on the old commit (instead of grey). Only the latest commit counts.
  • Not changed here: rules-main has strict_required_status_checks_policy: false, so two PRs that each pass CI can still break main together. Changing a PR's base doesn't re-run CI either. Requiring up-to-date branches (or a merge queue, which would also need a merge_group trigger) would cover both.
  • The agent instrumentation tests are flaky on main; Show dynamic and disabled function states in the Debug tab and fix flaky agent tests #104 addresses that.

rules-main requires "Agent build & test" and "ChatApp build & test".
Those were the build jobs themselves, which the changes job skips when a
PR touches no project files. GitHub counts a skipped required check as
passing, so the check also passed whenever change detection went wrong,
and a PR that does not compile could be merged: a failing git diff wrote
run_ci=false, a failed or cancelled changes job skipped the build, a file
moved out of a project only showed its new path, and paths that git
quotes missed the ^agent/ and ^ChatApp/ patterns.

Give the required names to small gate jobs that always run and pass only
when the build succeeded, or was skipped because detection found no
project changes. Detection stores git diff --no-renames output in a
variable first, so a git error fails the step, and its patterns accept
git's quoted paths. The build jobs keep their steps under new names.
@google-cla

google-cla Bot commented Nov 30, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@borisr-code-ibm
borisr-code-ibm marked this pull request as ready for review November 30, 2026 19:03
@borisr-code-ibm
borisr-code-ibm requested review from a team as code owners November 30, 2026 19:03
Comment thread .github/workflows/agent.yaml Resolved
@borisr-code-ibm

Copy link
Copy Markdown
Contributor Author

ChatApp CI fails in a test that predates this PR. It runs here only because this PR edits chatapp.yaml.

AppFunctionsViewModelTest.toggleFunction_doesNotCrash calls toggleFunction(FUNCTION_ID_SEARCH_CONTACTS, true), which starts setAppFunctionEnabled in viewModelScope without waiting for it. On a freshly installed app the function most likely isn't indexed yet, so the platform answers "Function com.example.chatapp.appfunctions.BaseChatAppFunctionService#searchContacts does not exist". That exception then fails whichever test is running: chatLinkWithDraft_keepsSpecialCharacters in attempt 2 and chatLink_resolvesToMainActivity in attempt 3. main hasn't run ChatApp CI since #99.

I'll send a separate PR that makes the test wait for the function to be indexed and for the toggle to finish. Once it's merged, I'll update this branch so CI can run again.

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.

2 participants