-
Notifications
You must be signed in to change notification settings - Fork 928
ci: add commitlint GitHub Actions #4440
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
base: master
Are you sure you want to change the base?
ci: add commitlint GitHub Actions #4440
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
.github/workflows/commitlint.yml
Outdated
- name: Create commitlint.config.js | ||
run: | | ||
echo "export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js |
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.
Isn't it already present at
Lines 28 to 33 in 8a295f0
"commitlint": { | |
"extends": [ | |
"@commitlint/config-conventional", | |
"@commitlint/config-workspace-scopes" | |
] | |
}, |
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.
Yes, it is.
I removed the Create commitlint.config.js
step.
.github/workflows/commitlint.yml
Outdated
cache: yarn | ||
|
||
- name: Install dependencies | ||
run: yarn install --ignore-engines --frozen-lockfile |
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.
run: yarn install --ignore-engines --frozen-lockfile | |
run: yarn install --frozen-lockfile |
Alreay set at
Line 2 in 8a295f0
--install.ignore-engines true |
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.
Thanks, deleted.
Personally I never use a separate workflow for Line 1 in 8a295f0
|
You are right. but, some PRs don't follow the rules. |
And that's totally fine for users to contribute easily, the final committed message will follow our rules when we merge those PRs. |
Wow, sounds nice! |
I guess it depends on how strict the org is and why you need a specific commit message format. And what consequences you have to deal with if a "wrong" messages is being merged. In our case we haven't been strict and (mostly) update wrong messages when a PR is being merged. The value I would see in this PR is that we would dogfood our own docs, which might be good to see if things are working as expected? |
Currently I do not work on any project using commitlint at all 😅 |
Such dogfooding would make contributing to this project more difficult as I mentioned.
Oh, really? I'm using it in all my projects. 🤣 |
I quite agree.
The most of contributors are so polite and wise |
I see your points. |
Then how those false postive PRs came from? |
Umm... I'm not sure... I felt that the importance of this issue might depend on whether you value the user or the contributor. @JounQin I am very appreciative of your input. I was very happy to hear how the maintainers use commitlint in their works. |
The contributors are also the users at the same time. ❤️ |
I feel like it could be a nice way to point people at a working (CI) example as well. |
@@ -0,0 +1,47 @@ | |||
name: Conventional Commitlint |
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.
Not sure when our docs were updated last. Should this here just be exactly this?
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 think CI
is ambiguous.
So I use Conventional Commitlint
.
Another workflow uses Validate Commits
.
It might be good to update the example name.
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.
Ah sorry, I do not care about the name 📦
I meant this part:
- name: Install commitlint
run: npm install -D @commitlint/cli @commitlint/config-conventional
Also there is not build step in the docs
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.
Good question.
At first, I try to use install command like yarn add -D @commitlint/cli @commitlint/config-conventional
.
However, It failed due to conflict with local packages in this repository.
So I select build command instead of install.
Failed GitHub Actions
name: Conventional Commitlint
on:
push:
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
commitlint:
name: Commitlint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: lts/*
cache: yarn
- name: Install commitlint
run: yarn add -D @commitlint/cli @commitlint/config-conventional
- name: Print versions
run: |
git --version
node --version
npm --version
yarn --version
yarn commitlint --version
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: yarn commitlint --last --verbose
- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: yarn commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
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.
Uhm, thanks. The docs use npm
, does it work if you try npm
?
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.
npm
can install dependencies, but npx commitlint
command fails, either.
Failed GitHub Actions
name: Conventional Commitlint
on:
push:
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
commitlint:
name: Commitlint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: lts/*
cache: npm
- name: Install commitlint
run: npm install -D @commitlint/cli @commitlint/config-conventional
- name: Print versions
run: |
git --version
node --version
npm --version
yarn --version
npx commitlint --version
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: npx commitlint --last --verbose
- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
Perhaps this is also related to the workspaces definition in package.json.
Description
This PR adds a new GitHub Actions workflow that enforces Conventional Commit message conventions by installing dependencies, building the code, and validating commits on pushes, pull requests, and manual triggers.
File-Level Changes
.github/workflows/commitlint.yml
.github/workflows/commitlint.yml
.github/workflows/commitlint.yml
Motivation and Context
Introduce a Conventional Commitlint workflow to enforce commit message conventions.
Why doesn't official repo check the commit message?Usage examples
Sequence Diagram for the Commit Validation Process
How Has This Been Tested?
My forked repo and this commit's test were succeeded.
Types of changes
Checklist: