Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[code-infra] Store test results in CI #43897

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ jobs:
then
exit 1
fi
- store_test_results:
path: test-reports
- run:
name: material-ui-icons
command: |
Expand Down Expand Up @@ -410,6 +412,8 @@ jobs:
then
exit 1
fi
- store_test_results:
path: test-reports
- run:
name: Coverage
command: |
Expand Down
2 changes: 1 addition & 1 deletion .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
],
recursive: true,
timeout: (process.env.CIRCLECI === 'true' ? 5 : 2) * 1000, // Circle CI has low-performance CPUs.
reporter: 'dot',
reporter: './test/mochaReporter.js',
require: ['@mui/internal-test-utils/setupBabel', '@mui/internal-test-utils/setupJSDOM'],
'watch-ignore': [
// default
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"generate-codeowners": "node scripts/generateCodeowners.mjs",
"canary:release": "tsx ./scripts/canaryRelease.mts",
"nx_test_tc": "node test/cli.js",
"nx_test_coverage_ci": "cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=lcov mocha 'packages/**/*.test.{js,ts,tsx}' 'packages-internal/**/*.test.{js,ts,tsx}' 'docs/**/*.test.{js,ts,tsx}'",
"nx_test_coverage_ci": "cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=lcov mocha --reporter-options mochaFile=./test-reports/unit/results.xml 'packages/**/*.test.{js,ts,tsx}' 'packages-internal/**/*.test.{js,ts,tsx}' 'docs/**/*.test.{js,ts,tsx}'",
"nx_test_coverage_html": "cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=html mocha 'packages/**/*.test.{js,ts,tsx}' 'packages-internal/**/*.test.{js,ts,tsx}' 'docs/**/*.test.{js,ts,tsx}'",
"nx_test_coverage": "cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=text mocha 'packages/**/*.test.{js,ts,tsx}' 'packages-internal/**/*.test.{js,ts,tsx}' 'docs/**/*.test.{js,ts,tsx}'",
"nx_test_e2e_build": "webpack --config test/e2e/webpack.config.js",
Expand Down Expand Up @@ -172,13 +172,15 @@
"karma-chrome-launcher": "^3.2.0",
"karma-coverage-istanbul-reporter": "^3.0.3",
"karma-firefox-launcher": "^2.1.3",
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1",
"karma-sourcemap-loader": "^0.4.0",
"karma-webpack": "^5.0.0",
"lerna": "^8.1.8",
"lodash": "^4.17.21",
"markdownlint-cli2": "^0.13.0",
"mocha": "^10.7.3",
"mocha-junit-reporter": "^2.2.1",
"nx": "^19.7.3",
"nyc": "^17.0.0",
"piscina": "^4.6.1",
Expand Down
77 changes: 76 additions & 1 deletion pnpm-lock.yaml

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

7 changes: 6 additions & 1 deletion test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ module.exports = function setKarmaConfig(config) {
'karma-sourcemap-loader',
'karma-webpack',
'karma-firefox-launcher',
'karma-junit-reporter',
],
/**
* possible values:
Expand All @@ -105,7 +106,11 @@ module.exports = function setKarmaConfig(config) {
},
// The CI branch fixes double log issue
// https://github.com/karma-runner/karma/issues/2342
reporters: ['dots', ...(CI ? ['coverage-istanbul'] : [])],
reporters: ['dots', ...(CI ? ['coverage-istanbul', 'junit'] : [])],
junitReporter: {
outputDir: './test-reports',
outputFile: 'results.xml',
},
webpack: {
mode: 'development',
devtool: CI ? 'inline-source-map' : 'eval-source-map',
Expand Down
17 changes: 17 additions & 0 deletions test/mochaReporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const mocha = require('mocha');
const Junit = require('mocha-junit-reporter');

const Base = mocha.reporters.Base;
const Dot = mocha.reporters.Dot;

class CiReporter extends Base {
constructor(runner, options) {
super(runner, options);
this.dotReporter = new Dot(runner, options);
if (options.reporterOption.mochaFile) {
this.junitReporter = new Junit(runner, options);
}
}
}

module.exports = CiReporter;