Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
汪航洋 committed Jul 31, 2023
1 parent 27acc47 commit f467002
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 14 deletions.
55 changes: 44 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,60 @@ on:
branches: [ "master" ]

jobs:

build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x]
# strategy:
# matrix:
# node-version: [16.x, 18.x]

steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
# - name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
node-version: 16.x
# node-version: ${{ matrix.node-version }}

- name: npm install
run: npm install

- name: Build
run: npm run build

- name: Test
run: |
npm install
npm coverage
npm run build
npm run coverage -- --noOpen
# # 手动调 coveralls
# - name: Coveralls
# env:
# COVERALLS_SERVICE_NAME: 'GitHub CI'
# COVERALLS_GIT_BRANCH: master
# COVERALLS_REPO_TOKEN : ${{ secrets.COVERALLS_REPO_TOKEN }}
# NODE_COVERALLS_DEBUG: 0 # or 1 for verbsoe
# run: |
# npm install coveralls -g
# npx nyc report --reporter=text-lcov | coveralls
- name: out lcov file
run: npx nyc report --reporter=text-lcov > ./coverage/test.lcov
- name: Coveralls
run: |
npm install coveralls
nyc report --reporter=text-lcov | coveralls
uses: coverallsapp/github-action@v2
with:
# github-token: ${{ github.token }}
debug: true

# Badge:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: out lcov file
# run: npx nyc report --reporter=text-lcov > ./coverage/test.lcov
# - name: Coveralls
# uses: coverallsapp/github-action@v2
# with:
# # github-token: ${{ github.token }}
# debug: true
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"prebuild": "npm run clean",
"test": "node ./script/test.js",
"test:speed": "node ./script/puppeteer ./test/speedTest",
"coverage": "npm test -- --coverage --noOpen",
"coverage:auto": "npm test -- --coverage",
"coverage": "npm test -- --coverage",
"test-server": "vite ./test --port 3300",
"prepack": "npm test && npm run build"
},
Expand Down
14 changes: 13 additions & 1 deletion script/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,23 @@ const v8toIstanbul = require("v8-to-istanbul");

const port = 3300;


// 覆盖率 json 输出目录
const outDir = path.join(__dirname, "../.nyc_output");
// vite 启动测试服务的路径
const root = path.join(__dirname,'../test');
// 项目目录
const codePath = path.join(__dirname, "..").replace(/\\/g, "/");
// 筛选需要导出覆盖率的文件
const coverageInclude = new RegExp(codePath + "/(lib|src)");

console.log('[config]',{
outDir,
root,
codePath,
coverageInclude
})

const args = process.argv.slice(2);
const noOpen = args.includes("--noOpen");
const coverage = args.includes("--coverage");
Expand Down Expand Up @@ -102,7 +114,7 @@ async function main() {
let outJson = {};
for (let k of out) {
let url = new URL(k.url);
url = url.pathname.replace("/@fs/", "");
url = url.pathname.replace("/@fs/", "/");
const converter = v8toIstanbul(url, undefined, {
source: k.text,
});
Expand Down

0 comments on commit f467002

Please sign in to comment.