diff --git a/.github/workflows/aws_tfhe_wasm_tests.yml b/.github/workflows/aws_tfhe_wasm_tests.yml index f863366754..0404ad2213 100644 --- a/.github/workflows/aws_tfhe_wasm_tests.yml +++ b/.github/workflows/aws_tfhe_wasm_tests.yml @@ -57,13 +57,20 @@ jobs: with: toolchain: stable + - name: Install Node + run: | + make install_node + + - name: Run fmt checks + run: | + make check_fmt_js + - name: Run js on wasm API tests run: | make test_nodejs_wasm_api_in_docker - name: Run parallel wasm tests run: | - make install_node make ci_test_web_js_api_parallel - name: Slack Notification diff --git a/Makefile b/Makefile index 461b8e64e6..717198bb75 100644 --- a/Makefile +++ b/Makefile @@ -149,10 +149,22 @@ check_actionlint_installed: @actionlint --version > /dev/null 2>&1 || \ ( echo "Unable to locate actionlint. Try installing it: https://github.com/rhysd/actionlint/releases" && exit 1 ) +.PHONY: check_nvm_installed # Check if Node Version Manager is installed +check_nvm_installed: + @source ~/.nvm/nvm.sh && nvm --version > /dev/null 2>&1 || \ + ( echo "Unable to locate Node. Run 'make install_node'" && exit 1 ) + .PHONY: fmt # Format rust code fmt: install_rs_check_toolchain cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" fmt +.PHONY: fmt_js # Format javascript code +fmt_js: check_nvm_installed + source ~/.nvm/nvm.sh && \ + nvm install $(NODE_VERSION) && \ + nvm use $(NODE_VERSION) && \ + $(MAKE) -C tfhe/web_wasm_parallel_tests fmt + .PHONY: fmt_gpu # Format rust and cuda code fmt_gpu: install_rs_check_toolchain cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" fmt @@ -167,6 +179,13 @@ check_fmt_gpu: install_rs_check_toolchain cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" fmt --check cd "$(TFHECUDA_SRC)" && ./format_tfhe_cuda_backend.sh -c +.PHONY: check_fmt_js # Check javascript code format +check_fmt_js: check_nvm_installed + source ~/.nvm/nvm.sh && \ + nvm install $(NODE_VERSION) && \ + nvm use $(NODE_VERSION) && \ + $(MAKE) -C tfhe/web_wasm_parallel_tests check_fmt + .PHONY: clippy_gpu # Run clippy lints on tfhe with "gpu" enabled clippy_gpu: install_rs_check_toolchain RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy \ diff --git a/tfhe/web_wasm_parallel_tests/.prettierignore b/tfhe/web_wasm_parallel_tests/.prettierignore new file mode 100644 index 0000000000..a3797fd203 --- /dev/null +++ b/tfhe/web_wasm_parallel_tests/.prettierignore @@ -0,0 +1,4 @@ +dist/ +node_modules/ +pkg/ +test/benchmark_results/ diff --git a/tfhe/web_wasm_parallel_tests/Makefile b/tfhe/web_wasm_parallel_tests/Makefile index 03d2c47ae6..f11091885f 100644 --- a/tfhe/web_wasm_parallel_tests/Makefile +++ b/tfhe/web_wasm_parallel_tests/Makefile @@ -23,3 +23,13 @@ bench: run_server .PHONY: bench-ci # Run benchmarks on web client in CI bench-ci: run_server + +.PHONY: fmt # Format Javascript code +fmt: + npm install + npm run format + +.PHONY: fmt # Check Javascript code format +check_fmt: + npm install + npm run check-format diff --git a/tfhe/web_wasm_parallel_tests/package-lock.json b/tfhe/web_wasm_parallel_tests/package-lock.json index 9772a9468f..66a1ecc1b4 100644 --- a/tfhe/web_wasm_parallel_tests/package-lock.json +++ b/tfhe/web_wasm_parallel_tests/package-lock.json @@ -15,6 +15,7 @@ "devDependencies": { "@babel/preset-env": "^7.22.4", "jest": "^29.5.0", + "prettier": "^3.2.5", "puppeteer": "^21.3.8", "serve": "^14.2.0", "webpack": "^5.75.0", @@ -7299,6 +7300,21 @@ "node": ">=8" } }, + "node_modules/prettier": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-format": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", diff --git a/tfhe/web_wasm_parallel_tests/package.json b/tfhe/web_wasm_parallel_tests/package.json index ee1eab90e1..76831479bb 100644 --- a/tfhe/web_wasm_parallel_tests/package.json +++ b/tfhe/web_wasm_parallel_tests/package.json @@ -10,13 +10,16 @@ "server": "serve --config ../serve.json dist/", "test-separate-processes": "jest --listTests | xargs -L 1 jest --runInBand --testNamePattern=Test", "bench-separate-processes": "jest --listTests | xargs -L 1 jest --runInBand --testNamePattern=Bench", - "test2": "mocha" + "test2": "mocha", + "format": "prettier . --write", + "check-format": "prettier . --check" }, "author": "", "license": "ISC", "devDependencies": { "@babel/preset-env": "^7.22.4", "jest": "^29.5.0", + "prettier": "^3.2.5", "puppeteer": "^21.3.8", "serve": "^14.2.0", "webpack": "^5.75.0",