From c95ba159de3ad981b15866669bfdee83566bd10e Mon Sep 17 00:00:00 2001 From: Shlok Amin Date: Mon, 23 Oct 2023 11:56:30 -0400 Subject: [PATCH] make internal js projects testing target --- .github/workflows/app-test-build-deploy.yaml | 14 +++++------- Makefile | 23 ++++++++------------ app/Makefile | 2 +- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/.github/workflows/app-test-build-deploy.yaml b/.github/workflows/app-test-build-deploy.yaml index c91131bd1dd..74176f9ab59 100644 --- a/.github/workflows/app-test-build-deploy.yaml +++ b/.github/workflows/app-test-build-deploy.yaml @@ -83,9 +83,9 @@ jobs: npm config set cache ${{ github.workspace }}/.npm-cache yarn config set cache-folder ${{ github.workspace }}/.yarn-cache make setup-js - - name: 'opentrons app frontendunit tests' + - name: 'test frontend packages' run: | - make -C app test-cov + yarn jest --coverage=true --ci=true --collectCoverageFrom="app/src/**/*.(js|ts|tsx)" app/src components/src shared-data/js - name: 'Upload coverage report' uses: codecov/codecov-action@v3 with: @@ -140,13 +140,9 @@ jobs: npm config set cache ${{ github.workspace }}/.npm-cache yarn config set cache-folder ${{ github.workspace }}/.yarn-cache make setup-js - - name: 'test app shell' - run: make -C app-shell test-cov - - name: 'test app shell odd' - run: make -C app-shell-odd test-cov - - name: 'test discovery client' - run: make -C discovery-client test-cov - # TODO before merging: check to see that coverage report actually gets uploaded for each native package + - name: 'test native(er) packages' + run: | + make test-js-internal tests="app-shell/src app-shell-odd/src discovery-client/src" cov_opts="--coverage=true --ci=true --collectCoverageFrom='(app-shell|app-shell-odd| discovery-client)/src/**/*.(js|ts|tsx)'" - name: 'Upload coverage report' uses: 'codecov/codecov-action@v3' with: diff --git a/Makefile b/Makefile index 945c9166d58..57f437c9006 100755 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ USB_BRIDGE_DIR := usb-bridge NODE_USB_BRIDGE_CLIENT_DIR := usb-bridge/node-client PYTHON_DIRS := $(API_DIR) $(UPDATE_SERVER_DIR) $(NOTIFY_SERVER_DIR) $(ROBOT_SERVER_DIR) $(SERVER_UTILS_DIR) $(SHARED_DATA_DIR)/python $(G_CODE_TESTING_DIR) $(HARDWARE_DIR) $(USB_BRIDGE_DIR) +JS_PACKAGES := $(API_CLIENT_DIR) $(APP_SHELL_DIR) $(APP_SHELL_ODD_DIR) $(COMPONENTS_DIR) $(DISCOVERY_CLIENT_DIR) $(LABWARE_LIBRARY_DIR) $(PROTOCOL_DESIGNER_DIR) $(SHARED_DATA_DIR) $(REACT_API_CLIENT_DIR) $(STEP_GENERATION_DIR) $(NODE_USB_BRIDGE_CLIENT_DIR) # This may be set as an environment variable (and is by CI tasks that upload # to test pypi) to add a .dev extension to the python package versions. If @@ -198,18 +199,8 @@ test-py: test-py-windows $(MAKE) -C $(USB_BRIDGE_DIR) test .PHONY: test-js -test-js: - $(MAKE) -C $(API_CLIENT_DIR) test - $(MAKE) -C $(APP_SHELL_DIR) test - $(MAKE) -C $(APP_SHELL_ODD_DIR) test - $(MAKE) -C $(COMPONENTS_DIR) test - $(MAKE) -C $(DISCOVERY_CLIENT_DIR) test - $(MAKE) -C $(LABWARE_LIBRARY_DIR) test - $(MAKE) -C $(PROTOCOL_DESIGNER_DIR) test - $(MAKE) -C $(REACT_API_CLIENT_DIR) test - $(MAKE) -C $(SHARED_DATA_DIR) test - $(MAKE) -C $(STEP_GENERATION_DIR) test - $(MAKE) -C $(LABWARE_LIBRARY_DIR) test +test-js: tests?=$(JS_PACKAGES) +test-js: test-js-internal # lints and typechecks .PHONY: lint @@ -271,6 +262,10 @@ circular-dependencies-js: yarn madge $(and $(CI),--no-spinner --no-color) --circular app/src/index.tsx yarn madge $(and $(CI),--no-spinner --no-color) --circular components/src/index.ts -.PHONY: test-js-% -test-js-%: +.PHONY: test-js-internal +test-js-internal: yarn jest $(tests) $(test_opts) $(cov_opts) + +.PHONY: test-js-% +test-js-%: + $(MAKE) test-js-internal tests="$(if $(tests),$(foreach test,$(tests),$*/$(test)),$*)" $(test_opts) $(cov_opts) \ No newline at end of file diff --git a/app/Makefile b/app/Makefile index 34dd07a22de..39eecd7b4bd 100644 --- a/app/Makefile +++ b/app/Makefile @@ -91,7 +91,7 @@ dev-shell-odd: .PHONY: test test: - make -C .. test-js-app tests=$(tests) test_opts="$(test_opts)" + make -C .. test-js-app tests="$(tests)" test_opts="$(test_opts)" .PHONY: test-cov test-cov: