2022-04-08 02:49:13 +08:00
|
|
|
name: 🧪 Unit Test
|
2020-07-25 23:38:24 +08:00
|
|
|
|
2024-01-30 15:00:23 +08:00
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
workflow_dispatch:
|
2020-07-25 23:38:24 +08:00
|
|
|
|
2022-06-25 22:18:54 +08:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2020-07-25 23:38:24 +08:00
|
|
|
jobs:
|
2022-09-14 09:50:55 +08:00
|
|
|
lint:
|
|
|
|
name: Lint
|
2020-07-25 23:38:24 +08:00
|
|
|
runs-on: ubuntu-latest
|
2022-05-24 22:54:34 +08:00
|
|
|
|
2020-07-25 23:38:24 +08:00
|
|
|
steps:
|
2022-03-07 10:52:16 +08:00
|
|
|
- uses: actions/checkout@v3
|
2021-10-01 14:17:16 +08:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2022-05-24 22:54:34 +08:00
|
|
|
|
2021-10-01 14:17:16 +08:00
|
|
|
- name: Add dev branch
|
|
|
|
run: git branch dev origin/dev
|
2022-05-24 22:54:34 +08:00
|
|
|
|
2021-09-23 08:12:37 +08:00
|
|
|
- name: Setup pnpm
|
|
|
|
uses: pnpm/action-setup@v2
|
2022-05-05 11:02:20 +08:00
|
|
|
|
2020-08-03 18:07:29 +08:00
|
|
|
- name: Setup node
|
2022-02-25 20:05:11 +08:00
|
|
|
uses: actions/setup-node@v3
|
2020-12-31 11:12:52 +08:00
|
|
|
with:
|
2022-09-14 09:50:55 +08:00
|
|
|
node-version: 16
|
2022-09-22 09:04:40 +08:00
|
|
|
|
|
|
|
- name: Get pnpm store directory
|
|
|
|
id: pnpm-cache
|
|
|
|
run: |
|
2022-10-27 15:17:05 +08:00
|
|
|
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
|
2022-09-22 09:04:40 +08:00
|
|
|
|
|
|
|
- uses: actions/cache@v3
|
|
|
|
name: Setup pnpm cache
|
|
|
|
with:
|
|
|
|
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
|
|
|
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-pnpm-store-
|
2022-02-21 16:11:17 +08:00
|
|
|
|
2020-08-03 18:07:29 +08:00
|
|
|
- name: Install dependencies
|
2021-10-16 20:58:41 +08:00
|
|
|
run: pnpm i --frozen-lockfile
|
2022-05-24 22:54:34 +08:00
|
|
|
|
2020-08-04 10:49:49 +08:00
|
|
|
- name: Lint
|
2021-09-23 08:12:37 +08:00
|
|
|
run: pnpm lint
|
2022-05-24 22:54:34 +08:00
|
|
|
|
|
|
|
- name: Type Check
|
|
|
|
run: pnpm typecheck
|
|
|
|
|
2022-09-14 09:50:55 +08:00
|
|
|
build:
|
|
|
|
name: Unit Test (${{ matrix.node-name }})
|
|
|
|
runs-on: ubuntu-latest
|
2022-09-22 09:04:40 +08:00
|
|
|
|
2022-09-14 09:50:55 +08:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-09-22 09:04:40 +08:00
|
|
|
node-version: [16]
|
2022-09-14 09:50:55 +08:00
|
|
|
include:
|
2022-09-22 09:04:40 +08:00
|
|
|
- node-version: 16
|
|
|
|
node-name: LTS
|
|
|
|
# - node-version: 18
|
|
|
|
# node-name: Current
|
2022-09-14 09:50:55 +08:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Setup pnpm
|
|
|
|
uses: pnpm/action-setup@v2
|
|
|
|
|
|
|
|
- name: Setup node
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node-version }}
|
2022-09-22 09:04:40 +08:00
|
|
|
|
|
|
|
- name: Get pnpm store directory
|
|
|
|
id: pnpm-cache
|
|
|
|
run: |
|
2022-10-27 15:17:05 +08:00
|
|
|
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
|
2022-09-22 09:04:40 +08:00
|
|
|
|
|
|
|
- uses: actions/cache@v3
|
|
|
|
name: Setup pnpm cache
|
|
|
|
with:
|
|
|
|
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
|
|
|
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-pnpm-store-
|
2022-09-14 09:50:55 +08:00
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: pnpm i --frozen-lockfile
|
|
|
|
|
2022-01-11 15:14:39 +08:00
|
|
|
- name: Test
|
2022-04-19 16:51:44 +08:00
|
|
|
run: pnpm test
|