Skip to content

Commit

Permalink
[Backport 1.x] Manually backport workflow fixes
Browse files Browse the repository at this point in the history
* Add retrying flaky jest tests (opensearch-project#2967)
* Add code coverage reporting (opensearch-project#1478)
* Report `done` on async jest failures

Signed-off-by: Miki <miki@amazon.com>
  • Loading branch information
AMoo-Miki committed Jan 20, 2023
1 parent 5f983c8 commit d87d600
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 33 deletions.
23 changes: 12 additions & 11 deletions .github/workflows/pr_check_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,19 @@ jobs:
id: linter
run: yarn lint

# Runs unit tests while limiting workers because github actions will spawn more than it can handle and crash
# Continues on error but will create a comment on the pull request if this step failed.
- name: Run unit tests
if: steps.unit_tests_results.outputs.unit_tests_results != 'success'
- name: Run unit tests with coverage
id: unit-tests
continue-on-error: true
run: node scripts/jest --ci --colors --maxWorkers=10
env:
SKIP_BAD_APPLES: true
run: yarn test:jest:ci:coverage

- run: echo Unit tests completed unsuccessfully. However, unit tests are inconsistent on the CI so please verify locally with `yarn test:jest`.
if: steps.unit_tests_results.outputs.unit_tests_results != 'success' && steps.unit-tests.outcome != 'success'
- name: Run mocha tests with coverage
id: mocha-tests
run: yarn test:mocha:coverage

- name: Upload Code Coverage
id: upload-code-coverage
uses: codecov/codecov-action@v3
with:
directory: ./target/opensearch-dashboards-coverage

- name: Run integration tests
if: steps.integration_tests_results.outputs.integration_tests_results != 'success'
Expand Down Expand Up @@ -168,7 +169,7 @@ jobs:
- name: Run integration tests
id: integration-tests
run: yarn test:jest_integration:ci

functional-tests-linux:
needs: [ build-lint-test-linux ]
runs-on: ubuntu-latest
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@
"test": "grunt test",
"test:bwc": "./scripts/bwctest_osd.sh",
"test:jest": "node scripts/jest",
"test:jest:coverage": "node scripts/jest --coverage",
"test:jest:ci": "node scripts/jest --ci --colors --runInBand",
"test:jest:ci:coverage": "node scripts/jest --ci --colors --runInBand --coverage",
"test:jest_integration": "node scripts/jest_integration",
"test:mocha": "node scripts/mocha",
"test:mocha:coverage": "grunt test:mochaCoverage",
"test:mocha:coverage": "yarn nyc --reporter=text-summary --reporter=lcov --report-dir=./target/opensearch-dashboards-coverage/mocha node scripts/mocha",
"test:ftr": "node scripts/functional_tests",
"test:ftr:server": "node scripts/functional_tests_server",
"test:ftr:runner": "node scripts/functional_test_runner",
"test:coverage": "grunt test:coverage",
"checkLicenses": "node scripts/check_licenses --dev",
"build-platform": "node scripts/build",
"build": "node scripts/build --all-platforms",
Expand Down Expand Up @@ -107,6 +109,8 @@
"**/url-parse": "^1.5.8",
"**/shelljs": "0.8.5",
"**/unset-value": "^2.0.1",
"**/jest-config": "npm:@amoo-miki/jest-config@26.4.2-rc.1",
"**/jest-jasmine2": "npm:@amoo-miki/jest-jasmine2@26.4.2-rc.1",
"**/minimatch": "^3.0.5"
},
"workspaces": {
Expand Down
13 changes: 2 additions & 11 deletions src/dev/jest/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ export default {
'<rootDir>/src/test_utils',
'<rootDir>/test/functional/services/remote',
],
collectCoverageFrom: [
'src/plugins/**/*.{ts,tsx}',
'!src/plugins/**/*.d.ts',
'packages/osd-ui-framework/src/components/**/*.js',
'!packages/osd-ui-framework/src/components/index.js',
'!packages/osd-ui-framework/src/components/**/*/index.js',
'packages/osd-ui-framework/src/services/**/*.js',
'!packages/osd-ui-framework/src/services/index.js',
'!packages/osd-ui-framework/src/services/**/*/index.js',
],
moduleNameMapper: {
'@elastic/eui$': '<rootDir>/node_modules/@elastic/eui/test-env',
'@elastic/eui/lib/(.*)?': '<rootDir>/node_modules/@elastic/eui/test-env/$1',
Expand All @@ -84,7 +74,8 @@ export default {
'<rootDir>/src/dev/jest/setup/react_testing_library.js',
],
coverageDirectory: '<rootDir>/target/opensearch-dashboards-coverage/jest',
coverageReporters: ['html', 'text'],
coveragePathIgnorePatterns: ['/node_modules/', '.*\\.d\\.ts'],
coverageReporters: ['lcov', 'text-summary'],
moduleFileExtensions: ['js', 'mjs', 'json', 'ts', 'tsx', 'node'],
modulePathIgnorePatterns: [
'__fixtures__/',
Expand Down
5 changes: 4 additions & 1 deletion src/dev/jest/integration_tests/__fixtures__/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
* GitHub history for details.
*/

it('fails', () => {
it('fails', (done) => {
setTimeout(() => {
done();
}, 200);
throw new Error('failure');
});
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12737,10 +12737,10 @@ jest-cli@^26.4.2:
prompts "^2.0.1"
yargs "^15.3.1"

jest-config@^26.4.2:
version "26.4.2"
resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-26.4.2.tgz#da0cbb7dc2c131ffe831f0f7f2a36256e6086558"
integrity sha512-QBf7YGLuToiM8PmTnJEdRxyYy3mHWLh24LJZKVdXZ2PNdizSe1B/E8bVm+HYcjbEzGuVXDv/di+EzdO/6Gq80A==
jest-config@^26.4.2, "jest-config@npm:@amoo-miki/jest-config@26.4.2-rc.1":
version "26.4.2-rc.1"
resolved "https://registry.yarnpkg.com/@amoo-miki/jest-config/-/jest-config-26.4.2-rc.1.tgz#5ccf4380d509b2007d6cc0cf91c421654f1a48c8"
integrity sha512-u8OAz4FqORcTIGc5F8/GGb4J/qObMHQ20869Vq7r7TIi93nYhx18M6wRtoVQo4IUNOwvG0rND1Ew8xFoE2OXYg==
dependencies:
"@babel/core" "^7.1.0"
"@jest/test-sequencer" "^26.4.2"
Expand Down Expand Up @@ -12864,10 +12864,10 @@ jest-haste-map@^26.3.0:
optionalDependencies:
fsevents "^2.1.2"

jest-jasmine2@^26.4.2:
version "26.4.2"
resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-26.4.2.tgz#18a9d5bec30904267ac5e9797570932aec1e2257"
integrity sha512-z7H4EpCldHN1J8fNgsja58QftxBSL+JcwZmaXIvV9WKIM+x49F4GLHu/+BQh2kzRKHAgaN/E82od+8rTOBPyPA==
jest-jasmine2@^26.4.2, "jest-jasmine2@npm:@amoo-miki/jest-jasmine2@26.4.2-rc.1":
version "26.4.2-rc.1"
resolved "https://registry.yarnpkg.com/@amoo-miki/jest-jasmine2/-/jest-jasmine2-26.4.2-rc.1.tgz#86162f9acd802038ec72a049b183f20e4e0a89f4"
integrity sha512-qi0Uo38OhygDK5zxiDPTiD+wqSJbwesk0D6hesM1TVOEeAkskX0mZN3PMqLIS//+Lgij26+lXyXfPuxbpVLdeQ==
dependencies:
"@babel/traverse" "^7.1.0"
"@jest/environment" "^26.3.0"
Expand Down

0 comments on commit d87d600

Please sign in to comment.