From 58cbc5148cd6117bcfab5c98bc3b125000a3a9e4 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Mon, 4 Dec 2023 18:39:52 -0300 Subject: [PATCH 1/2] chore: rocketchat:coverage package (#30339) --- .github/actions/meteor-build/action.yml | 9 +++- .github/workflows/ci-test-e2e.yml | 29 ++++++++++ apps/meteor/package.json | 2 +- .../.npm/package/.gitignore | 1 + .../rocketchat-coverage/.npm/package/README | 7 +++ .../.npm/package/npm-shrinkwrap.json | 52 ++++++++++++++++++ .../packages/rocketchat-coverage/package.js | 18 +++++++ .../plugin/compile-version.js | 54 +++++++++++++++++++ codecov.yml | 2 + docker-compose-ci.yml | 4 ++ 10 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 apps/meteor/packages/rocketchat-coverage/.npm/package/.gitignore create mode 100644 apps/meteor/packages/rocketchat-coverage/.npm/package/README create mode 100644 apps/meteor/packages/rocketchat-coverage/.npm/package/npm-shrinkwrap.json create mode 100644 apps/meteor/packages/rocketchat-coverage/package.js create mode 100644 apps/meteor/packages/rocketchat-coverage/plugin/compile-version.js diff --git a/.github/actions/meteor-build/action.yml b/.github/actions/meteor-build/action.yml index 21fec059c8de..0229e5bb5ba0 100644 --- a/.github/actions/meteor-build/action.yml +++ b/.github/actions/meteor-build/action.yml @@ -109,7 +109,14 @@ runs: env: METEOR_PROFILE: 1000 BABEL_ENV: ${{ inputs.coverage == 'true' && 'coverage' || '' }} - run: yarn build:ci -- --directory /tmp/dist + run: | + # check if BABEL_ENV is set to coverage + if [[ $BABEL_ENV == "coverage" ]]; then + echo -e "rocketchat:coverage\n" >> ./apps/meteor/.meteor/packages + echo "Coverage enabled" + fi + + yarn build:ci -- --directory /tmp/dist - name: Build Rocket.Chat shell: bash diff --git a/.github/workflows/ci-test-e2e.yml b/.github/workflows/ci-test-e2e.yml index e70d4c80217e..eb7b228022c3 100644 --- a/.github/workflows/ci-test-e2e.yml +++ b/.github/workflows/ci-test-e2e.yml @@ -127,6 +127,12 @@ jobs: - run: yarn build + - name: Prepare code coverage directory + if: inputs.release == 'ee' + run: | + mkdir -p /tmp/coverage + chmod 777 /tmp/coverage + - name: Start containers for CE if: inputs.release == 'ce' env: @@ -141,6 +147,8 @@ jobs: MONGO_URL: 'mongodb://host.docker.internal:27017/rocketchat?replicaSet=rs0&directConnection=true' ENTERPRISE_LICENSE: ${{ inputs.enterprise-license }} TRANSPORTER: ${{ inputs.transporter }} + COVERAGE_DIR: '/tmp/coverage' + COVERAGE_REPORTER: 'lcov' run: | docker compose -f docker-compose-ci.yml up -d @@ -184,6 +192,8 @@ jobs: env: WEBHOOK_TEST_URL: 'http://host.docker.internal:10000' IS_EE: ${{ inputs.release == 'ee' && 'true' || '' }} + COVERAGE_DIR: '/tmp/coverage' + COVERAGE_REPORTER: 'lcovonly' run: | for i in $(seq 1 2); do npm run testapi && s=0 && break || s=$? @@ -204,6 +214,9 @@ jobs: sleep 10 done; done; + docker compose -f ../../docker-compose-ci.yml stop + + ls -l $COVERAGE_DIR exit $s - name: E2E Test UI (${{ matrix.shard }}/${{ inputs.total-shard }}) @@ -249,6 +262,22 @@ jobs: verbose: true token: ${{ secrets.CODECOV_TOKEN }} + - uses: codecov/codecov-action@v3 + if: inputs.type == 'api' && inputs.release == 'ee' + with: + directory: /tmp/coverage + working-directory: . + flags: e2e-api + verbose: true + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Store e2e-api-ee-coverage + if: inputs.type == 'api' && inputs.release == 'ee' + uses: actions/upload-artifact@v3 + with: + name: e2e-api-ee-coverage + path: /tmp/coverage + - name: Store e2e-ee-coverage if: inputs.type == 'ui' && inputs.release == 'ee' uses: actions/upload-artifact@v3 diff --git a/apps/meteor/package.json b/apps/meteor/package.json index fb5204d1ed4b..eaaec7de67f3 100644 --- a/apps/meteor/package.json +++ b/apps/meteor/package.json @@ -35,7 +35,7 @@ "coverage": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' nyc -r html mocha --config ./.mocharc.js", "test:e2e": "playwright test", "test:e2e:federation": "playwright test --config=playwright-federation.config.ts", - "test:e2e:nyc": "nyc report --reporter=text-summary --reporter=lcov", + "test:e2e:nyc": "nyc report --reporter=lcov", "testapi": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' mocha --config ./.mocharc.api.js", "testunit": "npm run .testunit:definition && npm run .testunit:client && npm run .testunit:server:cov", ".testunit:server": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' mocha --config ./.mocharc.js", diff --git a/apps/meteor/packages/rocketchat-coverage/.npm/package/.gitignore b/apps/meteor/packages/rocketchat-coverage/.npm/package/.gitignore new file mode 100644 index 000000000000..3c3629e647f5 --- /dev/null +++ b/apps/meteor/packages/rocketchat-coverage/.npm/package/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/apps/meteor/packages/rocketchat-coverage/.npm/package/README b/apps/meteor/packages/rocketchat-coverage/.npm/package/README new file mode 100644 index 000000000000..3d492553a438 --- /dev/null +++ b/apps/meteor/packages/rocketchat-coverage/.npm/package/README @@ -0,0 +1,7 @@ +This directory and the files immediately inside it are automatically generated +when you change this package's NPM dependencies. Commit the files in this +directory (npm-shrinkwrap.json, .gitignore, and this README) to source control +so that others run the same versions of sub-dependencies. + +You should NOT check in the node_modules directory that Meteor automatically +creates; if you are using git, the .gitignore file tells git to ignore it. diff --git a/apps/meteor/packages/rocketchat-coverage/.npm/package/npm-shrinkwrap.json b/apps/meteor/packages/rocketchat-coverage/.npm/package/npm-shrinkwrap.json new file mode 100644 index 000000000000..526c4cbd2d5c --- /dev/null +++ b/apps/meteor/packages/rocketchat-coverage/.npm/package/npm-shrinkwrap.json @@ -0,0 +1,52 @@ +{ + "lockfileVersion": 1, + "dependencies": { + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + }, + "html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==" + }, + "istanbul-lib-coverage": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz", + "integrity": "sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg==" + }, + "istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "dependencies": { + "istanbul-lib-coverage": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", + "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==" + } + } + }, + "istanbul-reports": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.0.2.tgz", + "integrity": "sha512-9tZvz7AiR3PEDNGiV9vIouQ/EAcqMXFmkcA1CDFTwOB98OZVDL0PH9glHotf5Ugp6GCOTypfzGWI/OqjWNCRUw==" + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==" + }, + "semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==" + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==" + } + } +} diff --git a/apps/meteor/packages/rocketchat-coverage/package.js b/apps/meteor/packages/rocketchat-coverage/package.js new file mode 100644 index 000000000000..55dde32fec3d --- /dev/null +++ b/apps/meteor/packages/rocketchat-coverage/package.js @@ -0,0 +1,18 @@ +Package.describe({ + name: 'rocketchat:coverage', + summary: '', + version: '1.0.0', +}); + +Package.onUse(function (api) { + api.use('ecmascript'); + api.use('isobuild:compiler-plugin@1.0.0'); + + api.mainModule('plugin/compile-version.js', 'server'); +}); + +Npm.depends({ + 'istanbul-lib-report': '3.0.0', + 'istanbul-reports': '3.0.2', + 'istanbul-lib-coverage': '3.0.0', +}); diff --git a/apps/meteor/packages/rocketchat-coverage/plugin/compile-version.js b/apps/meteor/packages/rocketchat-coverage/plugin/compile-version.js new file mode 100644 index 000000000000..869fbcbf15d3 --- /dev/null +++ b/apps/meteor/packages/rocketchat-coverage/plugin/compile-version.js @@ -0,0 +1,54 @@ +import { exec } from 'child_process'; +import os from 'os'; +import util from 'util'; + +import libReport from 'istanbul-lib-report'; +import reports from 'istanbul-reports'; +import libCoverage from 'istanbul-lib-coverage'; + +const dir = process.env.COVERAGE_DIR; +const reporter = process.env.COVERAGE_REPORTER || 'lcov'; + +console.log('Coverage plugin started'); + +if (!dir && !reporter) { + return console.log('Coverage plugin not configured'); +} + +if (!dir || !reporter) { + console.log('Coverage plugin not fully configured'); + return; +} + +process.on('exit', async () => { + try { + if (!dir) { + throw new Error('No coverage dir'); + } + + if (!reporter) { + throw new Error('No coverage reporter'); + } + console.log('Coverage plugin triggered'); + + const coverageMap = libCoverage.createCoverageMap(globalThis['__coverage__']); + + const configWatermarks = { + statements: [50, 80], + functions: [50, 80], + branches: [50, 80], + lines: [50, 80], + }; + + const context = libReport.createContext({ + dir, + coverageMap, + }); + + const report = reports.create(reporter); + + report.execute(context); + } catch (e) { + console.log('Error', e); + } +}); diff --git a/codecov.yml b/codecov.yml index 2fe2eaf32b42..2a163eae4d74 100644 --- a/codecov.yml +++ b/codecov.yml @@ -26,3 +26,5 @@ flags: comment: layout: 'reach, diff, flags' +fixes: + - '/home/runner/work/Rocket.Chat/Rocket.Chat/::' diff --git a/docker-compose-ci.yml b/docker-compose-ci.yml index e859772f007b..f3ce12026d49 100644 --- a/docker-compose-ci.yml +++ b/docker-compose-ci.yml @@ -2,6 +2,8 @@ version: '3.8' services: rocketchat: + volumes: + - /tmp/coverage:/tmp/coverage platform: linux/amd64 build: dockerfile: ${RC_DOCKERFILE} @@ -15,6 +17,8 @@ services: - 'TRANSPORTER=${TRANSPORTER}' - MOLECULER_LOG_LEVEL=info - 'ROCKETCHAT_LICENSE=${ENTERPRISE_LICENSE}' + - 'COVERAGE_DIR=${COVERAGE_DIR}' + - 'COVERAGE_REPORTER=${COVERAGE_REPORTER}' extra_hosts: - 'host.docker.internal:host-gateway' depends_on: From a7bee82a1b4474f26030fed4f338f7ae4a51d6d7 Mon Sep 17 00:00:00 2001 From: Hardik Bhatia <98163873+hardikbhatia777@users.noreply.github.com> Date: Tue, 5 Dec 2023 18:13:40 +0530 Subject: [PATCH 2/2] i18n: Fixed all German translation handlebar errors (#31139) --- apps/meteor/packages/rocketchat-i18n/i18n/de.i18n.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/meteor/packages/rocketchat-i18n/i18n/de.i18n.json b/apps/meteor/packages/rocketchat-i18n/i18n/de.i18n.json index 9faa71e252d0..6601535bc40b 100644 --- a/apps/meteor/packages/rocketchat-i18n/i18n/de.i18n.json +++ b/apps/meteor/packages/rocketchat-i18n/i18n/de.i18n.json @@ -3208,7 +3208,7 @@ "Message_has_been_edited": "Die Nachricht wurde bearbeitet", "Message_has_been_edited_at": "Die Nachricht wurde am {{date}} bearbeitet", "Message_has_been_edited_by": "Die Nachricht wurde editiert von {{username}}", - "Message_has_been_edited_by_at": "Die Nachricht wurde bearbeitet von __Benutzername__ am __datum__", + "Message_has_been_edited_by_at": "Die Nachricht wurde bearbeitet von {{username}} am {{date}}", "Message_has_been_pinned": "Nachricht wurde angeheftet", "Message_has_been_starred": "Nachricht wurde als Favorit gekennzeichnet", "Message_has_been_unpinned": "Nachricht wurde entpinnt", @@ -3332,7 +3332,7 @@ "Moderation_Delete_message": "Nachricht löschen", "Moderation_Dismiss_and_delete": "Ablehnen und löschen", "Moderation_Delete_this_message": "Diese Nachricht löschen", - "Moderation_Message_context_header": "Nachricht(en) von __displayName__", + "Moderation_Message_context_header": "Nachricht(s) gemeldet", "Moderation_Action_View_reports": "Gemeldete Nachrichten anzeigen", "Moderation_Deactivate_User": "Nutzer deaktivieren", "Moderation_Delete_all_messages": "Alle Nachrichten löschen", @@ -4999,7 +4999,7 @@ "User_Settings": "Kontoeinstellungen", "User_started_a_new_conversation": "{{username}} hat ein neues Gespräch begonnen", "User_unmuted_by": "Benutzer {{user_unmuted}} wurde das Chatten von {{user_by}} wieder erlaubt", - "User_has_been_unmuted": "__user_muted__ nicht mehr stummgeschaltet", + "User_has_been_unmuted": "{{user_unmuted}} nicht mehr stummgeschaltet", "User_unmuted_in_room": "Dem Benutzer wurde das Chatten wieder erlaubt", "User_updated_successfully": "Benutzer wurde erfolgreich aktualisiert", "User_uploaded_a_file_on_channel": "{{username}} hat eine Datei in {{channel}} hochgeladen",