Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCKER] Add clang-format and nodejs to ci-lint #5567

Merged
merged 1 commit into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ Pipfile.lock
# conda package artifacts
conda/Dockerfile.cuda*
conda/pkg

.node_repl_history
# nix files
.envrc
*.nix
Expand Down
20 changes: 15 additions & 5 deletions docker/Dockerfile.ci_lint
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
29 changes: 29 additions & 0 deletions docker/install/ubuntu1804_install_clang_format.sh
Original file line number Diff line number Diff line change
@@ -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
61 changes: 61 additions & 0 deletions tests/lint/git-clang-format.sh
Original file line number Diff line number Diff line change
@@ -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 <commit>"
echo ""
echo "Run clang-format on files that changed since <commit>"
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
2 changes: 2 additions & 0 deletions tests/lint/rat-excludes
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ dist
.*~
\#..*\#
\.#.*
.npm
node_modules

# Relay parser: they are generated by ANTLR.
RelayLexer.py
Expand Down