Skip to content

Commit 5bb8717

Browse files
committed
ci(workflows): [ci] add commitlint job
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 514fa2b commit 5bb8717

File tree

2 files changed

+44
-9
lines changed

2 files changed

+44
-9
lines changed

.github/workflows/ci.yml

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ env:
3838
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3939
HUSKY: 0
4040
REF: ${{ github.head_ref || github.ref_name }}
41+
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
4142
concurrency:
4243
group: ${{ github.workflow }}-${{ github.ref }}
4344
cancel-in-progress: true
@@ -82,9 +83,38 @@ jobs:
8283
- id: version-typescript
8384
name: Get TypeScript version
8485
run: echo "result=$(jq .devDependencies.typescript package.json -r)" >> $GITHUB_OUTPUT
85-
gitguardian:
86+
commitlint:
8687
needs: metadata
8788
runs-on: ubuntu-latest
89+
steps:
90+
- id: checkout
91+
name: Checkout ${{ env.REF }}
92+
uses: actions/checkout@v3.3.0
93+
with:
94+
fetch-depth: 0
95+
ref: ${{ env.REF }}
96+
- id: node
97+
name: Setup Node.js
98+
uses: actions/setup-node@v3.6.0
99+
with:
100+
cache: yarn
101+
cache-dependency-path: yarn.lock
102+
node-version-file: .nvmrc
103+
- id: cache
104+
name: Restore dependencies cache
105+
uses: actions/cache@v3.2.6
106+
with:
107+
key: ${{ runner.os }}-${{ github.run_id }}
108+
path: ${{ env.CACHE_PATH }}
109+
- id: build
110+
name: Build project
111+
run: yarn build
112+
- id: lint
113+
name: Check commitlint status
114+
run: yarn commitlint --from $SHA~${{ github.event.pull_request.commits || 1 }} --to $SHA
115+
gitguardian:
116+
needs: commitlint
117+
runs-on: ubuntu-latest
88118
steps:
89119
- id: checkout
90120
name: Checkout ${{ env.REF }}
@@ -104,7 +134,7 @@ jobs:
104134
GITHUB_PUSH_BASE_SHA: ${{ github.event.base }}
105135
GITHUB_PUSH_BEFORE_SHA: ${{ github.event.before }}
106136
format:
107-
needs: metadata
137+
needs: commitlint
108138
runs-on: ubuntu-latest
109139
steps:
110140
- id: checkout
@@ -129,7 +159,7 @@ jobs:
129159
name: Check code formatting
130160
run: yarn check:format
131161
lint:
132-
needs: metadata
162+
needs: commitlint
133163
runs-on: ubuntu-latest
134164
steps:
135165
- id: checkout
@@ -157,7 +187,7 @@ jobs:
157187
name: Check lint status
158188
run: yarn check:lint
159189
spelling:
160-
needs: metadata
190+
needs: commitlint
161191
runs-on: ubuntu-latest
162192
steps:
163193
- id: checkout
@@ -182,7 +212,9 @@ jobs:
182212
name: Check spelling
183213
run: yarn check:spelling
184214
typescript:
185-
needs: metadata
215+
needs:
216+
- commitlint
217+
- metadata
186218
runs-on: ubuntu-latest
187219
strategy:
188220
fail-fast: false
@@ -229,7 +261,7 @@ jobs:
229261
name: Run typecheck
230262
run: yarn typecheck
231263
test:
232-
needs: metadata
264+
needs: commitlint
233265
runs-on: ubuntu-latest
234266
strategy:
235267
fail-fast: false
@@ -271,18 +303,20 @@ jobs:
271303
flags: ${{ format('node{0}', matrix.node-version) }}
272304
override_branch: ${{ env.REF }}
273305
override_build: ${{ github.run_id }}
274-
override_commit: ${{ env.GITHUB_SHA }}
306+
override_commit: ${{ env.SHA }}
275307
token: ${{ secrets.CODECOV_TOKEN }}
276308
verbose: true
277309
env:
278310
GITHUB_JOB: ${{ github.job }}
279311
GITHUB_REF: ${{ github.ref }}
280312
GITHUB_REF_TYPE: ${{ github.ref_type }}
281313
GITHUB_RUN_ID: ${{ github.run_id }}
282-
GITHUB_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
314+
GITHUB_SHA: ${{ env.SHA }}
283315
GITHUB_WORKSPACE: ${{ github.workspace }}
284316
build:
285-
needs: metadata
317+
needs:
318+
- commitlint
319+
- metadata
286320
runs-on: ubuntu-latest
287321
steps:
288322
- id: checkout

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"clean:test": "yarn clean:coverage && trash ./__tests__/report.json",
5858
"codecov": "yarn test:cov && yarn test:cov:upload",
5959
"codecov:validate": "cat .codecov.yml | curl --data-binary @- https://codecov.io/validate",
60+
"commitlint": "commitlint --strict --verbose",
6061
"fix:cg": "yarn fix:format && yarn fix:lint",
6162
"fix:dedupe": "yarn dedupe --strategy=highest",
6263
"fix:format": "prettier --cache --write .",

0 commit comments

Comments
 (0)