Skip to content
Open
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
27 changes: 0 additions & 27 deletions .github/workflows/sonarqube.yml

This file was deleted.

70 changes: 46 additions & 24 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ jobs:
--shard "$SHARD" \
--cacheDirectory /tmp/jest_cache
env:
JEST_SONAR_UNIQUE_OUTPUT_NAME: true

# tell jest to use coloured output
FORCE_COLOR: true
MAX_WORKERS: ${{ steps.cpu-cores.outputs.count }}
Expand All @@ -103,28 +101,6 @@ jobs:
apps/web/coverage
!apps/web/coverage/lcov-report

complete:
name: jest-tests
needs: [jest_ew, vitest]
if: always()
runs-on: ubuntu-24.04
permissions:
statuses: write
steps:
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1

- name: Skip SonarCloud in merge queue
if: github.event_name == 'merge_group' || inputs.disable_coverage == 'true'
uses: guibranco/github-status-action-v2@9bfa8773cdbdc6c185747fd43cd7faa9d7c32f09
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
state: success
description: SonarCloud skipped
context: SonarCloud Code Analysis
sha: ${{ github.sha }}
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

vitest:
name: Vitest
strategy:
Expand Down Expand Up @@ -191,3 +167,49 @@ jobs:
path: |
${{ matrix.path }}/coverage
!${{ matrix.path }}/coverage/lcov-report

complete:
name: Tests
needs:
- jest_ew
- vitest
if: always()
runs-on: ubuntu-24.04
permissions:
contents: read
pull-requests: read
checks: write
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
if: needs.test.result == 'success' && env.ENABLE_COVERAGE == 'true'
with:
persist-credentials: false
fetch-depth: 0 # Full history, fastest for diff-cover

- name: Download coverage artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
if: needs.test.result == 'success' && env.ENABLE_COVERAGE == 'true'
with:
pattern: coverage-*
path: coverage

- name: Diff Coverage
id: coverage
if: needs.test.result == 'success' && env.ENABLE_COVERAGE == 'true'
uses: Affanmir/diff-cover-action@0d8c98f613bbd2428df50b3109b1e3b1d5ab59d3 # v2.1.0
with:
compare-branch: origin/${{ github.base_ref || 'develop' }}
mode: coverage
coverage-files: coverage/*/*lcov.info
ignore-whitespace: true
show-uncovered: true
post-comment: false
create-annotations: true
annotation-type: warning
fail-on-threshold: ${{ contains(github.event.pull_request.labels.*.name, 'Z-Skip-Coverage') && 'false' || 'true' }}
fail-under: 80

- name: Check status of tests
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
5 changes: 3 additions & 2 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
"test:playwright": "nx test:playwright --",
"test:playwright:open": "nx test:playwright -- --ui",
"test:playwright:screenshots": "nx test:playwright:screenshots --",
"coverage": "pnpm test:unit --coverage",
"coverage:diff": "diff-cover --config-file ../../diff-cover.toml coverage/lcov.info",
"sane-postinstall": "electron-builder install-app-deps"
},
"dependencies": {
Expand Down Expand Up @@ -106,8 +108,7 @@
"rimraf": "^6.0.0",
"tar": "^7.5.8",
"typescript": "6.0.3",
"vitest": "catalog:",
"vitest-sonar-reporter": "catalog:"
"vitest": "catalog:"
},
"hakDependencies": {
"matrix-seshat": "4.3.0"
Expand Down
1 change: 0 additions & 1 deletion apps/web/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ if (env["GITHUB_ACTIONS"] !== undefined) {
config.reporters ??= [];
config.reporters.push(["github-actions", { silent: false }]);
config.reporters.push("summary");
config.reporters.push("@casualbot/jest-sonar-reporter");

// if we're running against the develop branch, also enable the slow test reporter
if (env["GITHUB_REF"] == "refs/heads/develop") {
Expand Down
7 changes: 1 addition & 6 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"test:playwright:open": "nx test:playwright -- --ui",
"test:playwright:screenshots": "nx test:playwright:screenshots --",
"coverage": "pnpm test --coverage",
"coverage:diff": "diff-cover --config-file ../../diff-cover.toml coverage/lcov.info",
"analyse:webpack-bundles": "webpack-bundle-analyzer webpack-stats.json webapp"
},
"dependencies": {
Expand Down Expand Up @@ -125,7 +126,6 @@
"@babel/preset-env": "^7.12.11",
"@babel/preset-react": "^7.12.10",
"@babel/preset-typescript": "^7.12.7",
"@casualbot/jest-sonar-reporter": "2.7.1",
"@element-hq/element-call-embedded": "0.19.4",
"@element-hq/element-web-playwright-common": "workspace:*",
"@fetch-mock/jest": "^0.2.20",
Expand Down Expand Up @@ -236,11 +236,6 @@
"webpack-version-file-plugin": "^0.5.0",
"yaml": "^2.3.3"
},
"@casualbot/jest-sonar-reporter": {
"outputDirectory": "coverage",
"outputName": "jest-sonar-report.xml",
"relativePaths": true
},
"engines": {
"node": ">=22.18"
},
Expand Down
2 changes: 2 additions & 0 deletions diff-cover.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.diff_cover]
compare_branch = "origin/develop"
6 changes: 5 additions & 1 deletion knip.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { KnipConfig } from "knip";

// Specify this as knip loads config files which may conditionally add reporters, e.g. `@casualbot/jest-sonar-reporter'
// Specify this as knip loads config files which may conditionally load plugins
process.env.GITHUB_ACTIONS = "1";

export default {
Expand Down Expand Up @@ -67,6 +67,10 @@ export default {
"events",
],
ignoreExportsUsedInFile: true,
ignoreBinaries: [
// Optional for coverage:diff development script
"diff-cover",
],
compilers: {
pcss: (text: string) =>
[...text.matchAll(/@import\s+(?:url\()?["']([^"']+)["']\)?[^;]*;/g)]
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"postinstall": "node scripts/pnpm-link.ts && pnpm run -r sane-postinstall",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs"
"docs:preview": "vitepress preview docs",
"coverage:diff": "diff-cover --config-file diff-cover.toml apps/*/coverage/lcov.info packages/*/coverage/lcov.info"
},
"devDependencies": {
"@action-validator/cli": "^0.6.0",
Expand Down
7 changes: 4 additions & 3 deletions packages/module-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"scripts": {
"prepack": "nx build",
"lint:types": "nx lint:types",
"test:unit": "vitest"
"test:unit": "vitest",
"coverage": "pnpm test:unit --coverage",
"coverage:diff": "diff-cover --config-file ../../diff-cover.toml coverage/lcov.info"
},
"devDependencies": {
"@element-hq/vite-common": "workspace:*",
Expand All @@ -44,8 +46,7 @@
"typescript": "^6.0.0",
"unplugin-dts": "1.0.1",
"vite": "catalog:",
"vitest": "catalog:",
"vitest-sonar-reporter": "catalog:"
"vitest": "catalog:"
},
"peerDependencies": {
"@matrix-org/react-sdk-module-api": "*",
Expand Down
5 changes: 3 additions & 2 deletions packages/shared-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
"test:unit": "nx test:unit",
"test:storybook": "nx test:storybook",
"test:storybook:update": "nx test:storybook:update",
"coverage": "pnpm test:unit --coverage",
"coverage:diff": "diff-cover --config-file ../../diff-cover.toml coverage/lcov.info",
"build": "nx build",
"prepack": "pnpm run build",
"storybook": "storybook dev -p 6007",
Expand Down Expand Up @@ -132,8 +134,7 @@
"unplugin-dts": "1.0.1",
"vite": "catalog:",
"vite-plugin-node-polyfills": "^0.28.0",
"vitest": "catalog:",
"vitest-sonar-reporter": "catalog:"
"vitest": "catalog:"
},
"engines": {
"node": ">=20.0.0"
Expand Down
3 changes: 1 addition & 2 deletions packages/vite-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"typescript": "catalog:"
},
"peerDependencies": {
"@vitest/coverage-v8": "catalog:",
"vitest-sonar-reporter": "catalog:"
"@vitest/coverage-v8": "catalog:"
}
}
7 changes: 0 additions & 7 deletions packages/vite-common/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ const slowTestReporter: Reporter = {
// if we're running under GHA, enable the GHA & Sonar reporters
if (env["GITHUB_ACTIONS"] !== undefined) {
reporters.push(["github-actions", { silent: false }]);
reporters.push([
"vitest-sonar-reporter",
{
outputFile: "coverage/sonar-report.xml",
onWritePath: (path): string => `${process.cwd()}/${path}`,
},
]);

// if we're running against the develop branch, also enable the slow test reporter
if (env["GITHUB_REF"] == "refs/heads/develop") {
Expand Down
Loading
Loading