mirror of
https://github.com/RocketChat/Rocket.Chat.git
synced 2025-12-28 06:47:25 +00:00
chore: rocketchat:coverage package (#30339)
This commit is contained in:
parent
92ee9fa284
commit
58cbc5148c
9
.github/actions/meteor-build/action.yml
vendored
9
.github/actions/meteor-build/action.yml
vendored
@ -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
|
||||
|
||||
29
.github/workflows/ci-test-e2e.yml
vendored
29
.github/workflows/ci-test-e2e.yml
vendored
@ -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
|
||||
|
||||
@ -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",
|
||||
|
||||
1
apps/meteor/packages/rocketchat-coverage/.npm/package/.gitignore
vendored
Normal file
1
apps/meteor/packages/rocketchat-coverage/.npm/package/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
||||
@ -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.
|
||||
52
apps/meteor/packages/rocketchat-coverage/.npm/package/npm-shrinkwrap.json
generated
Normal file
52
apps/meteor/packages/rocketchat-coverage/.npm/package/npm-shrinkwrap.json
generated
Normal file
@ -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=="
|
||||
}
|
||||
}
|
||||
}
|
||||
18
apps/meteor/packages/rocketchat-coverage/package.js
Normal file
18
apps/meteor/packages/rocketchat-coverage/package.js
Normal file
@ -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',
|
||||
});
|
||||
@ -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);
|
||||
}
|
||||
});
|
||||
@ -26,3 +26,5 @@ flags:
|
||||
|
||||
comment:
|
||||
layout: 'reach, diff, flags'
|
||||
fixes:
|
||||
- '/home/runner/work/Rocket.Chat/Rocket.Chat/::'
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user