diff --git a/.gitignore b/.gitignore index 7fbb099966cc..b9357018a64c 100644 --- a/.gitignore +++ b/.gitignore @@ -225,7 +225,7 @@ Pipfile.lock # conda package artifacts conda/Dockerfile.cuda* conda/pkg - +.node_repl_history # nix files .envrc *.nix diff --git a/docker/Dockerfile.ci_lint b/docker/Dockerfile.ci_lint index 1c72ee70b63e..aeed9cad416a 100644 --- a/docker/Dockerfile.ci_lint +++ b/docker/Dockerfile.ci_lint @@ -18,13 +18,17 @@ # For lint test # CI docker lint env # tag: v0.60 -FROM ubuntu:16.04 +FROM ubuntu:18.04 -RUN apt-get update && apt-get install -y sudo wget -COPY install/ubuntu_install_python.sh /install/ubuntu_install_python.sh -RUN bash /install/ubuntu_install_python.sh +RUN apt-get update --fix-missing + +RUN apt-get update && apt-get install -y wget git sudo make + +COPY install/ubuntu1804_install_python.sh /install/ubuntu1804_install_python.sh +RUN bash /install/ubuntu1804_install_python.sh + +RUN apt-get update && apt-get install -y doxygen graphviz -RUN apt-get install -y doxygen graphviz git RUN pip3 install cpplint pylint==2.4.4 mypy # java deps for rat @@ -33,3 +37,9 @@ RUN bash /install/ubuntu_install_java.sh COPY install/ubuntu_install_rat.sh /install/ubuntu_install_rat.sh RUN bash /install/ubuntu_install_rat.sh + +COPY install/ubuntu1804_install_clang_format.sh /install/ubuntu1804_install_clang_format.sh +RUN bash /install/ubuntu1804_install_clang_format.sh + +COPY install/ubuntu_install_nodejs.sh /install/ubuntu_install_nodejs.sh +RUN bash /install/ubuntu_install_nodejs.sh diff --git a/docker/install/ubuntu1804_install_clang_format.sh b/docker/install/ubuntu1804_install_clang_format.sh new file mode 100755 index 000000000000..e830433bb039 --- /dev/null +++ b/docker/install/ubuntu1804_install_clang_format.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +set -e +set -u +set -o pipefail + +echo deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main\ + >> /etc/apt/sources.list.d/llvm.list +echo deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main\ + >> /etc/apt/sources.list.d/llvm.list + +wget -q -O - http://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - +apt-get update && apt-get install -y clang-format-10 diff --git a/tests/lint/git-clang-format.sh b/tests/lint/git-clang-format.sh new file mode 100755 index 000000000000..0b1fd43d2801 --- /dev/null +++ b/tests/lint/git-clang-format.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +set -e +set -u +set -o pipefail + +if [ "$#" -lt 1 ]; then + echo "Usage: tests/lint/git-clang-format.sh " + echo "" + echo "Run clang-format on files that changed since " + echo "Examples:" + echo "- Compare last one commit: tests/lint/git-clang-format.sh HEAD~1" + echo "- Compare against upstream/master: tests/lint/git-clang-format.sh upsstream/master" + exit 1 +fi + +cleanup() +{ + rm -rf /tmp/$$.clang-format.txt +} +trap cleanup 0 + +CLANG_FORMAT=clang-format-10 + +if [ -x "$(command -v clang-format-10)" ]; then + CLANG_FORMAT=clang-format-10 +elif [ -x "$(command -v clang-format)" ]; then + echo "clang-format might be different from clang-format-10, expect pontential difference." + CLANG_FORMAT=clang-format +else + echo "Cannot find clang-format-10" + exit 1 +fi + +# Print out specific version +${CLANG_FORMAT} --version + +echo "Running git-clang-format against " $1 +git-${CLANG_FORMAT} --diff --extensions h,mm,c,cc --binary=${CLANG_FORMAT} $1 1> /tmp/$$.clang-format.txt +echo "---------clang-format log----------" +cat /tmp/$$.clang-format.txt +echo "" +if grep --quiet -E "diff" < /tmp/$$.clang-format.txt; then + echo "clang-format lint error found. Consider run clang-format-10 on these files to fix them." + exit 1 +fi diff --git a/tests/lint/rat-excludes b/tests/lint/rat-excludes index 0714850287f3..164352bd7f74 100644 --- a/tests/lint/rat-excludes +++ b/tests/lint/rat-excludes @@ -33,6 +33,8 @@ dist .*~ \#..*\# \.#.* +.npm +node_modules # Relay parser: they are generated by ANTLR. RelayLexer.py