Skip to content
Snippets Groups Projects
Unverified Commit 58cbc514 authored by Guilherme Gazzo's avatar Guilherme Gazzo Committed by GitHub
Browse files

chore: rocketchat:coverage package (#30339)

parent 92ee9fa2
No related branches found
No related tags found
No related merge requests found
...@@ -109,7 +109,14 @@ runs: ...@@ -109,7 +109,14 @@ runs:
env: env:
METEOR_PROFILE: 1000 METEOR_PROFILE: 1000
BABEL_ENV: ${{ inputs.coverage == 'true' && 'coverage' || '' }} 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 - name: Build Rocket.Chat
shell: bash shell: bash
......
...@@ -127,6 +127,12 @@ jobs: ...@@ -127,6 +127,12 @@ jobs:
- run: yarn build - 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 - name: Start containers for CE
if: inputs.release == 'ce' if: inputs.release == 'ce'
env: env:
...@@ -141,6 +147,8 @@ jobs: ...@@ -141,6 +147,8 @@ jobs:
MONGO_URL: 'mongodb://host.docker.internal:27017/rocketchat?replicaSet=rs0&directConnection=true' MONGO_URL: 'mongodb://host.docker.internal:27017/rocketchat?replicaSet=rs0&directConnection=true'
ENTERPRISE_LICENSE: ${{ inputs.enterprise-license }} ENTERPRISE_LICENSE: ${{ inputs.enterprise-license }}
TRANSPORTER: ${{ inputs.transporter }} TRANSPORTER: ${{ inputs.transporter }}
COVERAGE_DIR: '/tmp/coverage'
COVERAGE_REPORTER: 'lcov'
run: | run: |
docker compose -f docker-compose-ci.yml up -d docker compose -f docker-compose-ci.yml up -d
...@@ -184,6 +192,8 @@ jobs: ...@@ -184,6 +192,8 @@ jobs:
env: env:
WEBHOOK_TEST_URL: 'http://host.docker.internal:10000' WEBHOOK_TEST_URL: 'http://host.docker.internal:10000'
IS_EE: ${{ inputs.release == 'ee' && 'true' || '' }} IS_EE: ${{ inputs.release == 'ee' && 'true' || '' }}
COVERAGE_DIR: '/tmp/coverage'
COVERAGE_REPORTER: 'lcovonly'
run: | run: |
for i in $(seq 1 2); do for i in $(seq 1 2); do
npm run testapi && s=0 && break || s=$? npm run testapi && s=0 && break || s=$?
...@@ -204,6 +214,9 @@ jobs: ...@@ -204,6 +214,9 @@ jobs:
sleep 10 sleep 10
done; done;
done; done;
docker compose -f ../../docker-compose-ci.yml stop
ls -l $COVERAGE_DIR
exit $s exit $s
- name: E2E Test UI (${{ matrix.shard }}/${{ inputs.total-shard }}) - name: E2E Test UI (${{ matrix.shard }}/${{ inputs.total-shard }})
...@@ -249,6 +262,22 @@ jobs: ...@@ -249,6 +262,22 @@ jobs:
verbose: true verbose: true
token: ${{ secrets.CODECOV_TOKEN }} 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 - name: Store e2e-ee-coverage
if: inputs.type == 'ui' && inputs.release == 'ee' if: inputs.type == 'ui' && inputs.release == 'ee'
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
"coverage": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' nyc -r html mocha --config ./.mocharc.js", "coverage": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' nyc -r html mocha --config ./.mocharc.js",
"test:e2e": "playwright test", "test:e2e": "playwright test",
"test:e2e:federation": "playwright test --config=playwright-federation.config.ts", "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", "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": "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", ".testunit:server": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' mocha --config ./.mocharc.js",
......
node_modules
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.
{
"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=="
}
}
}
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',
});
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: ...@@ -26,3 +26,5 @@ flags:
comment: comment:
layout: 'reach, diff, flags' layout: 'reach, diff, flags'
fixes:
- '/home/runner/work/Rocket.Chat/Rocket.Chat/::'
...@@ -2,6 +2,8 @@ version: '3.8' ...@@ -2,6 +2,8 @@ version: '3.8'
services: services:
rocketchat: rocketchat:
volumes:
- /tmp/coverage:/tmp/coverage
platform: linux/amd64 platform: linux/amd64
build: build:
dockerfile: ${RC_DOCKERFILE} dockerfile: ${RC_DOCKERFILE}
...@@ -15,6 +17,8 @@ services: ...@@ -15,6 +17,8 @@ services:
- 'TRANSPORTER=${TRANSPORTER}' - 'TRANSPORTER=${TRANSPORTER}'
- MOLECULER_LOG_LEVEL=info - MOLECULER_LOG_LEVEL=info
- 'ROCKETCHAT_LICENSE=${ENTERPRISE_LICENSE}' - 'ROCKETCHAT_LICENSE=${ENTERPRISE_LICENSE}'
- 'COVERAGE_DIR=${COVERAGE_DIR}'
- 'COVERAGE_REPORTER=${COVERAGE_REPORTER}'
extra_hosts: extra_hosts:
- 'host.docker.internal:host-gateway' - 'host.docker.internal:host-gateway'
depends_on: depends_on:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment