diff --git a/.commitlintrc.yml b/.commitlintrc.yml new file mode 100644 index 000000000..2588ed10b --- /dev/null +++ b/.commitlintrc.yml @@ -0,0 +1,10 @@ +extends: + - '@commitlint/config-conventional' +rules: + subject-case: + - 0 + - always + - - sentence-case + - start-case + - pascal-case + - upper-case diff --git a/.github/workflows/pr-closed.yml b/.github/workflows/pr-closed.yml new file mode 100644 index 000000000..e3b7fbebc --- /dev/null +++ b/.github/workflows/pr-closed.yml @@ -0,0 +1,27 @@ +name: 🎉 PR closed + +on: + pull_request_target: + types: + - closed + +permissions: + contents: read + pull-requests: write + +jobs: + thank-you: + runs-on: ubuntu-latest + steps: + - name: Post Thank You Comment + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + env: + comment: Thanks for helping make WXT better! + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: process.env.comment + }) diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml new file mode 100644 index 000000000..662e70f69 --- /dev/null +++ b/.github/workflows/pr-title.yml @@ -0,0 +1,26 @@ +name: ✅ Check PR Title + +on: + pull_request: + types: [opened, edited] + +jobs: + lint-pr-title: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + # Only fetch the config file from the repository + sparse-checkout-cone-mode: false + sparse-checkout: .commitlintrc.yml + + - name: Install dependencies + run: npm install --global @commitlint/config-conventional commitlint + + - name: Check PR title with commitlint + env: + PR_TITLE: ${{ github.event.pull_request.title }} + HELP_URL: https://github.com/wxt-dev/wxt/blob/main/CONTRIBUTING.md#conventional-pr-titles + run: echo "$PR_TITLE" | npx commitlint --help-url $HELP_URL diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d1711c4c5..c625a7b9e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,9 +8,17 @@ If you want to add a new feature, please create an issue or discussion first so ## Conventional Commits -This project uses [Conventional Commits](https://www.conventionalcommits.org/en) to automate versioning. If you're a new contributor, don't worry about this. When you open a PR, a maintainer will change the PR's title so it's in the style of conventional commits, but that's all. +This project uses [Conventional Commit format](https://www.conventionalcommits.org/en/v1.0.0/) to automatically generate a changelog and better understand the changes in the project -Maintainers, commits to the `main` branch (either directly or via PRs) must be valid conventional commits. +Here are some examples of conventional commit messages: + +- `feat: add new functionality` +- `fix: correct typos in code` +- `ci: add GitHub Actions for automated testing` + +## Conventional PR Titles + +The title of your pull request should follow the [conventional commit format](#conventional-commits). When a pull request is merged to the main branch, all changes are going to be squashed into a single commit. The message of this commit will be the title of the pull request. And for every release, the commit messages are used to generate the changelog. ## Setup diff --git a/package.json b/package.json index 0214dcba3..b1e9c5883 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,8 @@ "devDependencies": { "@aklinker1/buildc": "^1.1.4", "@aklinker1/check": "^1.4.5", + "@commitlint/config-conventional": "^19.7.1", + "@commitlint/types": "^19.5.0", "@types/fs-extra": "^11.0.4", "@vitest/coverage-v8": "^2.1.4", "changelogen": "^0.5.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8b307462f..c3dfc8ef8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,6 +19,12 @@ importers: '@aklinker1/check': specifier: ^1.4.5 version: 1.4.5(typescript@5.6.3) + '@commitlint/config-conventional': + specifier: ^19.7.1 + version: 19.7.1 + '@commitlint/types': + specifier: ^19.5.0 + version: 19.5.0 '@types/fs-extra': specifier: ^11.0.4 version: 11.0.4 @@ -908,6 +914,14 @@ packages: '@bcoe/v8-coverage@0.2.3': resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} + '@commitlint/config-conventional@19.7.1': + resolution: {integrity: sha512-fsEIF8zgiI/FIWSnykdQNj/0JE4av08MudLTyYHm4FlLWemKoQvPNUYU2M/3tktWcCEyq7aOkDDgtjrmgWFbvg==} + engines: {node: '>=v18'} + + '@commitlint/types@19.5.0': + resolution: {integrity: sha512-DSHae2obMSMkAtTBSOulg5X7/z+rGLxcXQIkg3OmWvY6wifojge5uVMydfhUvs7yQj+V7jNmRZ2Xzl8GJyqRgg==} + engines: {node: '>=v18'} + '@devicefarmer/adbkit-logcat@2.1.3': resolution: {integrity: sha512-yeaGFjNBc/6+svbDeul1tNHtNChw6h8pSHAt5D+JsedUrMTN7tla7B15WLDyekxsuS2XlZHRxpuC6m92wiwCNw==} engines: {node: '>= 4'} @@ -1922,6 +1936,9 @@ packages: '@types/chrome@0.0.280': resolution: {integrity: sha512-AotSmZrL9bcZDDmSI1D9dE7PGbhOur5L0cKxXd7IqbVizQWCY4gcvupPUVsQ4FfDj3V2tt/iOpomT9EY0s+w1g==} + '@types/conventional-commits-parser@5.0.1': + resolution: {integrity: sha512-7uz5EHdzz2TqoMfV7ee61Egf5y6NkcO4FB/1iCCQnbeiI1F3xzv3vK5dBCXUCLQgGYS+mUeigK1iKQzvED+QnQ==} + '@types/estree@1.0.5': resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} @@ -2308,6 +2325,9 @@ packages: resolution: {integrity: sha512-Q6VPTLMsmXZ47ENG3V+wQyZS1ZxXMxFyYzA+Z/GMrJ6yIutAIEf9wTyroTzmGjNfox9/h3GdGBCVh43GVFx4Uw==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + array-ify@1.0.0: + resolution: {integrity: sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==} + array-union@3.0.1: resolution: {integrity: sha512-1OvF9IbWwaeiM9VhzYXVQacMibxpXOMYVNIvMtKRyX9SImBXpKcFr8XvFDeEslCyuH/t6KRt7HEO94AlP8Iatw==} engines: {node: '>=12'} @@ -2615,6 +2635,9 @@ packages: commondir@1.0.1: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} + compare-func@2.0.0: + resolution: {integrity: sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==} + concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} @@ -2636,6 +2659,10 @@ packages: resolution: {integrity: sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ==} engines: {node: ^14.18.0 || >=16.10.0} + conventional-changelog-conventionalcommits@7.0.2: + resolution: {integrity: sha512-NKXYmMR/Hr1DevQegFB4MwfM5Vv0m4UIxKZTTYuD98lpTknaZlSRrDOG4X7wIXpGkfsYxZTghUN+Qq+T0YQI7w==} + engines: {node: '>=16'} + convert-gitmoji@0.1.5: resolution: {integrity: sha512-4wqOafJdk2tqZC++cjcbGcaJ13BZ3kwldf06PTiAQRAB76Z1KJwZNL1SaRZMi2w1FM9RYTgZ6QErS8NUl/GBmQ==} @@ -2834,6 +2861,10 @@ packages: domutils@3.1.0: resolution: {integrity: sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==} + dot-prop@5.3.0: + resolution: {integrity: sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==} + engines: {node: '>=8'} + dot-prop@6.0.1: resolution: {integrity: sha512-tE7ztYzXHIeyvc7N+hR3oi7FIbf/NIjVP9hmAt3yMXzrQ072/fpjGLx2GxNxGxUl5V73MEqYzioOMoVhGMJ5cA==} engines: {node: '>=10'} @@ -5634,6 +5665,16 @@ snapshots: '@bcoe/v8-coverage@0.2.3': {} + '@commitlint/config-conventional@19.7.1': + dependencies: + '@commitlint/types': 19.5.0 + conventional-changelog-conventionalcommits: 7.0.2 + + '@commitlint/types@19.5.0': + dependencies: + '@types/conventional-commits-parser': 5.0.1 + chalk: 5.3.0 + '@devicefarmer/adbkit-logcat@2.1.3': {} '@devicefarmer/adbkit-monkey@1.2.1': {} @@ -6360,6 +6401,10 @@ snapshots: '@types/filesystem': 0.0.36 '@types/har-format': 1.2.15 + '@types/conventional-commits-parser@5.0.1': + dependencies: + '@types/node': 20.17.6 + '@types/estree@1.0.5': {} '@types/estree@1.0.6': {} @@ -6856,6 +6901,8 @@ snapshots: array-differ@4.0.0: {} + array-ify@1.0.0: {} + array-union@3.0.1: {} assertion-error@2.0.1: {} @@ -7196,6 +7243,11 @@ snapshots: commondir@1.0.1: {} + compare-func@2.0.0: + dependencies: + array-ify: 1.0.0 + dot-prop: 5.3.0 + concat-map@0.0.1: {} concat-stream@1.6.2: @@ -7222,6 +7274,10 @@ snapshots: consola@3.2.3: {} + conventional-changelog-conventionalcommits@7.0.2: + dependencies: + compare-func: 2.0.0 + convert-gitmoji@0.1.5: {} convert-source-map@2.0.0: {} @@ -7417,6 +7473,10 @@ snapshots: domelementtype: 2.3.0 domhandler: 5.0.3 + dot-prop@5.3.0: + dependencies: + is-obj: 2.0.0 + dot-prop@6.0.1: dependencies: is-obj: 2.0.0