diff --git a/.github/hooks/pre-commit b/.github/hooks/pre-commit new file mode 100644 index 0000000..fa79554 --- /dev/null +++ b/.github/hooks/pre-commit @@ -0,0 +1,16 @@ +#!/bin/sh + +# Execute the make target +make test + +# Capture the exit status of the make command +STATUS=$? + +# If the make command fails, exit with the same status +if [ $STATUS -ne 0 ]; then + echo "Pre-commit hook failed: make test failed with status $STATUS" + exit $STATUS +fi + +# If the make command succeeds, allow the commit to proceed +exit 0 diff --git a/Makefile b/Makefile index 767f123..911eccf 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,11 @@ +install-git-hooks: + cp .github/hooks/pre-commit .git/hooks/pre-commit + chmod +x .git/hooks/pre-commit + +.PHONY: install-git-hooks + +all: install-git-hooks run + openapi-gen: docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \ -i /local/openapis/naas-openapi.json \ diff --git a/tests/unitests/test_cli_with_mock_domain.py b/tests/unitests/test_cli_with_mock_domain.py index 3440ee8..7fbf5f6 100644 --- a/tests/unitests/test_cli_with_mock_domain.py +++ b/tests/unitests/test_cli_with_mock_domain.py @@ -54,7 +54,7 @@ def test_create_valid_registry(mock_domain, capsys): def test_create_invalid_registry(mock_domain): app = TyperRegistryAdaptor(mock_domain) - with pytest.raises(ValidationError, match="string does not match regex"): + with pytest.raises(ValidationError, match="1 validation error for Registry"): app.create("invalid_registry_name", rich_preview=False)