From f1a34f7ee494890248ea33bc109543bde4b95b29 Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Fri, 10 May 2024 12:52:36 +0200 Subject: [PATCH] [pre-commit]Run basic pre-commit checks and bashate --- .pre-commit-config.yaml | 29 +++++++++++++++++++ README.md | 2 +- osbs_dockerfile_template_scripts/default.sh | 2 +- .../osp-director-operator.env | 1 - stage_downstream_rebase.sh | 5 ++-- 5 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..1c53722 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,29 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-added-large-files + - id: fix-byte-order-marker + - id: check-case-conflict + - id: check-executables-have-shebangs + exclude: ^vendor + - id: check-shebang-scripts-are-executable + exclude: ^vendor + - id: check-merge-conflict + - id: check-symlinks + - id: destroyed-symlinks + - id: check-yaml + args: [-m] + - id: check-json + - id: detect-private-key + - id: end-of-file-fixer + exclude: ^vendor + - id: no-commit-to-branch + - id: trailing-whitespace + exclude: ^vendor + +- repo: https://github.com/openstack/bashate.git + rev: 2.1.1 + hooks: + - id: bashate + entry: bashate --error . diff --git a/README.md b/README.md index 34daa28..d1ab3d5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # openstack-k8s-operators-ci ## Description -Common scripts and tools for the openstack-k8s-operators CI that can be used inside or outside of any CI platform. +Common scripts and tools for the openstack-k8s-operators CI that can be used inside or outside of any CI platform. ## Test Coverage The following tests are currently available to be run: diff --git a/osbs_dockerfile_template_scripts/default.sh b/osbs_dockerfile_template_scripts/default.sh index d378525..1e8eccf 100644 --- a/osbs_dockerfile_template_scripts/default.sh +++ b/osbs_dockerfile_template_scripts/default.sh @@ -21,7 +21,7 @@ function replace_ARG_values() { do # Replace all Dockerfile ${ARGNAME} with the value from $ENVFILE # Use non priting character $'\001' to ensure it's not in the value - # sed is preffered over envsubst + # sed is preffered over envsubst sed -ir s$'\001'\${"$value"}$'\001'"${!value}"$'\001' "$input_dockerfile" # Ensure none of the specified arguments is set diff --git a/osbs_dockerfile_vars/osp-director-operator.env b/osbs_dockerfile_vars/osp-director-operator.env index adb453e..c09d3fc 100644 --- a/osbs_dockerfile_vars/osp-director-operator.env +++ b/osbs_dockerfile_vars/osp-director-operator.env @@ -4,4 +4,3 @@ IMAGE_SUMMARY="OSP Director Operator" IMAGE_DESC="This image includes the osp-director-operator" USER_ID="" - diff --git a/stage_downstream_rebase.sh b/stage_downstream_rebase.sh index 56e2bdb..d87a4b0 100755 --- a/stage_downstream_rebase.sh +++ b/stage_downstream_rebase.sh @@ -1,3 +1,4 @@ +#!/bin/bash # Based on the stage_downstream_rebase.sh from dprince # https://github.com/openstack-k8s-operators/osp-director-operator/pull/397 # @@ -35,7 +36,7 @@ function download_operator_sdk() { OPERATOR_SDK="${SDK_TMP_DIR}/operator-sdk" } -# Do check if the branch is specified in upstream_to_downstream variable +# Do check if the branch is specified in upstream_to_downstream variable function check_if_branch_exists() { if [ -z ${upstream_to_downstream[${1}]} ]; then echo "Upstream branch ${1} is not supported by this script !" @@ -240,7 +241,7 @@ if [ -z "$operator_branch" ]; then fi popd if [ -z "$operator_branch" ]; then - echo "ERROR: No upstream branch found!" + echo "ERROR: No upstream branch found!" exit -1 fi fi