Skip to content

Commit 2923b80

Browse files
authored
ci: add commitlint to github actions (#3)
As anyone will be able to contribute to the project it is essencial to use a commit pattern. Running commitlint on Github Actions will make sure of that.
1 parent 866ac3d commit 2923b80

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

.github/workflows/commitlint.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
commitlint:
7+
runs-on: ubuntu-22.04
8+
steps:
9+
- uses: actions/checkout@v3
10+
with:
11+
fetch-depth: 0
12+
- name: Install required dependencies
13+
run: |
14+
sudo apt update
15+
sudo apt install -y sudo
16+
sudo apt install -y git curl
17+
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
18+
sudo DEBIAN_FRONTEND=noninteractive apt install -y nodejs
19+
- name: Print versions
20+
run: |
21+
git --version
22+
node --version
23+
npm --version
24+
npx commitlint --version
25+
- name: Install commitlint
26+
run: |
27+
npm install conventional-changelog-conventionalcommits
28+
npm install commitlint@latest
29+
30+
- name: Validate current commit (last commit) with commitlint
31+
if: github.event_name == 'push'
32+
run: npx commitlint --from HEAD~1 --to HEAD --verbose
33+
34+
- name: Validate PR commits with commitlint
35+
if: github.event_name == 'pull_request'
36+
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
},
3333
"devDependencies": {
3434
"@babel/core": "^7.20.0",
35+
"@commitlint/cli": "^18.0.0",
36+
"@commitlint/config-conventional": "^18.0.0",
3537
"@testing-library/react-native": "^12.4.1",
3638
"@types/jest": "^29.5.10",
3739
"@types/react": "~18.2.14",
@@ -50,6 +52,11 @@
5052
"jest": {
5153
"preset": "jest-expo"
5254
},
55+
"commitlint": {
56+
"extends": [
57+
"@commitlint/config-conventional"
58+
]
59+
},
5360
"license": "MIT",
5461
"private": true,
5562
"resolutions": {

0 commit comments

Comments
 (0)