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

Update pre-commit hooks #1154

Merged
merged 10 commits into from
Dec 14, 2022
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
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
Expand All @@ -27,7 +27,7 @@ AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python/rmm/_version.py export-subst
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ python/ @rapidsai/rmm-python-codeowners
**/cmake/ @rapidsai/rmm-cmake-codeowners

#build/ops code owners
.github/ @rapidsai/ops-codeowners
.github/ @rapidsai/ops-codeowners
ci/ @rapidsai/ops-codeowners
conda/ @rapidsai/ops-codeowners
**/Dockerfile @rapidsai/ops-codeowners
Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/documentation-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ A clear and concise description of what documentation is needed and why.

**Steps taken to search for needed documentation**
List any steps you have taken.

1 change: 0 additions & 1 deletion .github/ops-bot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ release_drafter: true
copy_prs: true
rerun_tests: true
recently_updated: true

48 changes: 33 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,49 @@
# Copyright (c) 2022, NVIDIA CORPORATION.
repos:
- repo: https://github.com/pycqa/isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
args: ["--settings-path=python/setup.cfg"]
args: ["--config-root=python/", "--resolve-all-configs"]
files: python/.*
exclude: __init__.py$
types: [text]
types_or: [python, cython]
types_or: [python, cython, pyi]
- repo: https://github.com/ambv/black
rev: 22.3.0
hooks:
- id: black
args: ["--config=python/pyproject.toml"]
- repo: https://github.com/PyCQA/flake8
rev: 3.8.3
rev: 5.0.4
hooks:
- id: flake8
alias: flake8
name: flake8
args: ["--config=python/.flake8"]
types: [python]
- id: flake8
alias: flake8-cython
name: flake8-cython
args: ["--config=python/.flake8.cython"]
types: [cython]
args: ["--config=python/setup.cfg"]
files: python/.*$
types: [file]
types_or: [python, cython]
additional_dependencies: ["flake8-force"]
- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.1.10
hooks:
- id: cython-lint
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v11.1.0
hooks:
- id: clang-format
types_or: [c, c++, cuda]
args: ["-fallback-style=none", "-style=file", "-i"]
- repo: https://github.com/sirosen/texthooks
rev: 0.4.0
hooks:
- id: fix-smartquotes
exclude: |
(?x)^(
^benchmarks/utilities/cxxopts.hpp
)
- repo: local
hooks:
- id: cmake-format
Expand Down
128 changes: 6 additions & 122 deletions ci/check_style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,126 +14,10 @@ rapids-dependency-file-generator \
rapids-mamba-retry env create --force -f env.yaml -n checks
conda activate checks

set +e
FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.02/cmake-format-rapids-cmake.json
export RAPIDS_CMAKE_FORMAT_FILE=/tmp/rapids_cmake_ci/cmake-formats-rapids-cmake.json
mkdir -p $(dirname ${RAPIDS_CMAKE_FORMAT_FILE})
wget -O ${RAPIDS_CMAKE_FORMAT_FILE} ${FORMAT_FILE_URL}

# Run isort and get results/return code
ISORT=$(isort --check-only python --settings-path=python/setup.cfg)
ISORT_RETVAL=$?

# Run black and get results/return code
BLACK=$(black --config python/pyproject.toml --check python)
BLACK_RETVAL=$?

# Run flake8 and get results/return code
FLAKE=$(flake8 --config=python/.flake8 python)
FLAKE_RETVAL=$?

# Run flake8-cython and get results/return code
FLAKE_CYTHON=$(flake8 --config=python/.flake8.cython)
FLAKE_CYTHON_RETVAL=$?

# Run clang-format and check for a consistent code format
CLANG_FORMAT=$(python scripts/run-clang-format.py 2>&1)
CLANG_FORMAT_RETVAL=$?

# Run cmake-format / cmake-lint and get results/return code
CMAKE_FILES=($(find . | grep -E "^.*\.cmake(\.in)?$|^.*/CMakeLists.txt$"))

CMAKE_FORMATS=()
CMAKE_FORMAT_RETVAL=0

CMAKE_LINTS=()
CMAKE_LINT_RETVAL=0

CURRENT_TAG=$(git tag --merged HEAD | grep -xE '^v.*' | sort --version-sort | tail -n 1 | tr -d 'v')
CURRENT_MAJOR=$(echo "${CURRENT_TAG}" | awk '{split($0, a, "."); print a[1]}')
CURRENT_MINOR=$(echo "${CURRENT_TAG}" | awk '{split($0, a, "."); print a[2]}')
CURRENT_SHORT_TAG="${CURRENT_MAJOR}.${CURRENT_MINOR}"
rapids-retry curl -s "https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${CURRENT_SHORT_TAG}/cmake-format-rapids-cmake.json" -o cmake/rapids-cmake.json

for cmake_file in "${CMAKE_FILES[@]}"; do
cmake-format --in-place --config-files cmake/config.json cmake/rapids-cmake.json -- "${cmake_file}"
TMP_CMAKE_FORMAT=$(git diff --color --exit-code -- "${cmake_file}")
TMP_CMAKE_FORMAT_RETVAL=$?
if [ "$TMP_CMAKE_FORMAT_RETVAL" != "0" ]; then
CMAKE_FORMAT_RETVAL=1
CMAKE_FORMATS+=("$TMP_CMAKE_FORMAT")
fi

TMP_CMAKE_LINT=$(cmake-lint --config-files cmake/config.json cmake/rapids-cmake.json -- "${cmake_file}")
TMP_CMAKE_LINT_RETVAL=$?
if [ "$TMP_CMAKE_LINT_RETVAL" != "0" ]; then
CMAKE_LINT_RETVAL=1
CMAKE_LINTS+=("$TMP_CMAKE_LINT")
fi
done


# Output results if failure otherwise show pass
if [ "$ISORT_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: isort style check; begin output\n\n"
echo -e "$ISORT"
echo -e "\n\n>>>> FAILED: isort style check; end output\n\n"
else
echo -e "\n\n>>>> PASSED: isort style check\n\n"
fi

if [ "$BLACK_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: black style check; begin output\n\n"
echo -e "$BLACK"
echo -e "\n\n>>>> FAILED: black style check; end output\n\n"
else
echo -e "\n\n>>>> PASSED: black style check\n\n"
fi

if [ "$FLAKE_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: flake8 style check; begin output\n\n"
echo -e "$FLAKE"
echo -e "\n\n>>>> FAILED: flake8 style check; end output\n\n"
else
echo -e "\n\n>>>> PASSED: flake8 style check\n\n"
fi

if [ "$FLAKE_CYTHON_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: flake8-cython style check; begin output\n\n"
echo -e "$FLAKE_CYTHON"
echo -e "\n\n>>>> FAILED: flake8-cython style check; end output\n\n"
else
echo -e "\n\n>>>> PASSED: flake8-cython style check\n\n"
fi

if [ "$CLANG_FORMAT_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: clang format check; begin output\n\n"
echo -e "$CLANG_FORMAT"
echo -e "\n\n>>>> FAILED: clang format check; end output\n\n"
else
echo -e "\n\n>>>> PASSED: clang format check\n\n"
fi

if [ "$CMAKE_FORMAT_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: cmake format check; begin output\n\n"
for CMAKE_FORMAT in "${CMAKE_FORMATS[@]}"; do
echo -e "$CMAKE_FORMAT"
echo -e "\n"
done
echo -e "\n\n>>>> FAILED: cmake format check; end output\n\n"
else
echo -e "\n\n>>>> PASSED: cmake format check\n\n"
fi

if [ "$CMAKE_LINT_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: cmake lint check; begin output\n\n"
for CMAKE_LINT in "${CMAKE_LINTS[@]}"; do
echo -e "$CMAKE_LINT"
echo -e "\n"
done
echo -e "\n\n>>>> FAILED: cmake lint check; end output\n\n"
else
echo -e "\n\n>>>> PASSED: cmake lint check\n\n"
fi

RETVALS=($ISORT_RETVAL $BLACK_RETVAL $FLAKE_RETVAL $FLAKE_CYTHON_RETVAL $CLANG_FORMAT_RETVAL $CMAKE_FORMAT_RETVAL $CMAKE_LINT_RETVAL)
IFS=$'\n'
RETVAL=$(echo "${RETVALS[*]}" | sort -nr | head -n1)

exit "${RETVAL}"
# Run pre-commit checks
pre-commit run --hook-stage manual --all-files --show-diff-on-failure
3 changes: 1 addition & 2 deletions ci/docs/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ for PROJECT in ${PROJECTS[@]}; do
if [ ! -d "api/$PROJECT/$BRANCH_VERSION" ]; then
mkdir -p api/$PROJECT/$BRANCH_VERSION
fi
rm -rf $DOCS_WORKSPACE/api/$PROJECT/$BRANCH_VERSION/*
rm -rf $DOCS_WORKSPACE/api/$PROJECT/$BRANCH_VERSION/*
done


mv $PROJECT_WORKSPACE/doxygen/html/* $DOCS_WORKSPACE/api/librmm/$BRANCH_VERSION
mv $PROJECT_WORKSPACE/python/docs/_build/html/* $DOCS_WORKSPACE/api/rmm/$BRANCH_VERSION

10 changes: 9 additions & 1 deletion ci/release/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,20 @@ function sed_runner() {
sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak
}

# cpp update
sed_runner 's/'" VERSION .*"'/'" VERSION ${NEXT_FULL_TAG}"'/g' CMakeLists.txt
sed_runner 's/'"rmm_version .*)"'/'"rmm_version ${NEXT_FULL_TAG})"'/g' python/CMakeLists.txt
sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' CMakeLists.txt

# Python update
sed_runner 's/'"rmm_version .*)"'/'"rmm_version ${NEXT_FULL_TAG})"'/g' python/CMakeLists.txt
sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' python/CMakeLists.txt

# cmake-format rapids-cmake definitions
sed_runner 's/'"branch-.*\/cmake-format-rapids-cmake.json"'/'"branch-${NEXT_SHORT_TAG}\/cmake-format-rapids-cmake.json"'/g' ci/checks/style.sh

# doxyfile update
sed_runner 's/'"PROJECT_NUMBER = .*"'/'"PROJECT_NUMBER = ${NEXT_SHORT_TAG}"'/g' doxygen/Doxyfile

# sphinx docs update
sed_runner 's/'"version =.*"'/'"version = \"${NEXT_SHORT_TAG}\""'/g' python/docs/conf.py
sed_runner 's/'"release =.*"'/'"release = \"${NEXT_FULL_TAG}\""'/g' python/docs/conf.py
2 changes: 1 addition & 1 deletion cmake/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"VERSION": "?",
"GIT_SHALLOW": "?",
"OPTIONS": "*",
"FIND_PACKAGE_ARGUMENTS": "*"
"FIND_PACKAGE_ARGUMENTS": "*"
}
},
"ConfigureTest": {
Expand Down
7 changes: 1 addition & 6 deletions conda/environments/all_cuda-115_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@ channels:
- rapidsai
- conda-forge
dependencies:
- black=22.3.0
- clang-tools=11.1.0
- clang=11.1.0
- cmake>=3.23.1,!=3.25.0
- cmakelang=0.6.13
- cuda-python>=11.7.1,<12.0
- cudatoolkit=11.5
- cython>=0.29,<0.30
- flake8=3.8.3
- gcovr>=5.0
- isort=5.10.1
- ninja
- numba>=0.49
- numpy>=1.19
- pre-commit
- pytest
- pytest-cov
- python>=3.8,<3.10
Expand Down
7 changes: 1 addition & 6 deletions conda/environments/all_cuda-116_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@ channels:
- rapidsai
- conda-forge
dependencies:
- black=22.3.0
- clang-tools=11.1.0
- clang=11.1.0
- cmake>=3.23.1,!=3.25.0
- cmakelang=0.6.13
- cuda-python>=11.7.1,<12.0
- cudatoolkit=11.6
- cython>=0.29,<0.30
- flake8=3.8.3
- gcovr>=5.0
- isort=5.10.1
- ninja
- numba>=0.49
- numpy>=1.19
- pre-commit
- pytest
- pytest-cov
- python>=3.8,<3.10
Expand Down
17 changes: 7 additions & 10 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ files:
arch: [x86_64]
includes:
- build
- checks
- cudatoolkit
- develop
- run
Expand All @@ -24,8 +25,7 @@ files:
checks:
output: none
includes:
- build
- develop
- checks
- py_version
channels:
- rapidsai
Expand All @@ -44,6 +44,11 @@ dependencies:
- output_types: conda
packages:
- spdlog>=1.8.5,<1.9
checks:
common:
- output_types: [conda, requirements]
packages:
- pre-commit
cudatoolkit:
specific:
- output_types: conda
Expand All @@ -68,15 +73,7 @@ dependencies:
common:
- output_types: [conda, requirements]
packages:
- black=22.3.0
- cmakelang=0.6.13
- flake8=3.8.3
- gcovr>=5.0
- isort=5.10.1
- output_types: conda
packages:
- clang=11.1.0
- clang-tools=11.1.0
py_version:
specific:
- output_types: conda
Expand Down
Loading