Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dieselftw authored Dec 4, 2023
2 parents f468a37 + 58cbc51 commit 107f076
Show file tree
Hide file tree
Showing 12 changed files with 185 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fifty-ducks-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fix: Discussion messages deleted despite the "Do not delete discussion messages" retention policy enabled
9 changes: 8 additions & 1 deletion .github/actions/meteor-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/ci-test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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=$?
Expand All @@ -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 }})
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions apps/meteor/app/retention-policy/server/cronPruneMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ async function job(): Promise<void> {
const ignoreDiscussion = settings.get<boolean>('RetentionPolicy_DoNotPruneDiscussion');
const ignoreThreads = settings.get<boolean>('RetentionPolicy_DoNotPruneThreads');

const ignoreDiscussionQuery = ignoreDiscussion ? { prid: { $exists: false } } : {};

// get all rooms with default values
for await (const type of types) {
const maxAge = maxTimes[type] || 0;
Expand All @@ -34,6 +36,7 @@ async function job(): Promise<void> {
't': type,
'$or': [{ 'retention.enabled': { $eq: true } }, { 'retention.enabled': { $exists: false } }],
'retention.overrideGlobal': { $ne: true },
...ignoreDiscussionQuery,
},
{ projection: { _id: 1 } },
).toArray();
Expand All @@ -56,6 +59,7 @@ async function job(): Promise<void> {
'retention.enabled': { $eq: true },
'retention.overrideGlobal': { $eq: true },
'retention.maxAge': { $gte: 0 },
...ignoreDiscussionQuery,
},
{ projection: { _id: 1, retention: 1 } },
).toArray();
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
7 changes: 7 additions & 0 deletions apps/meteor/packages/rocketchat-coverage/.npm/package/README
Original file line number Diff line number Diff line change
@@ -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.

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

18 changes: 18 additions & 0 deletions apps/meteor/packages/rocketchat-coverage/package.js
Original file line number Diff line number Diff line change
@@ -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',
});
54 changes: 54 additions & 0 deletions apps/meteor/packages/rocketchat-coverage/plugin/compile-version.js
Original file line number Diff line number Diff line change
@@ -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);
}
});
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ flags:

comment:
layout: 'reach, diff, flags'
fixes:
- '/home/runner/work/Rocket.Chat/Rocket.Chat/::'
4 changes: 4 additions & 0 deletions docker-compose-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ version: '3.8'

services:
rocketchat:
volumes:
- /tmp/coverage:/tmp/coverage
platform: linux/amd64
build:
dockerfile: ${RC_DOCKERFILE}
Expand All @@ -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:
Expand Down

0 comments on commit 107f076

Please sign in to comment.