diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..dbf574b21 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,77 @@ +ci: + # autofix_commit_msg: | + # [pre-commit.ci] auto fixes from pre-commit.com hooks + # + # for more information, see https://pre-commit.ci + autofix_prs: false + autoupdate_branch: "" + autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' + autoupdate_schedule: weekly + skip: [] + submodules: false + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-added-large-files + - id: check-ast + - id: check-builtin-literals + # - id: check-case-conflict + - id: check-docstring-first + - id: check-executables-have-shebangs + # - id: check-illegal-windows-names + - id: check-json + - id: check-merge-conflict + - id: check-shebang-scripts-are-executable + exclude: '(^setup\.bash$|^setup/tue-data.bash$|^setup/tue-env.bash$|^setup/tue-functions.bash$|^setup/tue-misc.bash$)' + - id: check-symlinks + - id: check-toml + - id: check-vcs-permalinks + - id: check-xml + - id: check-yaml + - id: debug-statements + - id: destroyed-symlinks + # - id: detect-aws-credentials + - id: detect-private-key + # - id: double-quote-string-fixer + - id: end-of-file-fixer + # - id: file-contents-sorter + # files: [] + - id: fix-byte-order-marker + - id: fix-encoding-pragma + args: [--remove] + # - id: forbid-new-submodules + # - id: forbid-submodules + - id: mixed-line-ending + args: ["--fix", "no"] + # - id: name-tests-test + # args: [ + # "--pytest-test-first" # test_.*\.py + # # "--pytest" # .*_test\.py + # # "--unittest" # test.*\.py + # ] + - id: no-commit-to-branch + - id: pretty-format-json + # - id: requirements-txt-fixer + # - id: sort-simple-yaml + # files: [] + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + + - repo: https://github.com/psf/black + rev: 24.10.0 + hooks: + - id: black + args: [--check, --diff, --color] + + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.10.0.1 + hooks: + - id: shellcheck + files: '\S\.(bash|sh)' + + - repo: https://github.com/pre-commit-ci/pre-commit-ci-config + rev: v1.6.1 + hooks: + - id: check-pre-commit-ci-config diff --git a/ci/azure_commit_range.py b/ci/azure_commit_range.py old mode 100644 new mode 100755 index ddf16f61b..936be493c --- a/ci/azure_commit_range.py +++ b/ci/azure_commit_range.py @@ -1,10 +1,5 @@ #! /usr/bin/env python3 -import json -import os -import sys -from urllib.request import urlopen - """ Script to determine the commit range of a build in azure pipelines. @@ -15,6 +10,11 @@ If the range is just 1 commit, an empty string is printed. """ +import json +import os +import sys +from urllib.request import urlopen + TEAM_FOUNDATION_URI = os.getenv("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI") TEAM_PROJECT = os.getenv("SYSTEM_TEAMPROJECT") BUILD_ID = os.getenv("BUILD_BUILDID") diff --git a/ci/organization-packages.sh b/ci/organization-packages.sh old mode 100644 new mode 100755 diff --git a/installer/lsb_release.py b/installer/lsb_release.py old mode 100644 new mode 100755 diff --git a/installer/tue-get-dep.bash b/installer/tue-get-dep.bash index aa00f521a..fecfb3ed4 100755 --- a/installer/tue-get-dep.bash +++ b/installer/tue-get-dep.bash @@ -21,7 +21,7 @@ function _show_dep fi local indent_str - indent_str=$(perl -E 'say "--" x '$indent) + indent_str=$(perl -E 'say "--" x '"${indent}") if [ -n "$2" ] then @@ -34,7 +34,7 @@ function _show_dep else if [ -n "$LEVEL" ] then - if [[ $indent > $LEVEL ]] + if [[ ${indent} -gt ${LEVEL} ]] then return fi diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..c18fdf4dd --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[tool.black] +line-length = 120 +target-version = ["py38"] diff --git a/setup/tue-env-config.bash b/setup/tue-env-config.bash index 1eb7e66f4..68bcefb7a 100755 --- a/setup/tue-env-config.bash +++ b/setup/tue-env-config.bash @@ -150,7 +150,7 @@ function tue-env-set echo -e "[tue-env](config) Environment '${tue_env}' has '${option}' set to '${value}'" } -function _main +function _tue-env-config-main { if [ -z "$1" ] then @@ -190,4 +190,6 @@ function _main fi } -_main "$@" +_tue-env-config-main "$@" + +unset -f _tue-env-config-main