Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,54 @@ on:
jobs:
run-unit-tests:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "20"
- run: yarn install
- run: yarn test
- run: yarn test:coverage
- name: Add coverage summary
if: always()
run: |
node <<'EOF'
const fs = require("fs");

const summaryPath = "coverage/coverage-summary.json";

if (!fs.existsSync(summaryPath)) {
fs.appendFileSync(
process.env.GITHUB_STEP_SUMMARY,
"## Coverage Summary\n\nCoverage summary was not generated.\n"
);
process.exit(0);
}

const summary = JSON.parse(fs.readFileSync(summaryPath, "utf8")).total;
const metrics = [
["Lines", summary.lines.pct],
["Statements", summary.statements.pct],
["Functions", summary.functions.pct],
["Branches", summary.branches.pct],
];

const output = [
"## Coverage Summary",
"",
"| Metric | Coverage |",
"| --- | ---: |",
...metrics.map(([label, value]) => `| ${label} | ${Number(value).toFixed(1)}% |`),
"",
].join("\n");

fs.appendFileSync(process.env.GITHUB_STEP_SUMMARY, output);
EOF
- name: Upload coverage to Codecov
if: always()
uses: codecov/codecov-action@v5
with:
files: ./coverage/lcov.info
fail_ci_if_error: false
verbose: true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
![alt text](https://github.com/eclipse-editdor/editdor/blob/master/logo/1585_ediTDor_logo.png "ediTDor logo")
[![Discord](https://img.shields.io/badge/Discord-7289DA?logo=discord&logoColor=white&label=WoT-CG-Discord)](https://discord.com/channels/1081253871688622181/1359286591100817549)
[![Coverage](https://codecov.io/gh/eclipse-editdor/editdor/graph/badge.svg?branch=master)](https://codecov.io/gh/eclipse-editdor/editdor)

A tool for simply designing W3C Thing Descriptions and Thing Models

Expand Down
5 changes: 5 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export default defineConfig(({ mode }) => {
environment: "jsdom",
setupFiles: "./src/setupTests.ts",
include: ["src/**/*.{test,spec}.{ts,tsx}"],
coverage: {
provider: "v8",
reportsDirectory: "./coverage",
reporter: ["text", "json-summary", "lcov"],
},
},
};
});
Loading