Compare commits

...

9 Commits

Author SHA1 Message Date
Nikhil Soni
a8c48fe9cd Merge remote-tracking branch 'origin/main' into ns/githooks
# Conflicts:
#	.githooks/commit-msg
#	frontend/.husky/pre-commit
#	frontend/package.json
#	frontend/pnpm-lock.yaml
2026-11-11 17:53:13 +05:30
Nikhil Soni
31c342c2e5 chore(hooks): install hooks with an explicit make hooks target
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 17:48:02 +05:30
Nikhil Soni
773453f104 chore(hooks): point core.hooksPath at .githooks instead of generating stubs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 17:35:17 +05:30
Nikhil Soni
eff31a0180 chore(hooks): run commitlint only when frontend deps are installed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 16:21:06 +05:30
Nikhil Soni
e7b8ec2a00 ci: check pr titles follow conventional commits
Squash merges use the PR title, so it is the only message that lands on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 16:21:06 +05:30
Nikhil Soni
3c6c700a73 revert: "chore(hooks): replace commitlint with a shell commit-msg check"
This reverts commit 872194dbee.
2026-11-11 15:26:05 +05:30
Nikhil Soni
872194dbee chore(hooks): replace commitlint with a shell commit-msg check
Mirrors @commitlint/config-conventional so commits need no node_modules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 13:40:57 +05:30
Nikhil Soni
bfaac7a7cc fix(hooks): require frontend deps only for frontend changes
Without node_modules, commit messages fall back to a header-only conventional check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 12:06:48 +05:30
Nikhil Soni
f1010908db chore(hooks): replace husky with worktree-safe .githooks installed automatically
Husky wired hook installation to pnpm install, which go-only contributors
never run. The installer is plain shell so both the Makefile and the frontend
postinstall can call it, and each check is gated on staged paths so neither
side needs the other's toolchain.
2026-08-18 15:09:45 +05:30
8 changed files with 76 additions and 15 deletions

View File

@@ -1,4 +1,12 @@
cd frontend && pnpm run commitlint --edit $1
#!/bin/sh
set -e
msg_file="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
if [ -d frontend/node_modules ] && command -v pnpm >/dev/null 2>&1; then
(cd frontend && pnpm exec commitlint --edit "$msg_file")
fi
branch="$(git rev-parse --abbrev-ref HEAD)"

33
.githooks/pre-commit Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/sh
set -e
IFS='
'
go_files=$(git diff --cached --name-only --diff-filter=ACM -- '*.go')
if [ -n "$go_files" ] && command -v gofmt >/dev/null 2>&1; then
partially_staged=""
for f in $go_files; do
[ -n "$(git show ":$f" | gofmt -l)" ] || continue
if git diff --quiet -- "$f"; then
gofmt -w "$f"
git add -- "$f"
else
partially_staged="$partially_staged
$f"
fi
done
if [ -n "$partially_staged" ]; then
echo "pre-commit: unformatted and partially staged, run gofmt -w and restage:$partially_staged" >&2
exit 1
fi
fi
if [ -n "$(git diff --cached --name-only --diff-filter=ACM -- frontend/)" ]; then
if [ ! -d frontend/node_modules ] || ! command -v pnpm >/dev/null 2>&1; then
echo "pre-commit: frontend changes need dependencies, run: cd frontend && pnpm install" >&2
exit 1
fi
(cd frontend && pnpm exec lint-staged)
fi

25
.github/workflows/prtitleci.yaml vendored Normal file
View File

@@ -0,0 +1,25 @@
name: prtitleci
on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened
branches:
- main
jobs:
check:
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- name: check
uses: amannn/action-semantic-pull-request@v6.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
subjectPattern: ^(?![A-Z]).+$
subjectPatternError: The subject "{subject}" must not start with an uppercase letter.

View File

@@ -48,6 +48,10 @@ $(TARGET_DIR):
help: ## Displays help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-z0-9A-Z_-]+:.*?##/ { printf " \033[36m%-40s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
.PHONY: hooks
hooks: ## Installs the git hooks from .githooks
@git config core.hooksPath .githooks
##############################################################
# devenv commands
##############################################################

View File

@@ -36,6 +36,10 @@ Before diving in, make sure you have these tools installed:
```bash
cd signoz
```
4. Install the git hooks (formatting, linting and commit message checks), once per clone:
```bash
make hooks
```
## How do I run it locally?

View File

@@ -1 +0,0 @@
cd frontend && pnpm lint-staged

View File

@@ -24,8 +24,7 @@
"jest": "jest",
"jest:coverage": "jest --coverage",
"jest:watch": "jest --watch",
"postinstall": "pnpm i18n:generate-hash && ([ -n \"$CI\" ] || pnpm husky:configure) && node scripts/update-registry.cjs",
"husky:configure": "cd .. && husky frontend/.husky",
"postinstall": "pnpm i18n:generate-hash && ([ -n \"$CI\" ] || git config core.hooksPath .githooks || true) && node scripts/update-registry.cjs",
"commitlint": "commitlint --edit $1",
"test": "jest",
"test:changedsince": "jest --changedSince=main --coverage --silent",
@@ -190,7 +189,6 @@
"@types/testing-library__jest-dom": "^5.14.5",
"@typescript/native-preview": "7.0.0-dev.20260430.1",
"eslint-plugin-sonarjs": "4.0.2",
"husky": "^9.1.7",
"jest-environment-jsdom": "29.7.0",
"jest-styled-components": "^7.2.0",
"json-schema-to-typescript": "^15.0.4",

View File

@@ -443,9 +443,6 @@ importers:
eslint-plugin-sonarjs:
specifier: 4.0.2
version: 4.0.2(eslint@10.2.1(jiti@2.6.1))
husky:
specifier: ^9.1.7
version: 9.1.7
jest-environment-jsdom:
specifier: 29.7.0
version: 29.7.0
@@ -6171,11 +6168,6 @@ packages:
resolution: {integrity: sha512-eKCa6bwnJhvxj14kZk5NCPc6Hb6BdsU9DZcOnmQKSnO1VKrfV0zCvtttPZUsBvjmNDn8rpcJfpwSYnHBjc95MQ==}
engines: {node: '>=18.18.0'}
husky@9.1.7:
resolution: {integrity: sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==}
engines: {node: '>=18'}
hasBin: true
hyphenate-style-name@1.0.4:
resolution: {integrity: sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ==}
@@ -16029,8 +16021,6 @@ snapshots:
human-signals@8.0.1: {}
husky@9.1.7: {}
hyphenate-style-name@1.0.4: {}
i18next-browser-languagedetector@6.1.8: