Skip to content

Commit

Permalink
fix: optimize ci (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
khuongln-1346 authored Nov 4, 2024
1 parent 317bc73 commit 121f4e5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
34 changes: 29 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- '!docs/**'
pull_request:
branches: [ 'main' ]
types: [opened, synchronize]
paths:
- 'src/**'
- 'test/**'
Expand All @@ -25,6 +26,8 @@ permissions:

jobs:
build-and-test:
name: Build and test
timeout-minutes: 15
# skip ci if PR has label 'skip-ci' or 'skip-actions'
if: |
!contains(github.event.pull_request.labels.*.name, 'skip-ci') &&
Expand All @@ -39,19 +42,40 @@ jobs:
steps:
- name: Copy repository
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
cache-dependency-path: ./pnpm-lock.yaml

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false

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

- name: Lint code
run: pnpm lint

- name: Build project
run: pnpm build

- name: Build docs
run: pnpm docs:build

- name: Run UT tests
run: pnpm test
4 changes: 2 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
BRANCH=$(git rev-parse --abbrev-ref HEAD)
REGEX="^(feature|bugfix|hotfix|release|merge)\.([a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*)$"
REGEX="^(feature|feat|chore|fix|bugfix|hotfix|docs|refactor|test|build|perf|style|ci|release|merge)\.([a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*)$"

RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
echo "Branch name: ${GREEN}$BRANCH${NC}"
if ! echo "$BRANCH" | grep -qE "$REGEX"; then
echo "${RED}Your commit was rejected due to branching name"
echo "Please rename your branch with '(feature|bugfix|hotfix|release|merge)(.<ticket>?).<subject-example>' syntax${NC}"
echo "Please rename your branch with '(feature|feat|chore|fix|bugfix|hotfix|docs|refactor|test|build|perf|style|ci|release|merge)(.<ticket>?).<subject-example>' syntax${NC}"
exit 1
fi

Expand Down

0 comments on commit 121f4e5

Please sign in to comment.