From f6bc95b1b7379cf8d668a2422e2495c3b5e45cb9 Mon Sep 17 00:00:00 2001 From: Xuehai Pan Date: Sun, 10 Dec 2023 11:53:20 +0800 Subject: [PATCH] feat(Makefile): install `clang-format` and `clang-tidy` from PyPI --- .github/workflows/lint.yml | 6 ------ Dockerfile | 2 +- Makefile | 11 ++++------- tests/requirements.txt | 2 ++ 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 472d5967..80f65eb6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -98,12 +98,6 @@ jobs: - name: clang-format run: | - ( - source /etc/os-release - wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc - sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME} llvm-toolchain-${UBUNTU_CODENAME} main" --yes - ) - sudo apt-get update && sudo apt-get install clang-format --yes make clang-format - name: addlicense diff --git a/Dockerfile b/Dockerfile index 246a81e9..41febb5d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,7 +48,7 @@ FROM builder AS devel-builder # Install extra dependencies RUN sudo apt-get update && \ - sudo apt-get install -y golang clang-format clang-tidy && \ + sudo apt-get install -y golang && \ sudo chown -R "$(whoami):$(whoami)" "$(realpath /usr/lib/go)" && \ sudo rm -rf /var/lib/apt/lists/* diff --git a/Makefile b/Makefile index e9099f0c..5cff5f05 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,6 @@ CUDA_FILES = $(shell find $(SOURCE_FOLDERS) -type f -name "*.cuh" -o -name " COMMIT_HASH = $(shell git log -1 --format=%h) PATH := $(HOME)/go/bin:$(PATH) PYTHON ?= $(shell command -v python3 || command -v python) -CLANG_FORMAT ?= $(shell command -v clang-format-17 || command -v clang-format) PYTESTOPTS ?= .PHONY: default @@ -96,12 +95,10 @@ cpplint-install: $(call check_pip_install,cpplint) clang-format-install: - command -v clang-format-17 || command -v clang-format || \ - sudo apt-get install -y clang-format-17 || \ - sudo apt-get install -y clang-format + $(call check_pip_install,clang-format) clang-tidy-install: - command -v clang-tidy || sudo apt-get install -y clang-tidy + $(call check_pip_install,clang-tidy) go-install: # requires go >= 1.16 @@ -172,8 +169,8 @@ cpplint: cpplint-install $(PYTHON) -m cpplint $(CXX_FILES) $(CUDA_FILES) clang-format: clang-format-install - $(CLANG_FORMAT) --version - $(CLANG_FORMAT) --style=file -i $(CXX_FILES) $(CUDA_FILES) -n --Werror + clang-format --version + clang-format --style=file -i $(CXX_FILES) $(CUDA_FILES) -n --Werror clang-tidy: clang-tidy-install cmake-configure clang-tidy --version diff --git a/tests/requirements.txt b/tests/requirements.txt index ee54732b..2fa484aa 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -26,4 +26,6 @@ doc8 pydocstyle[toml] pyenchant cpplint +clang-format +clang-tidy pre-commit