Skip to content

feat(scripts,agents): add diff-aware pre-commit/pre-push gates and pr-quality-ci skill - #1288

Merged
kyasbal merged 1 commit into
mainfrom
push-mozkyuprolkq
Nov 18, 2026
Merged

kyasbal merged 1 commit into
mainfrom
push-mozkyuprolkq

Conversation

@kyasbal

@kyasbal kyasbal commented Nov 18, 2026

Copy link
Copy Markdown
Member

Summary

Consolidates local code quality verification into two diff-aware make commands (make pre-commit and make pre-push) and adds the pr-quality-ci agent skill to minimize pre-push rework and standardize autonomous post-PR CI monitoring, transient failure reruns, review triage, and incremental jj fixes.

What Changed

  1. Diff-Scoped make pre-commit & CI-Parity make pre-push (scripts/pre-commit.sh, scripts/pre-push.sh, scripts/make/*.mk):

    • make pre-commit: Inspects modified files in the active working copy (@ in Jujutsu, or index/working tree in Git), running only the formatters and fast static checks relevant to touched domains (add-licenses, Proto, package-scoped Go format-go/lint-go + codequality-fast, Web, misc YAML/JSON, and Markdown). Fails explicitly when @ is empty instead of silently passing as a no-op.
    • make pre-push (optional BASE=<parent-bookmark> for stacked PRs): Evaluates fork_point(BASE | @)..@ across the branch diff and runs affected CI gates in fail-fast order with GitHub Actions (PR Tests) and Cloud Build (github-codequality) parity — including check-licenses, lint-*, build-web (prod + dev), build-storybook, cross-OS build-go-binaries, unit tests, and differential codequality with unlimited mutants (CODEQUALITY_MAX=0, CODEQUALITY_TIMEOUT=10m).
    • Fixes unquoted CODEQUALITY_BASE / CODEQUALITY_TARGET shell arguments in scripts/make/testing.mk so Jujutsu revsets such as trunk() pass cleanly, and removes the duplicate codequality entry in make help.
    • Adds hermetic table-driven script tests in scripts/codequality/hooks_script_test.go.
  2. Agent Skill & Workflow Documentation (.agents/skills/pr_quality_ci/SKILL.md, .agents/skills/jj_workflow/SKILL.md, GEMINI.md, scripts/GEMINI.md):

    • Adds pr-quality-ci covering the two-command local verification workflow, codequality remediation priority, PR creation, non-polling gh pr checks --watch --fail-fast monitoring, transient failure CI reruns (gh run rerun --failed and Check Run rerequest), sticky <!-- khi-codequality-report --> commit-SHA freshness checks, critical gemini-code-assist[bot] / reviewer comment evaluation, no-squash incremental fix pushes, and review thread / PR summary commenting rules.
    • Aligns jj-workflow, GEMINI.md, and scripts/GEMINI.md onto make pre-commit and make pre-push.

Verification

  • go test -v ./scripts/codequality -run TestHookScripts: PASS
  • make pre-commit: PASS
  • make pre-push: PASS (0 violations across check-licenses, lint-md, lint-go, codequality-fast, test-go, build-go-binaries, and codequality-go with CODEQUALITY_MAX=0)

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

Copy link
Copy Markdown
Contributor

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 introduces diff-scoped verification scripts (pre-commit.sh and pre-push.sh) along with corresponding Makefile targets and documentation to streamline local and CI-parity checks. Feedback on these changes points out an invalid --fail-fast flag used with gh pr checks in the documentation, a potential failure in pre-commit.sh when directory paths contain spaces, and portability issues caused by hardcoding /bin/bash in both the test suite and Makefile recipes.

Comment on lines +128 to +132
Never run `sleep` loops in a shell to poll CI. Watch checks asynchronously with `--fail-fast` so execution wakes immediately on the first failure without waiting up to an hour for `github-deploy-ondemand`:

```bash
gh pr checks <pr_number> --repo GoogleCloudPlatform/khi --watch --fail-fast --interval 30
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The GitHub CLI gh pr checks command does not support a --fail-fast flag. Running this command will result in an unknown flag: --fail-fast error, which will break automated agent workflows. Please remove the --fail-fast flag from both the description and the command block.

Comment thread scripts/pre-commit.sh
Comment on lines +86 to +91
dir_has_go_files() {
local rel_dir="$1"
local abs_dir="${REPO_ROOT}/${rel_dir}"
[[ -d "${abs_dir}" ]] || return 1
compgen -G "${abs_dir}/*.go" >/dev/null
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The use of compgen -G to check for the existence of Go files will fail if the repository path contains spaces, because compgen -G performs word splitting on its argument before expanding the glob. To make this robust against spaces in directory paths, use a standard glob loop instead.

Suggested change
dir_has_go_files() {
local rel_dir="$1"
local abs_dir="${REPO_ROOT}/${rel_dir}"
[[ -d "${abs_dir}" ]] || return 1
compgen -G "${abs_dir}/*.go" >/dev/null
}
dir_has_go_files() {
local rel_dir="$1"
local abs_dir="${REPO_ROOT}/${rel_dir}"
[[ -d "${abs_dir}" ]] || return 1
local f
for f in "${abs_dir}"/*.go; do
[[ -e "${f}" ]] && return 0
done
return 1
}
writeStubCLIs(t, binDir, callsFile, diffFixture)

scriptPath := filepath.Join(realRepoRoot, "scripts", tc.scriptName)
cmd := exec.CommandContext(context.Background(), "/bin/bash", scriptPath)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Hardcoding /bin/bash makes the test suite incompatible with Windows environments (even when Git Bash or MSYS2 is installed and bash is in the PATH) and some non-standard Unix environments. Using "bash" directly allows Go's exec.CommandContext to look up the executable in the system's PATH dynamically.

Suggested change
cmd := exec.CommandContext(context.Background(), "/bin/bash", scriptPath)
cmd := exec.CommandContext(context.Background(), "bash", scriptPath)
Comment thread scripts/make/hooks.mk
fi \
fi
pre-commit: ## Auto-format and run fast static checks on modified files in working copy
@/bin/bash ./scripts/pre-commit.sh

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Hardcoding /bin/bash in the Makefile recipe reduces portability on systems where bash is located elsewhere (e.g., /usr/local/bin/bash on FreeBSD) or on Windows environments. Using bash directly is more portable as it resolves via the system's PATH.

	@bash ./scripts/pre-commit.sh
Comment thread scripts/make/hooks.mk

.PHONY: pre-push
pre-push: ## Run full CI-parity verification gates on changed branch files (optional: BASE=<rev>)
@BASE="$(BASE)" /bin/bash ./scripts/pre-push.sh

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Hardcoding /bin/bash in the Makefile recipe reduces portability on systems where bash is located elsewhere (e.g., /usr/local/bin/bash on FreeBSD) or on Windows environments. Using bash directly is more portable as it resolves via the system's PATH.

	@BASE="$(BASE)" bash ./scripts/pre-push.sh
@github-actions

Copy link
Copy Markdown

Go Quality Report (origin/main) — ✅ PASS

Metric Result
Changed Scope 0 prod file(s), 1 test file(s), 6 unit(s)
Patch Coverage 100.0% (0/0 lines)
Mutation Score 100.0% (0/0 killed, 0 survived)

Commit: ea51184d0c05 · Cloud Build Logs

@kyasbal
kyasbal added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit 27825e8 Nov 18, 2026
22 checks passed
@kyasbal
kyasbal deleted the push-mozkyuprolkq branch November 18, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant