Skip to content

Commit

Permalink
Add test coverage support through CodeCov (#3281)
Browse files Browse the repository at this point in the history
Signed-off-by: Guilherme Caponetto <[email protected]>
  • Loading branch information
caponetto authored Jan 18, 2025
1 parent d896303 commit 5c40a5d
Show file tree
Hide file tree
Showing 26 changed files with 360 additions and 22 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ jobs:
days: 7 # check for newer package versions in past X days
run: |
python3 ./.github/workflows/scripts/fetch_packages_metadata.py $days
- name: Upload coverage reports to Codecov
if: ${{ matrix.python-version == env.PYTHON_VERSION }}
uses: codecov/codecov-action@v5

test-ui:
name: Test UI
Expand Down Expand Up @@ -146,6 +149,8 @@ jobs:
run: make install-server
- name: Test
run: make test-ui-unit
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5

test-integration:
name: Run Integration Tests
Expand Down Expand Up @@ -176,13 +181,18 @@ jobs:
run: |
make build-dependencies
make yarn-install
make test-instrument
make build-ui-prod
- name: Install
run: |
make install-server
make install-examples
- name: Cypress
run: make test-integration
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
files: ./coverage/cobertura-coverage.xml
- name: Collect logs
uses: actions/upload-artifact@v4
if: failure()
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ nosetests.xml
coverage.xml
*,cover
**/coverage/
.nyc_output/

# Translations
*.mo
Expand Down
12 changes: 12 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "nyc-config-tsx",
"all": true,
"include": ["**/src/**/*.{ts,tsx}"],
"exclude": ["**/*.spec.ts", "tests/**/*"],
"reporter": ["text-summary", "cobertura"],
"check-coverage": true,
"lines": 70,
"functions": 60,
"branches": 50,
"statements": 70
}
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,16 @@ test-dependencies:
@$(PYTHON_PIP) install -q -r test_requirements.txt

pytest:
$(PYTHON) -m pytest -v --durations=0 --durations-min=60 elyra
$(PYTHON) -m pytest -v --durations=0 --durations-min=60 elyra --cov --cov-report=xml

test-server: test-dependencies pytest # Run python unit tests

test-ui-unit: # Run frontend jest unit tests
yarn test:unit

test-instrument: # Prepare code coverage instrumentation
yarn lerna run cy:instrument --stream

test-integration: # Run frontend cypress integration tests
jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
yarn test:integration
Expand Down
3 changes: 3 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

import coverage from '@cypress/code-coverage/task';

import { defineConfig } from 'cypress';

import { register } from './cypress/utils/snapshots/plugin';
Expand All @@ -33,6 +35,7 @@ export default defineConfig({
testIsolation: false,
setupNodeEvents(on, config) {
register(on, config);
coverage(on, config);
return config;
},
retries: {
Expand Down
2 changes: 2 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

import '@cypress/code-coverage/support';

import '@testing-library/cypress/add-commands';

import 'cypress-real-events/support';
Expand Down
1 change: 1 addition & 0 deletions cypress/support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface Chainable {
Expand Down
File renamed without changes.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"scripts": {
"graph": "ts-node etc/scripts/generate-make-graph.ts",
"cy:open": "npx cypress open",
"cy:run": "npx cypress run --headed",
"cy:run": "npx nyc npx cypress run --headed",
"eslint": "eslint . --fix --ignore-path .gitignore --ext .ts,.tsx,.js",
"eslint:check": "eslint . --ignore-path .gitignore --ext .ts,.tsx,.js",
"prettier": "prettier --ignore-path .gitignore --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json}\"",
Expand Down Expand Up @@ -44,6 +44,7 @@
"yjs": "^13.5.40"
},
"devDependencies": {
"@cypress/code-coverage": "^3.13.8",
"@cypress/webpack-preprocessor": "^6.0.2",
"@glen/jest-raw-loader": "^2.0.0",
"@jupyterlab/testutils": "^4.2.5",
Expand Down Expand Up @@ -72,6 +73,8 @@
"lerna": "^8.0.1",
"lint-staged": "^15.2.0",
"npm-run-all": "^4.1.5",
"nyc": "^17.1.0",
"nyc-config-tsx": "^0.1.0",
"prettier": "^3.1.1",
"rimraf": "~5.0.5",
"start-server-and-test": "^2.0.3",
Expand Down
1 change: 1 addition & 0 deletions packages/code-snippet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_code_snippet_extension/labextension ../../../../labextensions/elyra_code_snippet_extension/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/code-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_code_viewer_extension/labextension ../../../../labextensions/elyra_code_viewer_extension/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/metadata-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_metadata_common/labextension ../../../../labextensions/elyra_metadata_common/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/metadata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_metadata_extension/labextension ../../../../labextensions/elyra_metadata_extension/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/pipeline-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_pipeline_editor_extension/labextension ../../../../labextensions/elyra_pipeline_editor_extension/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/python-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_python_editor_extension/labextension ../../../../labextensions/elyra_python_editor_extension/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/r-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_r_editor_extension/labextension ../../../../labextensions/elyra_r_editor_extension/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/scala-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_scala_editor_extension/labextension ../../../../labextensions/elyra_scala_editor_extension/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/script-debugger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_script_debugger_extension/labextension ../../../../labextensions/elyra_script_debugger_extension/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/script-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_script_editor/labextension ../../../../labextensions/elyra_script_editor/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_services/labextension ../../../../labextensions/elyra_services/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensionselyra_theme_extension/labextension ../../../../labextensionselyra_theme_extension/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions packages/ui-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf ../../../../labextensions/elyra_ui_components/labextension ../../../../labextensions/elyra_ui_components/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"cy:instrument": "npx nyc instrument --compact=false --in-place src/ src/",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ test = [
"git-python",
"importlib-resources",
"pytest>=5.4.1",
"pytest-cov",
"pytest-console-scripts",
"pytest_jupyter",
"pytest-tornasync",
Expand Down
1 change: 1 addition & 0 deletions test_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ git-python
importlib-resources
PyGithub==1.58.1 # Github actions with Python 3.11 is having newer versions causing test failures
pytest>=5.4.1
pytest-cov
pytest-console-scripts
pytest_jupyter
pytest-tornasync
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/* Additional Checks */
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noFallthroughCasesInSwitch": false,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,

Expand Down
Loading

0 comments on commit 5c40a5d

Please sign in to comment.