Skip to content

Commit

Permalink
CI: Add Test reports
Browse files Browse the repository at this point in the history
  • Loading branch information
remileduc committed Nov 9, 2023
1 parent 66318fc commit 809ca26
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 42 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/_build-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: 📥 Install
uses: remileduc/vcards-io/.github/actions/package-install@${{ github.ref_name }}
uses: ./.github/actions/package-install

- name: Build
run: npm run build
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,24 @@ jobs:
uses: ./.github/actions/package-install

- name: Run tests
run: npm test
run: npm run testci
env:
JEST_JUNIT_OUTPUT_DIR: coverage/reports
JEST_JUNIT_OUTPUT_NAME: jest-junit.xml
JEST_JUNIT_ANCESTOR_SEPARATOR: " > "
JEST_JUNIT_UNIQUE_OUTPUT_NAME: false
JEST_JUNIT_SUITE_NAME: "{filepath}"
JEST_JUNIT_CLASSNAME: "{classname}"
JEST_JUNIT_TITLE: "{title}"

- name: Report test results
if: success() || failure()
uses: dorny/test-reporter@v1
with:
name: Jest Tests
path: coverage/reports/jest-*.xml
reporter: jest-junit
list-suites: failed
list-tests: failed
fail-on-error: false
token: ${{ github.token }}
15 changes: 14 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
name: ⚙️ CI

on: push
on:
pull_request:
push:
branches:
- main

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read
actions: read
checks: write

jobs:
call-build-lint:
Expand Down
2 changes: 1 addition & 1 deletion lib/VcardIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ export class VCardIO
*/
fromString(str: string)
{
const vcard = stringutils.unfold(str).split("\r\n").filter((f) => f.length !== 0 && !/^\s+$/.test(f));
var vcard = stringutils.unfold(str).split("\r\n").filter((f) => f.length !== 0 && !/^\s+$/.test(f));

Check failure on line 385 in lib/VcardIO.ts

View workflow job for this annotation

GitHub Actions / ⚒️ Build - 🧹 Lint / Build

Unexpected var, use let or const instead
if (vcard.length < 3 || vcard.shift()?.toUpperCase() !== "BEGIN:VCARD" || vcard.pop()?.toUpperCase() !== "END:VCARD")
throw new Error("Invalid vCard: missing keywords");

Expand Down
43 changes: 43 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 39 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
{
"name": "vcards-io",
"version": "0.1.0",
"description": "vCard reader and writer - represents a vCard as a JSON object that can be exported",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"prepublish": "npm run build",
"build": "tsc",
"clean": "tsc --build --clean",
"test": "jest",
"lint": "eslint lib/",
"doc": "typedoc --plugin @mxssfd/typedoc-theme --theme my-theme --cleanOutputDir --includeVersion --readme ./README.md --out ./docs/ ./lib/index.ts"
},
"keywords": [
"vCard",
"vCards",
"vcf",
"contacts"
],
"author": {
"name": "Rémi Ducceschi",
"url": "https://github.com/remileduc",
"email": "[email protected]"
},
"license": "MIT",
"devDependencies": {
"@mxssfd/typedoc-theme": "^1.1.3",
"@types/jest": "^29.5.7",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"eslint": "^8.53.0",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"typedoc": "^0.25.3",
"typescript": "^5.2.2"
}
"name": "vcards-io",
"version": "0.1.0",
"description": "vCard reader and writer - represents a vCard as a JSON object that can be exported",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"prepublish": "npm run build",
"build": "tsc",
"clean": "tsc --build --clean",
"test": "jest",
"testci": "jest --ci --testResultsProcessor='jest-junit'",
"lint": "eslint lib/",
"doc": "typedoc --plugin @mxssfd/typedoc-theme --theme my-theme --cleanOutputDir --includeVersion --readme ./README.md --out ./docs/ ./lib/index.ts"
},
"keywords": [
"vCard",
"vCards",
"vcf",
"contacts"
],
"author": {
"name": "Rémi Ducceschi",
"url": "https://github.com/remileduc",
"email": "[email protected]"
},
"license": "MIT",
"devDependencies": {
"@mxssfd/typedoc-theme": "^1.1.3",
"@types/jest": "^29.5.7",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"eslint": "^8.53.0",
"jest": "^29.7.0",
"jest-junit": "^16.0.0",
"ts-jest": "^29.1.1",
"typedoc": "^0.25.3",
"typescript": "^5.2.2"
}
}
2 changes: 1 addition & 1 deletion tests/stringutils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("ICaseMap", () => {
const icaseMap = new stringutils.ICaseMap<string>();
icaseMap.set("KEY1", "Value1");

expect(icaseMap.has("key1")).toBe(true);
expect(icaseMap.has("key")).toBe(true);

Check failure on line 18 in tests/stringutils.test.ts

View workflow job for this annotation

GitHub Actions / Jest Tests

tests/stringutils.test.ts ► ICaseMap ► should correctly check if a key exists in a case-insensitive manner

Failed test found in: coverage/reports/jest-junit.xml Error: Error: expect(received).toBe(expected) // Object.is equality
Raw output
Error: expect(received).toBe(expected) // Object.is equality

Expected: true
Received: false
    at Object.<anonymous> (/home/runner/work/vcards-io/vcards-io/tests/stringutils.test.ts:18:31)
    at Promise.then.completed (/home/runner/work/vcards-io/vcards-io/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/home/runner/work/vcards-io/vcards-io/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (/home/runner/work/vcards-io/vcards-io/node_modules/jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/home/runner/work/vcards-io/vcards-io/node_modules/jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (/home/runner/work/vcards-io/vcards-io/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/home/runner/work/vcards-io/vcards-io/node_modules/jest-circus/build/run.js:121:9)
    at run (/home/runner/work/vcards-io/vcards-io/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/home/runner/work/vcards-io/vcards-io/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (/home/runner/work/vcards-io/vcards-io/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (/home/runner/work/vcards-io/vcards-io/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (/home/runner/work/vcards-io/vcards-io/node_modules/jest-runner/build/runTest.js:444:34)
    at Object.worker (/home/runner/work/vcards-io/vcards-io/node_modules/jest-runner/build/testWorker.js:106:12)
expect(icaseMap.has("Key1")).toBe(true);
expect(icaseMap.has("nonExistentKey")).toBe(false);
});
Expand Down

0 comments on commit 809ca26

Please sign in to comment.