Skip to content

Commit

Permalink
chore(ci): add format recipes for javascript code
Browse files Browse the repository at this point in the history
  • Loading branch information
soonum committed Mar 14, 2024
1 parent b40897a commit 937c364
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 2 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/aws_tfhe_wasm_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 \
Expand Down
4 changes: 4 additions & 0 deletions tfhe/web_wasm_parallel_tests/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist/
node_modules/
pkg/
test/benchmark_results/
10 changes: 10 additions & 0 deletions tfhe/web_wasm_parallel_tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions tfhe/web_wasm_parallel_tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion tfhe/web_wasm_parallel_tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 937c364

Please sign in to comment.