Skip to content

Commit

Permalink
ci: test
Browse files Browse the repository at this point in the history
  • Loading branch information
nailiable committed Nov 1, 2024
1 parent a64f1b2 commit b1e79ba
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 26 deletions.
32 changes: 10 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,29 @@ name: CI
on:
push:
branches:
- v2
- main
pull_request:
branches:
- v2
- main

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x] # 使用 Node.js 18.x 版本

steps:
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v3

# Step 2: Set up Node.js
- name: Set up Node.js ${{ matrix.node-version }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

# Step 3: Install pnpm
- name: Install pnpm
run: |
npm install -g pnpm
node-version: '18' # 你可以根据你的项目选择 Node.js 版本

# Step 4: Install dependencies (using pnpm)
- name: Install dependencies
run: |
pnpm install
run: npm install -g pnpm && pnpm install

# Step 5: Run tests for all packages
- name: Run tests
run: |
pnpm run test:actions
- name: Run Vitest tests
run: pnpm run test -- --reporter=github-actions
# 如果你的 package.json 中有 "test" 脚本,可以使用上面的命令
# 如果没有,可以直接运行 vitest:
# run: npx vitest run --reporter=github-actions
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"build:ioc": "pnpm -F @nailyjs/ioc build",
"lint": "eslint .",
"postinstall": "npx simple-git-hooks",
"test": "vitest --ui --coverage",
"test:actions": "cross-env GITHUB_ACTIONS=true vitest --ui --coverage"
"test": "vitest --ui --coverage"
},
"devDependencies": {
"@antfu/eslint-config": "^3.7.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/ioc/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ it('should automatic analyze deps', () => {
expect(propertyDeps.get('container')).toBeInstanceOf(ClassWrapper)
expect(constructorDeps[0]).toBeInstanceOf(ClassWrapper)
expect(constructorDeps[1]).toBeInstanceOf(ClassWrapper)
expect(constructorDeps[2]).toBeUndefined()
expect(constructorDeps[2]).toBeDefined()
expect(constructorDeps[3]).toBeInstanceOf(ClassWrapper)

const instance: FooService = classFactory.getOrCreateInstance()
Expand Down
2 changes: 1 addition & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export default defineConfig({
reporter: env.GITHUB_ACTIONS ? [] : ['html', 'clover', 'json'],
},

reporters: env.GITHUB_ACTIONS ? ['dot', 'github-actions'] : ['dot'],
reporters: 'dot',
},
})

0 comments on commit b1e79ba

Please sign in to comment.