From 0e4ee98ae08c0d08c71fbae4e03945ed081cf3d8 Mon Sep 17 00:00:00 2001 From: Arvin <17693119+vindard@users.noreply.github.com> Date: Tue, 13 Feb 2024 21:15:41 -0400 Subject: [PATCH] build: add buck test filters for local dev (#3958) * build: rename npm_test buck toolchain file * build: add option to filter jest tests * build: remove make test commands --- core/api/Makefile | 9 --------- toolchains/workspace-pnpm/BUCK | 2 +- toolchains/workspace-pnpm/macros.bzl | 2 +- .../workspace-pnpm/{run_in_dir.py => run_npm_test.py} | 6 +++++- toolchains/workspace-pnpm/toolchain.bzl | 8 ++++---- 5 files changed, 11 insertions(+), 16 deletions(-) rename toolchains/workspace-pnpm/{run_in_dir.py => run_npm_test.py} (95%) diff --git a/core/api/Makefile b/core/api/Makefile index 49f0fe10d1..99652e26c5 100644 --- a/core/api/Makefile +++ b/core/api/Makefile @@ -22,16 +22,11 @@ start-main-ci: watch: pnpm nodemon -V -e ts,graphql -w ./src -x make start -test: unit integration - test-migrate: docker compose down -v -t 3 docker compose build docker compose -f docker-compose.yml up mongodb-migrate --exit-code-from mongodb-migrate -unit: - pnpm run test:unit - watch-unit: $(BIN_DIR)/jest --config ./test/unit/jest.config.js --clearCache NODE_ENV=test LOGLEVEL=warn $(BIN_DIR)/jest --watch --config ./test/unit/jest.config.js @@ -39,10 +34,6 @@ watch-unit: del-containers: docker compose rm -sfv -integration: - pnpm run build && \ - . ./.env && pnpm run test:integration - create-tmp-env-ci: . ./.env && \ envsubst < ./.env.ci > tmp.env.ci diff --git a/toolchains/workspace-pnpm/BUCK b/toolchains/workspace-pnpm/BUCK index ed62a43d88..1541dcba6f 100644 --- a/toolchains/workspace-pnpm/BUCK +++ b/toolchains/workspace-pnpm/BUCK @@ -39,7 +39,7 @@ export_file( ) export_file( - name = "run_in_dir.py", + name = "run_npm_test.py", visibility = ["PUBLIC"], ) diff --git a/toolchains/workspace-pnpm/macros.bzl b/toolchains/workspace-pnpm/macros.bzl index c13e590656..e310525cd9 100644 --- a/toolchains/workspace-pnpm/macros.bzl +++ b/toolchains/workspace-pnpm/macros.bzl @@ -627,7 +627,7 @@ def _npm_test_impl( run_cmd_args = cmd_args([ ctx.attrs._python_toolchain[PythonToolchainInfo].interpreter, - pnpm_toolchain.run_in_dir[DefaultInfo].default_outputs, + pnpm_toolchain.run_npm_test[DefaultInfo].default_outputs, "--cwd", cmd_args([build_context.workspace_root, ctx.label.package], delimiter = "/"), "--bin", diff --git a/toolchains/workspace-pnpm/run_in_dir.py b/toolchains/workspace-pnpm/run_npm_test.py similarity index 95% rename from toolchains/workspace-pnpm/run_in_dir.py rename to toolchains/workspace-pnpm/run_npm_test.py index df553605ea..1c7714db0d 100644 --- a/toolchains/workspace-pnpm/run_in_dir.py +++ b/toolchains/workspace-pnpm/run_npm_test.py @@ -50,10 +50,14 @@ def merge_env_from_file(file_path): ) args = parser.parse_args() + + env = merge_env_from_file(args.env_file) + bin_args = args.args[1:] # ignore '--' separator + if env.get("TEST"): + bin_args.append(env.get("TEST")) cmd = [os.path.abspath(args.bin), *bin_args] - env = merge_env_from_file(args.env_file) exit_code = subprocess.call(cmd, cwd=args.cwd, env=env) sys.exit(exit_code) diff --git a/toolchains/workspace-pnpm/toolchain.bzl b/toolchains/workspace-pnpm/toolchain.bzl index 141d3b4e65..6eab3fe053 100644 --- a/toolchains/workspace-pnpm/toolchain.bzl +++ b/toolchains/workspace-pnpm/toolchain.bzl @@ -7,7 +7,7 @@ WorkspacePnpmToolchainInfo = provider(fields = [ "package_prod_tsc_build_bin", "build_next_build", "package_next_bin", - "run_in_dir", + "run_npm_test", "run_audit", ]) @@ -26,7 +26,7 @@ def workspace_pnpm_toolchain_impl(ctx) -> list[[DefaultInfo, WorkspacePnpmToolch package_prod_tsc_build_bin = ctx.attrs._package_prod_tsc_build_bin, build_next_build = ctx.attrs._build_next_build, package_next_bin = ctx.attrs._package_next_bin, - run_in_dir = ctx.attrs._run_in_dir, + run_npm_test = ctx.attrs._run_npm_test, run_audit = ctx.attrs._run_audit, ) ] @@ -58,8 +58,8 @@ workspace_pnpm_toolchain = rule( "_package_next_bin": attrs.dep( default = "toolchains//workspace-pnpm:package_next_bin.py", ), - "_run_in_dir": attrs.dep( - default = "toolchains//workspace-pnpm:run_in_dir.py", + "_run_npm_test": attrs.dep( + default = "toolchains//workspace-pnpm:run_npm_test.py", ), "_run_audit": attrs.dep( default = "toolchains//workspace-pnpm:run_audit.py",