Skip to content

Commit

Permalink
chore: update workflow and related configs
Browse files Browse the repository at this point in the history
  • Loading branch information
tianenpang committed Nov 12, 2024
1 parent 01342bf commit 349ca7f
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 42 deletions.
7 changes: 5 additions & 2 deletions .commitlintrc.cjs → .commitlintrc.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const conventional = require("@commitlint/config-conventional");
import conventional from "@commitlint/config-conventional";

module.exports = {

const commitLintConfig = {
extends: ["@commitlint/config-conventional"],
plugins: ["commitlint-plugin-function-rules"],
helpUrl:
Expand All @@ -15,3 +16,5 @@ module.exports = {
"function-rules/header-max-length": [0],
},
};

export default commitLintConfig;
28 changes: 23 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,36 @@ jobs:
script: [lint, test, build]
steps:
- name: Checkout Codebase
uses: actions/checkout@v3
- name: Setup Pnpm
uses: pnpm/action-setup@v2
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Setup Node
uses: actions/setup-node@v3

- name: Setup node
uses: actions/setup-node@v4
with:
cache: "pnpm"
check-latest: true
node-version-file: ".nvmrc"

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Dependencies
shell: bash
run: pnpm install --frozen-lockfile

- name: Run Script ${{ matrix.script }}
run: pnpm ${{ matrix.script }}
36 changes: 17 additions & 19 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,29 @@ on: [pull_request]

jobs:
commitlint:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
environment: Preview

steps:
- name: Checkout Codebase
uses: actions/checkout@v3
- name: Checkout codebase
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
run_install: false
- name: Setup Node
uses: actions/setup-node@v3
with:
cache: "pnpm"
check-latest: true
node-version-file: ".nvmrc"
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Run Commitlint

- name: Install dependencies
uses: ./.github/actions/install

- name: Run commitlint
id: run_commitlint
uses: wagoid/commitlint-github-action@v5
uses: wagoid/commitlint-github-action@v6
with:
configFile: .commitlintrc.cjs
configFile: .commitlintrc.mjs
env:
NODE_PATH: ${{ github.workspace }}/node_modules
- name: Show Outputs

- name: Show outputs
if: ${{ always() }}
run: echo ${{ toJSON(steps.run_commitlint.outputs.results) }}
5 changes: 1 addition & 4 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm commitlint --config .commitlintrc.cjs --edit ${1}
pnpm commitlint --config .commitlintrc.mjs --edit ${1}
10 changes: 1 addition & 9 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# Avoid excessive outputs
if [ -t 2 ]; then
exec >/dev/tty 2>&1
fi

pnpm lint-staged
pnpm lint-staged -c .lintstagedrc.mjs
9 changes: 6 additions & 3 deletions .lintstagedrc.cjs → .lintstagedrc.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {relative} = require("path");
import {relative} from "path";

const {ESLint} = require("eslint");
import {ESLint} from "eslint";

const removeIgnoredFiles = async (files) => {
const cwd = process.cwd();
Expand All @@ -12,7 +12,8 @@ const removeIgnoredFiles = async (files) => {
return filteredFiles.join(" ");
};

module.exports = {

const lintStaged = {
// *.!(js|ts|jsx|tsx|d.ts)
"**/*.{js,cjs,mjs,ts,jsx,tsx,json,md}": async (files) => {
const filesToLint = await removeIgnoredFiles(files);
Expand All @@ -25,3 +26,5 @@ module.exports = {
return [`eslint -c .eslintrc.json --max-warnings=0 --fix ${filesToLint}`];
},
};

export default lintStaged;

0 comments on commit 349ca7f

Please sign in to comment.