Skip to content

Commit

Permalink
build: add buck test filters for local dev (#3958)
Browse files Browse the repository at this point in the history
* build: rename npm_test buck toolchain file

* build: add option to filter jest tests

* build: remove make test commands
  • Loading branch information
vindard authored Feb 14, 2024
1 parent f9d495d commit 0e4ee98
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
9 changes: 0 additions & 9 deletions core/api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,18 @@ 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

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
Expand Down
2 changes: 1 addition & 1 deletion toolchains/workspace-pnpm/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export_file(
)

export_file(
name = "run_in_dir.py",
name = "run_npm_test.py",
visibility = ["PUBLIC"],
)

Expand Down
2 changes: 1 addition & 1 deletion toolchains/workspace-pnpm/macros.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 4 additions & 4 deletions toolchains/workspace-pnpm/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
])

Expand All @@ -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,
)
]
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 0e4ee98

Please sign in to comment.