ci(workflow): add commit msg check (#587)

* ci(workflow): add commit check

* docs(workflow): add commit check to CONTRIBUTING

* chore(workflow): optimize lint error
This commit is contained in:
Zhou Xiao 2025-04-18 12:50:52 +08:00 committed by GitHub
parent bcfcb3c4d0
commit bc5b6e2121
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 316 additions and 347 deletions

4
.husky/commit-msg Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx --no -- commitlint --edit "$1"

View File

@ -196,23 +196,54 @@ Commit your changes to your forked repo, and [create a pull request](https://hel
> Normally, the commits in a PR will be squashed into one commit, so you don't need to rebase locally.
### Format of PR titles
### Format of PR titles and Commit Messages
The format of PR titles follow [Conventional Commits](https://www.conventionalcommits.org/).
We use [Conventional Commits](https://www.conventionalcommits.org/) for PR titles and commit messages. This helps in automating changelog generation and keeps the commit history clean and understandable.
An example:
**Structure:**
```
feat(core): Add `myOption` config
^ ^ ^
| | |__ Subject
| |_______ Scope
|____________ Type
<type>(<scope>): <subject>
^ ^ ^
| | |__ Subject: Concise description of the change (imperative mood, lowercase).
| |__________ Scope: The specific part of the codebase affected. **This is mandatory.**
|_______________ Type: Indicates the kind of change.
```
**Allowed Types:**
* `feat`: A new feature.
* `fix`: A bug fix.
* `refactor`: Code changes that neither fix a bug nor add a feature.
* `chore`: Changes to the build process, auxiliary tools, libraries, documentation generation etc.
* `docs`: Documentation only changes.
* Other conventional types like `perf`, `style`, `test`, `ci`, `build` are also acceptable.
**Mandatory & Allowed Scopes:**
Every commit **must** include a scope. The scope must be one of the following:
* `workflow`
* `android`
* `llm`
* `playwright`
* `puppeteer`
* `mcp`
* `bridge`
* *(Consider adding other relevant top-level packages or areas here if needed)*
**Examples:**
* `feat(mcp): add screenshot tool with element selection`
* `fix(android): correct adb connection issue on windows`
* `refactor(llm): simplify prompt generation logic`
* `chore(workflow): update commitlint configuration`
* `docs(bridge): clarify AgentOverChromeBridge usage`
Your commit will be rejected by a pre-commit hook if it doesn't adhere to these rules.
---
## Versioning
All Midscene packages will use a fixed unified version.

23
commitlint.config.js Normal file
View File

@ -0,0 +1,23 @@
// commitlint.config.js
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'scope-enum': [
2, // Level: Error
'always', // Apply rule always
[
// Allowed scopes
'workflow',
'android',
'llm',
'playwright',
'puppeteer',
'mcp',
'bridge',
// Add other relevant scopes for your project if needed
],
],
// Add rule to disallow empty scopes
'scope-empty': [2, 'never'],
},
};

View File

@ -11,7 +11,7 @@
"e2e:report": "nx run @midscene/web:e2e:report --verbose",
"e2e:visualizer": "nx run @midscene/visualizer:e2e --verbose",
"test:ai:all": "npm run e2e && npm run e2e:cache && npm run e2e:report && npm run test:ai && npm run e2e:visualizer",
"prepare": "pnpm run build && simple-git-hooks",
"prepare": "simple-git-hooks && husky && pnpm run build",
"check-dependency-version": "check-dependency-version-consistency .",
"lint": "npx biome check . --diagnostic-level=info --no-errors-on-unmatched --fix",
"format:ci": "pretty-quick --since HEAD~1",
@ -40,7 +40,8 @@
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@changesets/cli": "2.24.1",
"@commitlint/cli": "^17.8.1",
"@commitlint/cli": "19.8.0",
"@commitlint/config-conventional": "19.8.0",
"@esm2cjs/execa": "6.1.1-cjs.1",
"@jsdevtools/version-bump-prompt": "6.1.0",
"chalk": "4.1.2",
@ -48,6 +49,7 @@
"commitizen": "4.2.5",
"cspell-ban-words": "^0.0.3",
"dayjs": "1.11.11",
"husky": "9.1.7",
"minimist": "1.2.5",
"nano-staged": "^0.8.0",
"nx": "^19.8.10",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 624 KiB

After

Width:  |  Height:  |  Size: 597 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 845 KiB

After

Width:  |  Height:  |  Size: 768 KiB

581
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff