Skip to content

Commit

Permalink
chore: repo overall update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Nov 18, 2024
1 parent 78fea38 commit 95fb30d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/upload-canyon-report-coverage-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
- name: Install Playwright Browsers
run: cd packages/canyon-report && npx playwright install --with-deps
- name: Run Playwright tests
run: cd packages/canyon-report && npx playwright test && canyon-uploader hit
run: cd packages/canyon-report && npx playwright test && canyon-uploader hit --dsn=https://collect.canyonjs.org/coverage/map/client
24 changes: 18 additions & 6 deletions tools/canyon-uploader/src/commands/hit.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import fs from "node:fs";
import path from "node:path";
import axios from "axios";

export async function hitCommand(params, options) {
// const { dsn, project_id:projectID, sha:sha,instrument_cwd:instrumentCwd } = params;
const { dsn } = params;
// console.log(dsn, projectID, sha);

// 判断是否存在.canyon_output文件夹
Expand Down Expand Up @@ -33,13 +34,24 @@ export async function hitCommand(params, options) {
const data = JSON.parse(fileCoverageString);

if (Object.values(data).length>0){
const { sha, projectID, reportID } = data[Object.keys(data)[0]];
if (!map[`__${projectID}__${sha}__${reportID}__`]) {
map[`__${projectID}__${sha}__${reportID}__`] = [];
const { sha, projectID, reportID,instrumentCwd } = data[Object.keys(data)[0]];
if (!map[JSON.stringify({sha, projectID, reportID,instrumentCwd})]) {
map[JSON.stringify({sha, projectID, reportID,instrumentCwd})] = [];
}
map[`__${projectID}__${sha}__${reportID}__`].push(Object.keys(data).length);
map[JSON.stringify({sha, projectID, reportID,instrumentCwd})].push(Object.keys(data).length);
}

}
console.log(map);
// console.log(map);
return Promise.all(Object.entries(map).map( ([key, value]) => {
const {sha,projectID,instrumentCwd,reportID} = JSON.parse(key);
return axios.post(dsn, {
sha: sha,
projectID: projectID,
coverage: JSON.stringify(value[0]),
instrumentCwd: instrumentCwd,
branch: "",
reportID: reportID,
})
}))
}

0 comments on commit 95fb30d

Please sign in to comment.