fix: add commitlint as husky pre-commit hook and ci check #67
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: [push] | |
jobs: | |
install: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: "npm" | |
- uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
- name: install dependencies | |
run: npm ci --ignore-scripts # don't install husky hooks when in ci | |
- name: Validate current commit (last commit) message with commitlint | |
if: github.event_name == 'push' | |
run: npx commitlint --last --verbose | |
- name: Validate PR commits messages 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 | |
- name: lint typescript code | |
run: npm run lint | |
- name: build typescript | |
run: npm run build | |
- name: run unit test | |
run: npm run test | |
### Integration tests | |
- name: Setup iggy | |
uses: iggy-rs/setup-iggy@v1 | |
- name: Perform integration tests | |
run: npm run test:e2e | |
semantic-release: | |
needs: install | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ secrets.DEPLOY_APP_ID }} | |
private-key: ${{ secrets.DEPLOY_APP_KEY }} | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ steps.app-token.outputs.token }} | |
# Make sure the value of GITHUB_TOKEN will not be persisted in repo's config | |
persist-credentials: false | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: "npm" | |
- run: npm ci | |
- run: npm run build | |
- name: Semantic Release | |
uses: cycjimmy/semantic-release-action@v4 | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
VERSION.txt | |
package.json | |
package-lock.json | |
CHANGELOG.md | |
key: ${{ runner.os }}-sr-version-${{ github.sha }} |