Skip to content

Commit

Permalink
ARROW-3313: [R] Move .clang-format to top level. Add r/lint.sh script…
Browse files Browse the repository at this point in the history
… for linting R C++ files in Travis CI

This also skips the R Travis job if there are no changes affecting it.

Author: Wes McKinney <wesm+git@apache.org>

Closes #2628 from wesm/clang-format-raise and squashes the following commits:

8b7efea8d <Wes McKinney> slashdot
1a1576269 <Wes McKinney> Move .clang-format to top level. Add r/lint.sh script for linting R files
  • Loading branch information
wesm committed Sep 26, 2018
1 parent 0e9b761 commit 52b4b8f
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 9 deletions.
20 changes: 20 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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.
---
BasedOnStyle: Google
DerivePointerAlignment: false
ColumnLimit: 90
29 changes: 29 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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.
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,modernize-*,readability-*'
HeaderFilterRegex: 'arrow/.*'
AnalyzeTemporaryDtors: true
CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
18 changes: 18 additions & 0 deletions .clang-tidy-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.
ipc-adapter-test.cc
memory-pool-test.cc
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,14 @@ matrix:
- language: r
cache: packages
latex: false
before_script:
- if [ $ARROW_CI_R_AFFECTED != "1" ]; then exit; fi
before_install:
- $TRAVIS_BUILD_DIR/ci/travis_install_linux.sh
- $TRAVIS_BUILD_DIR/ci/travis_before_script_cpp.sh --only-library
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TRAVIS_BUILD_DIR/cpp-install/lib
- export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$TRAVIS_BUILD_DIR/cpp-install/lib/pkgconfig
- $TRAVIS_BUILD_DIR/ci/travis_lint.sh
- pushd ${TRAVIS_BUILD_DIR}/r


Expand Down
20 changes: 11 additions & 9 deletions ci/detect-changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

perr = functools.partial(print, file=sys.stderr)

LANGUAGE_TOPICS = ['c_glib', 'cpp', 'go', 'java', 'js', 'python', 'ruby', 'rust']
LANGUAGE_TOPICS = ['c_glib', 'cpp', 'go', 'java', 'js', 'python',
'r', 'ruby', 'rust']

ALL_TOPICS = LANGUAGE_TOPICS + ['integration', 'site', 'dev']

Expand Down Expand Up @@ -66,7 +67,8 @@ def get_travis_head_commit():

def get_travis_commit_range():
cr = os.environ['TRAVIS_COMMIT_RANGE']
# See https://github.com/travis-ci/travis-ci/issues/4596#issuecomment-139811122
# See
# https://github.com/travis-ci/travis-ci/issues/4596#issuecomment-139811122
return cr.replace('...', '..')


Expand Down Expand Up @@ -136,16 +138,16 @@ def get_affected_topics(affected_files):
break
elif p in ('cpp', 'format'):
# Test C++ and bindings to the C++ library
for k in ('cpp', 'python', 'c_glib', 'ruby', 'integration'):
for k in ('cpp', 'python', 'c_glib', 'r', 'ruby', 'integration'):
affected[k] = True
elif p in ('java', 'js'):
affected[p] = True
affected['integration'] = True
elif p in ('c_glib'):
affected[p] = True
affected['ruby'] = True
elif p in ('go', 'integration', 'python', 'ruby', 'rust', 'site',
'dev'):
elif p in ('go', 'integration', 'python', 'r', 'ruby', 'rust',
'site', 'dev'):
affected[p] = True

return affected
Expand Down Expand Up @@ -174,8 +176,8 @@ def get_windows_shell_eval(env):

def run_from_travis():
if (os.environ['TRAVIS_REPO_SLUG'] == 'apache/arrow' and
os.environ['TRAVIS_BRANCH'] == 'master' and
os.environ['TRAVIS_EVENT_TYPE'] != 'pull_request'):
os.environ['TRAVIS_BRANCH'] == 'master' and
os.environ['TRAVIS_EVENT_TYPE'] != 'pull_request'):
# Never skip anything on master builds in the official repository
affected = dict.fromkeys(ALL_TOPICS, True)
else:
Expand Down Expand Up @@ -219,14 +221,14 @@ def run_from_appveyor():
if os.environ.get('TRAVIS'):
try:
print(run_from_travis())
except:
except Exception:
# Make sure the enclosing eval will return an error
print("exit 1")
raise
elif os.environ.get('APPVEYOR'):
try:
print(run_from_appveyor())
except:
except Exception:
print("exit 1")
raise
else:
Expand Down
6 changes: 6 additions & 0 deletions ci/travis_lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@ if [ "$ARROW_CI_PYTHON_AFFECTED" != "0" ]; then
--config=$ARROW_PYTHON_DIR/.flake8.cython \
$ARROW_PYTHON_DIR
fi

if [ "$ARROW_CI_R_AFFECTED" != "0" ]; then
pushd $ARROW_R_DIR
./lint.sh
popd
fi

0 comments on commit 52b4b8f

Please sign in to comment.