diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 511f042..e42f123 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,6 +10,7 @@ on: permissions: contents: read + pull-requests: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -78,4 +79,36 @@ jobs: run: npm run lint -w @auth0/auth0-fastify - name: Lint @auth0/auth0-fastify-api - run: npm run lint -w @auth0/auth0-fastify-api \ No newline at end of file + run: npm run lint -w @auth0/auth0-fastify-api + + commitlint: + name: Commitlint + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + steps: + - name: Checkout code + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + with: + fetch-depth: 0 + + - name: Validate conventional commits + uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1 + with: + configFile: commitlint.config.js + + pr-title: + name: PR Title + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + steps: + - name: Validate PR title follows conventional commits + uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + scopes: | + auth0-fastify + auth0-fastify-api + ci + security + deps \ No newline at end of file diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 0000000..0a4b97d --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1 @@ +npx --no -- commitlint --edit $1 diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000..37f4a28 --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,13 @@ +export default { + extends: ['@commitlint/config-conventional'], + rules: { + 'scope-enum': [2, 'always', [ + 'auth0-fastify', + 'auth0-fastify-api', + 'ci', + 'security', + 'deps', + ]], + 'scope-empty': [1, 'never'], + }, +}; diff --git a/package.json b/package.json index 8ba8bef..9038196 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "auth0-fastify", "version": "1.0.0", + "type": "module", "workspaces": [ "packages/*", "examples/*" @@ -10,13 +11,17 @@ "clean": "turbo run clean", "test": "turbo run test", "lint": "turbo run lint", - "docs": "typedoc" + "docs": "typedoc", + "prepare": "husky" }, "author": "", "license": "ISC", "description": "", "packageManager": "npm@10.1.0", "devDependencies": { + "@commitlint/cli": "^21.0.2", + "@commitlint/config-conventional": "^21.0.2", + "husky": "^9.1.7", "turbo": "^2.4.4", "typedoc": "^0.27.9" }