From a52f013ef4d8ddd017fc93f9f323582cf637d931 Mon Sep 17 00:00:00 2001 From: Boris Rayskiy Date: Mon, 30 Nov 2026 19:00:48 +0000 Subject: [PATCH 1/2] ci: make the required build checks fail closed 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. --- .github/workflows/agent.yaml | 36 ++++++++++++++++++++++++++++++++-- .github/workflows/chatapp.yaml | 36 ++++++++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/.github/workflows/agent.yaml b/.github/workflows/agent.yaml index afccfa80..f1041245 100644 --- a/.github/workflows/agent.yaml +++ b/.github/workflows/agent.yaml @@ -40,14 +40,16 @@ jobs: echo "run_ci=true" >> "$GITHUB_OUTPUT" exit 0 fi - if git diff --name-only "origin/$BASE_REF...HEAD" | grep -qE '^(agent/|\.github/workflows/agent\.yaml|\.github/ci-gradle\.properties)'; then + changed_files="$(git diff --no-renames --name-only "origin/$BASE_REF...HEAD")" + # git wraps paths with non-ASCII or special characters in double quotes. + if grep -qE '^"?(agent/|\.github/workflows/agent\.yaml|\.github/ci-gradle\.properties)' <<< "$changed_files"; then echo "run_ci=true" >> "$GITHUB_OUTPUT" else echo "run_ci=false" >> "$GITHUB_OUTPUT" fi agent-build: - name: "Agent build & test" + name: "Agent spotless, tests & APKs" needs: changes if: needs.changes.outputs.run_ci == 'true' runs-on: ubuntu-latest @@ -116,3 +118,33 @@ jobs: with: name: agent-apks path: agent/app/build/outputs/apk/**/*.apk + + # Required status check in the rules-main ruleset, so keep its name in sync. GitHub counts a + # skipped required check as passing, so this job always runs and fails unless the build passed or + # was skipped because the change touches no agent files. + agent-gate: + name: "Agent build & test" + needs: [changes, agent-build] + if: always() + runs-on: ubuntu-latest + permissions: {} + steps: + - name: Check build result + env: + CHANGES_RESULT: ${{ needs.changes.result }} + RUN_CI: ${{ needs.changes.outputs.run_ci }} + BUILD_RESULT: ${{ needs.agent-build.result }} + run: | + if [ "$CHANGES_RESULT" != "success" ]; then + echo "::error::Check changes finished with '$CHANGES_RESULT', so the agent build was not verified." + exit 1 + fi + if [ "$RUN_CI" = "false" ] && [ "$BUILD_RESULT" = "skipped" ]; then + echo "No agent files changed, so the agent build is not needed." + exit 0 + fi + if [ "$BUILD_RESULT" != "success" ]; then + echo "::error::Agent spotless, tests & APKs finished with '$BUILD_RESULT'." + exit 1 + fi + echo "Agent spotless, tests & APKs passed." diff --git a/.github/workflows/chatapp.yaml b/.github/workflows/chatapp.yaml index 316797dc..64a9ba8f 100644 --- a/.github/workflows/chatapp.yaml +++ b/.github/workflows/chatapp.yaml @@ -40,14 +40,16 @@ jobs: echo "run_ci=true" >> "$GITHUB_OUTPUT" exit 0 fi - if git diff --name-only "origin/$BASE_REF...HEAD" | grep -qE '^(ChatApp/|\.github/workflows/chatapp\.yaml|\.github/ci-gradle\.properties)'; then + changed_files="$(git diff --no-renames --name-only "origin/$BASE_REF...HEAD")" + # git wraps paths with non-ASCII or special characters in double quotes. + if grep -qE '^"?(ChatApp/|\.github/workflows/chatapp\.yaml|\.github/ci-gradle\.properties)' <<< "$changed_files"; then echo "run_ci=true" >> "$GITHUB_OUTPUT" else echo "run_ci=false" >> "$GITHUB_OUTPUT" fi chatapp-build: - name: "ChatApp build & test" + name: "ChatApp spotless, tests & APKs" needs: changes if: needs.changes.outputs.run_ci == 'true' runs-on: ubuntu-latest @@ -121,3 +123,33 @@ jobs: path: | ChatApp/app/build/outputs/apk/**/*.apk ChatApp/wear/build/outputs/apk/**/*.apk + + # Required status check in the rules-main ruleset, so keep its name in sync. GitHub counts a + # skipped required check as passing, so this job always runs and fails unless the build passed or + # was skipped because the change touches no ChatApp files. + chatapp-gate: + name: "ChatApp build & test" + needs: [changes, chatapp-build] + if: always() + runs-on: ubuntu-latest + permissions: {} + steps: + - name: Check build result + env: + CHANGES_RESULT: ${{ needs.changes.result }} + RUN_CI: ${{ needs.changes.outputs.run_ci }} + BUILD_RESULT: ${{ needs.chatapp-build.result }} + run: | + if [ "$CHANGES_RESULT" != "success" ]; then + echo "::error::Check changes finished with '$CHANGES_RESULT', so the ChatApp build was not verified." + exit 1 + fi + if [ "$RUN_CI" = "false" ] && [ "$BUILD_RESULT" = "skipped" ]; then + echo "No ChatApp files changed, so the ChatApp build is not needed." + exit 0 + fi + if [ "$BUILD_RESULT" != "success" ]; then + echo "::error::ChatApp spotless, tests & APKs finished with '$BUILD_RESULT'." + exit 1 + fi + echo "ChatApp spotless, tests & APKs passed." From a7d7b4a8b4c820432b89f5376f5396287617d16c Mon Sep 17 00:00:00 2001 From: Boris Rayskiy Date: Mon, 30 Nov 2026 22:07:15 +0000 Subject: [PATCH 2/2] Address review: add a 5-minute timeout to the gate jobs --- .github/workflows/agent.yaml | 1 + .github/workflows/chatapp.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/agent.yaml b/.github/workflows/agent.yaml index f1041245..148077c2 100644 --- a/.github/workflows/agent.yaml +++ b/.github/workflows/agent.yaml @@ -127,6 +127,7 @@ jobs: needs: [changes, agent-build] if: always() runs-on: ubuntu-latest + timeout-minutes: 5 permissions: {} steps: - name: Check build result diff --git a/.github/workflows/chatapp.yaml b/.github/workflows/chatapp.yaml index 64a9ba8f..609b073d 100644 --- a/.github/workflows/chatapp.yaml +++ b/.github/workflows/chatapp.yaml @@ -132,6 +132,7 @@ jobs: needs: [changes, chatapp-build] if: always() runs-on: ubuntu-latest + timeout-minutes: 5 permissions: {} steps: - name: Check build result