diff --git a/.github/workflows/cargo_build.yml b/.github/workflows/cargo_build.yml index 7904845ca..47b01b5b8 100644 --- a/.github/workflows/cargo_build.yml +++ b/.github/workflows/cargo_build.yml @@ -23,6 +23,16 @@ jobs: steps: - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac + - name: Install and run newline linter checks + if: matrix.os == 'ubuntu-latest' + run: | + wget https://github.com/fernandrone/linelint/releases/download/0.0.6/linelint-linux-amd64 + echo "16b70fb7b471d6f95cbdc0b4e5dc2b0ac9e84ba9ecdc488f7bdf13df823aca4b linelint-linux-amd64" > checksum + sha256sum -c checksum || exit 1 + chmod +x linelint-linux-amd64 + mv linelint-linux-amd64 /usr/local/bin/linelint + make check_newline + - name: Run pcc checks run: | make pcc diff --git a/.linelint.yml b/.linelint.yml new file mode 100644 index 000000000..0cac82892 --- /dev/null +++ b/.linelint.yml @@ -0,0 +1,14 @@ +ignore: + - .git + - target + - tfhe/benchmarks_parameters + - tfhe/web_wasm_parallel_tests/node_modules + - tfhe/web_wasm_parallel_tests/dist + - keys + - coverage + +rules: + # checks if file ends in a newline character + end-of-file: + enable: true + single-new-line: true diff --git a/Makefile b/Makefile index faa701cb0..9a20511e2 100644 --- a/Makefile +++ b/Makefile @@ -102,14 +102,27 @@ install_tarpaulin: install_rs_build_toolchain cargo $(CARGO_RS_BUILD_TOOLCHAIN) install cargo-tarpaulin --locked || \ ( echo "Unable to install cargo tarpaulin, unknown error." && exit 1 ) +.PHONY: check_linelint_installed # Check if linelint newline linter is installed +check_linelint_installed: + @printf "\n" | linelint - > /dev/null 2>&1 || \ + ( echo "Unable to locate linelint. Try installing it: https://github.com/fernandrone/linelint/releases" && exit 1 ) + .PHONY: fmt # Format rust code fmt: install_rs_check_toolchain cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" fmt -.PHONT: check_fmt # Check rust code format +.PHONY: check_fmt # Check rust code format check_fmt: install_rs_check_toolchain cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" fmt --check +.PHONY: fix_newline # Fix newline at end of file issues to be UNIX compliant +fix_newline: check_linelint_installed + linelint -a . + +.PHONY: check_newline # Check for newline at end of file to be UNIX compliant +check_newline: check_linelint_installed + linelint . + .PHONY: clippy_core # Run clippy lints on core_crypto with and without experimental features clippy_core: install_rs_check_toolchain RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy \ @@ -604,7 +617,7 @@ pcc: no_tfhe_typo no_dbg_log check_fmt lint_doc clippy_all check_compile_tests fpcc: no_tfhe_typo no_dbg_log check_fmt lint_doc clippy_fast check_compile_tests .PHONY: conformance # Automatically fix problems that can be fixed -conformance: fmt +conformance: fix_newline fmt .PHONY: help # Generate list of targets with descriptions help: