-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
test: add Go + React UI coverage gates and fill test gaps #9989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| #!/usr/bin/env sh | ||
| # | ||
| # LocalAI pre-commit hook. Install it (once per clone) with: | ||
| # | ||
| # make install-hooks | ||
| # | ||
| # Runs only the checks relevant to what's staged: | ||
| # - Go files -> make lint + make test-coverage-check | ||
| # - core/http/react-ui -> make test-ui-coverage-check (Playwright e2e + gate) | ||
| # A commit touching neither is skipped entirely (docs/YAML/etc. can't change | ||
| # lint findings, Go coverage, or the UI). | ||
| # | ||
| # To bypass for a single commit (e.g. a WIP checkpoint): git commit --no-verify | ||
| set -eu | ||
|
|
||
| repo_root="$(git rev-parse --show-toplevel)" | ||
| cd "$repo_root" | ||
|
|
||
| staged="$(git diff --cached --name-only --diff-filter=ACMRD)" | ||
|
|
||
| go_changed=0 | ||
| ui_changed=0 | ||
| if echo "$staged" | grep -qE '\.go$'; then go_changed=1; fi | ||
| if echo "$staged" | grep -qE '^core/http/react-ui/'; then ui_changed=1; fi | ||
|
|
||
| if [ "$go_changed" -eq 0 ] && [ "$ui_changed" -eq 0 ]; then | ||
| echo "pre-commit: no Go or React UI changes staged — skipping." | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [ "$go_changed" -eq 1 ]; then | ||
| # Resolve the ref golangci-lint's new-from-merge-base should compare | ||
| # against. .golangci.yml pins origin/master, which is correct in CI | ||
| # (origin == the canonical repo) but wrong from a fork clone, where | ||
| # origin/master lags behind and lint would report the whole upstream | ||
| # backlog. Prefer upstream/master, then origin/master, then master. | ||
| lint_base="" | ||
| for ref in upstream/master origin/master master; do | ||
| if git rev-parse --verify --quiet "${ref}^{commit}" >/dev/null 2>&1; then | ||
| lint_base="$ref" | ||
| break | ||
| fi | ||
| done | ||
|
|
||
| echo "pre-commit ▶ golangci-lint (make lint${lint_base:+, new-from $lint_base})" | ||
| make lint LINT_NEW_FROM="$lint_base" | ||
|
|
||
| echo "pre-commit ▶ coverage gate (make test-coverage-check) — builds and runs the" | ||
| echo " pkg/core suites plus tests/e2e; can take a few minutes." | ||
| make test-coverage-check | ||
| fi | ||
|
|
||
| if [ "$ui_changed" -eq 1 ]; then | ||
| echo "pre-commit ▶ React UI e2e + coverage gate (make test-ui-coverage-check) —" | ||
| echo " rebuilds the UI + ui-test-server, runs the Playwright specs, and" | ||
| echo " fails if line coverage regressed; can take a couple of minutes." | ||
| make test-ui-coverage-check | ||
| fi | ||
|
|
||
| echo "pre-commit ✓ all relevant checks passed" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would even enforce here for agents to install make install-hooks so automatically enroll themselves when pointed at this repository
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I agree, I'd even consider making the agent submit a hash of the test results, so it can't reason its way out of using the hooks without getting caught.