chore(ci): add format recipes for javascript code

This commit is contained in:
David Testé
2024-03-12 17:41:01 +01:00
committed by David Testé
parent b40897adbe
commit 937c364c6d
6 changed files with 61 additions and 2 deletions

View File

@@ -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

View File

@@ -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 \

View File

@@ -0,0 +1,4 @@
dist/
node_modules/
pkg/
test/benchmark_results/

View File

@@ -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

View File

@@ -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",

View File

@@ -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",