From fe74ac126ea8404a10b4b0296f090f8dd5bc4a44 Mon Sep 17 00:00:00 2001 From: undsoft Date: Fri, 15 Nov 2024 12:50:44 +0100 Subject: [PATCH] NAS-132540: Enable additional codecov test analytics --- .github/workflows/main.yml | 22 +++++++++++++++-- jest.config.cjs | 10 ++++++++ package.json | 1 + yarn.lock | 48 ++++++++++++++++++++++++++++++++++---- 4 files changed, 75 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index afb675af1de..cea9f991852 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,7 +67,10 @@ jobs: - name: Run tests run: yarn test:pr --shard=${{ matrix.shard }}/${{ strategy.job-total }} - name: Save shard coverage - run: mv coverage/webui/coverage-final.json coverage/${{matrix.shard}}.json && rm -rf coverage/webui + run: | + mv coverage/webui/coverage-final.json coverage/coverage-${{matrix.shard}}.json + mv coverage/webui/junit.xml coverage/junit-${{matrix.shard}}.xml + rm -rf coverage/webui - name: Upload coverage uses: actions/upload-artifact@v4 with: @@ -77,6 +80,7 @@ jobs: report-coverage: name: Collect coverage runs-on: ubuntu-latest + if: ${{ !cancelled() }} needs: [test] env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} @@ -87,12 +91,26 @@ jobs: pattern: 'coverage-*' path: coverage merge-multiple: true + - name: Collect test data from shards + uses: actions/download-artifact@v4 + with: + pattern: 'junit-*' + path: coverage + merge-multiple: true - name: Merge Code Coverage run: npx -y nyc merge coverage/ coverage/merged-coverage.json - - name: Upload to Codecov + - name: Merge Test Data + run: npx -y junit-report-merger coverage/merged-junit.xml "coverage/junit-*.xml" + - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: name: webui token: ${{ env.CODECOV_TOKEN }} file: coverage/merged-coverage.json fail_ci_if_error: true + - name: Upload extra test data to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: coverage/merged-junit.xml diff --git a/jest.config.cjs b/jest.config.cjs index 62e6f5cc2d6..97a058e23ea 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -31,5 +31,15 @@ module.exports = { transformIgnorePatterns: [ `node_modules/(?!(${esmPatterns.join('|')}))` ], + reporters: [ + "default", + [ + "jest-junit", + { + classNameTemplate: "{filepath}", + outputDirectory: "/coverage/webui" + }, + ] + ], clearMocks: true, }; diff --git a/package.json b/package.json index 28d2cdb8e60..2406eb5ef4d 100644 --- a/package.json +++ b/package.json @@ -164,6 +164,7 @@ "jest": "~29.7.0", "jest-canvas-mock": "^2.5.0", "jest-fail-on-console": "~3.3.0", + "jest-junit": "~16.0.0", "jest-preset-angular": "~14.2.4", "jest-when": "~3.6.0", "jira-prepare-commit-msg": "^1.6.1", diff --git a/yarn.lock b/yarn.lock index e300f36a7ca..7c1fdac63dc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9872,6 +9872,16 @@ jest-haste-map@^29.7.0: optionalDependencies: fsevents "^2.3.2" +jest-junit@~16.0.0: + version "16.0.0" + resolved "https://registry.yarnpkg.com/jest-junit/-/jest-junit-16.0.0.tgz#d838e8c561cf9fdd7eb54f63020777eee4136785" + integrity sha512-A94mmw6NfJab4Fg/BlvVOUXzXgF0XIH6EmTgJ5NDPp4xoKq0Kr7sErb+4Xs9nZvu58pJojz5RFGpqnZYJTrRfQ== + dependencies: + mkdirp "^1.0.4" + strip-ansi "^6.0.1" + uuid "^8.3.2" + xml "^1.0.1" + jest-leak-detector@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz#5b7ec0dadfdfec0ca383dc9aa016d36b5ea4c728" @@ -11212,7 +11222,7 @@ mkdirp@^0.5.1: dependencies: minimist "^1.2.6" -mkdirp@^1.0.3: +mkdirp@^1.0.3, mkdirp@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== @@ -13185,7 +13195,16 @@ string-length@^4.0.1: char-regex "^1.0.2" strip-ansi "^6.0.0" -"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -13315,7 +13334,14 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@6, strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-ansi@6, strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -14411,7 +14437,7 @@ winston@^3.0.0, winston@^3.11.0: triple-beam "^1.3.0" winston-transport "^4.7.0" -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -14429,6 +14455,15 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" @@ -14470,6 +14505,11 @@ xml-name-validator@^4.0.0: resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-4.0.0.tgz#79a006e2e63149a8600f15430f0a4725d1524835" integrity sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw== +xml@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5" + integrity sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw== + xmlchars@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"