diff --git a/.github/tox.ini b/.github/tox.ini deleted file mode 100644 index bb8dcdbe..00000000 --- a/.github/tox.ini +++ /dev/null @@ -1,10 +0,0 @@ -[pycodestyle] -; E402: module level import not at top of file -; W503: line break before binary operator -; E231 missing whitespace after ',' (emitted by black) -; E203 whitespace before ':' (emitted by black) -ignore = E402,W503,E203,E231 -max-line-length = 160 -statistics = True -count = True -exclude = .* diff --git a/scripts/ci.sh b/scripts/ci.sh deleted file mode 100755 index 1d359c7c..00000000 --- a/scripts/ci.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (C) 2020 Mandiant, Inc. All Rights Reserved. -# Licensed 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: [package root]/LICENSE.txt -# 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. - -# Use a console with emojis support for a better experience -# Use venv to ensure that `python` calls the correct python version - -# Stash uncommitted changes -MSG="pre-push-$(date +%s)"; -git stash push -kum "$MSG" &>/dev/null ; -STASH_LIST=$(git stash list); -if [[ "$STASH_LIST" == *"$MSG"* ]]; then - echo "Uncommitted changes stashed with message '$MSG', if you abort before they are restored run \`git stash pop\`"; -fi - -restore_stashed() { - if [[ "$STASH_LIST" == *"$MSG"* ]]; then - git stash pop --index &>/dev/null ; - echo "Stashed changes '$MSG' restored"; - fi -} - -# Run isort and print state -python -m isort --profile black --length-sort --line-width 120 -c . > isort-output.log 2>&1; -if [ $? == 0 ]; then - echo 'isort succeeded!! 💖'; -else - echo 'isort FAILED! 😭'; - echo 'Check isort-output.log for details'; - restore_stashed; - exit 1; -fi - -# Run black and print state -python -m black -l 120 --check . > black-output.log 2>&1; -if [ $? == 0 ]; then - echo 'black succeeded!! 💝'; -else - echo 'black FAILED! 😭'; - echo 'Check black-output.log for details'; - restore_stashed; - exit 2; -fi - -# Run rule linter and print state -python ./scripts/lint.py ./rules/ > rule-linter-output.log 2>&1; -if [ $? == 0 ]; then - echo 'Rule linter succeeded!! 💘'; -else - echo 'Rule linter FAILED! 😭'; - echo 'Check rule-linter-output.log for details'; - restore_stashed; - exit 3; -fi - -# Run tests except if first argument is no_tests -if [ "$1" != 'no_tests' ]; then - echo 'Running tests, please wait ⌛'; - python -m pytest tests/ --maxfail=1; - if [ $? == 0 ]; then - echo 'Tests succeed!! 🎉'; - else - echo 'Tests FAILED! 😓'; - echo 'Run `pytest -v --cov=capa test/` if you need more details'; - restore_stashed; - exit 4; - fi -fi - -restore_stashed; -echo 'SUCCEEDED 🎉🎉'; - diff --git a/scripts/setup-hooks.sh b/scripts/setup-hooks.sh deleted file mode 100755 index 0ff607bd..00000000 --- a/scripts/setup-hooks.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# Copyright (C) 2020 Mandiant, Inc. All Rights Reserved. -# Licensed 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: [package root]/LICENSE.txt -# 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 -euo pipefail - -GIT_DIR=$(git rev-parse --show-toplevel); -cd "$GIT_DIR"; - -# hooks may exist already (e.g. git-lfs configuration) -# If the `.git/hooks/$arg` file doesn't exist it, initialize with `#!/usr/bin/env bash` -# After that append `scripts/hooks/$arg` and ensure they can be run -create_hook() { - if [[ ! -e .git/hooks/$1 ]]; then - echo "#!/usr/bin/env bash" > ".git/hooks/$1"; - fi - echo "scripts/ci.sh ${2:-}" >> ".git/hooks/$1"; - chmod +x .git/hooks/"$1"; -} - -printf 'Adding scripts/ci.sh to .git/hooks/'; -create_hook 'pre-commit' 'no_tests'; -create_hook 'pre-push';