Skip to content

Commit

Permalink
feat/check-v2 add e2e for check v
Browse files Browse the repository at this point in the history
  • Loading branch information
hminaee-tc committed Jul 2, 2024
1 parent 4a141af commit 5e41959
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 3 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
with:
python-version: 3.11

- name: Run test-package-e2e.sh
- name: Run test-package-e2e.sh for find-replace-strings package
run: |
cd opencepk_lib_python_common/find_and_replace_strings_package/tests-package-e2e
./test-package-e2e.sh
Expand All @@ -67,8 +67,14 @@ jobs:
with:
python-version: 3.11

- name: Run test-pre-commit-hook.sh
- name: Run test-pre-commit-hook.sh for find-replace-strings package
run: |
pip install pre-commit
cd opencepk_lib_python_common/find_and_replace_strings_package/tests-pre-commit-hook
./test-pre-commit-hook.sh
- name: Run test-pre-commit-hook.sh for check version package
run: |
pip install pre-commit
cd opencepk_lib_python_common/pypi_bumpversion_check_package/tests-pre-commit-hook
./test-pre-commit-hook.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import toml
import sys
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:

# -----------------------------
# PYPI bumpversion check
# -----------------------------
- repo: local
hooks:
- id: install-pypi_bumpversion_check-requirements
name: Install PYPI bumpversion check requirements
entry: sh -c 'python3 -m pip install -r ./opencepk_lib_python_common/pypi_bumpversion_check_package/pypi_bumpversion_check/requirements.txt && exit 0'
language: system
always_run: true
- repo: local
hooks:
- id: python-pypi-version-check
name: python-pypi-version-check
entry: python3 -m opencepk_lib_python_common.pypi_bumpversion_check_package.pypi_bumpversion_check
language: python
exclude_types:
- binary
args: ['./opencepk_lib_python_common/pypi_bumpversion_check_package/tests-pre-commit-hook/pyproject.test']
pass_filenames: false # Do not pass filenames to the hook (this is important to keep)
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = { find = { where = ["."] } }

[project]
name = "opencepk-lib-python-common"
version = "0.0.0"
description = "Python package and pre-commit-hook for finding and replacing string(s) in file(s)."
readme = "README.md"
license = { text = "GPLv3" }
authors = [{name = "OpenCEPK Open Cloud Engineering Platform Kit", email = "opencepk@gmail.com"}]
requires-python = ">=3.9"

keywords = ["find", "replace", "string", "file", "pre-commit", "hook", "git", "tool", "utility", "opencepk"]
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Natural Language :: English",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Topic :: File Formats :: JSON",
"Topic :: Software Development :: Pre-processors",
"Topic :: Software Development :: Version Control :: Git",
"Topic :: Text Processing",
"Topic :: Text Processing :: Filters",
"Topic :: Text Processing :: General",
"Topic :: Utilities"
]

[project.entry-points."console_scripts"]
python-pypi-version-check = "opencepk_lib_python_common.pypi_bumpversion_check_package.pypi_bumpversion_check.main:main"
find-and-replace-strings = "opencepk_lib_python_common.find_and_replace_strings_package.find_and_replace_strings.main:main"
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

TEST_DIR_FROM_ROOT="opencepk_lib_python_common/pypi_bumpversion_check_package/tests-pre-commit-hook"
TEST_DIR="tests-pre-commit-hook"
TEST_SCRIPT_FILENAME=$(basename -- "$0")
TEST_SCRIPT_NAME="${TEST_SCRIPT_FILENAME%.*}"
TEST_TARGET_FILE="README_TEST_PRE_COMMIT.md"

#-------------------------------
# Run the pre-commit hook test
#-------------------------------
echo "${TEST_SCRIPT_NAME}: Running pre-commit using ${TEST_DIR_FROM_ROOT}/.pre-commit-config.yaml"
cd ../../..
pwd
pre-commit run -a -c "${TEST_DIR_FROM_ROOT}/.pre-commit-config.yaml"

# #-------------------------------
# # Evaluate results
# #-------------------------------
# echo "${TEST_SCRIPT_NAME}: Running (cd ${TEST_DIR} && diff ${TEST_TARGET_FILE} ${TEST_TARGET_FILE}.expected)"
# echo "${TEST_SCRIPT_NAME}: Fetching return code of diff"
# diff "./${TEST_TARGET_FILE}" "${TEST_TARGET_FILE}.expected"
# evaluate_diff_status=$?

# #-------------------------------
# # Run the pre-commit hook reset
# #-------------------------------
# echo "${TEST_SCRIPT_NAME}: Resetting ${TEST_DIR}/${TEST_TARGET_FILE} file to original state"
# cp -pf "${TEST_TARGET_FILE}.template" "${TEST_TARGET_FILE}"

# #-------------------------------
# # Exit with exit code of diff evaluation
# #-------------------------------
# echo "${TEST_SCRIPT_NAME}: Exit code = $evaluate_diff_status"
# exit $evaluate_diff_status

0 comments on commit 5e41959

Please sign in to comment.