From 5749762bba6dfef36a86741a69508951f7294984 Mon Sep 17 00:00:00 2001 From: Maxime Jublou Date: Tue, 18 Jun 2024 09:35:02 +0200 Subject: [PATCH 1/2] ci: Install git hooks --- .github/hooks/pre-commit | 16 ++++++++++++++++ Makefile | 8 ++++++++ 2 files changed, 24 insertions(+) create mode 100644 .github/hooks/pre-commit 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 \ From 041f22c7c58918a787781c73266818001c96e516 Mon Sep 17 00:00:00 2001 From: Maxime Jublou Date: Tue, 18 Jun 2024 09:35:20 +0200 Subject: [PATCH 2/2] fix: tests --- tests/unitests/test_cli_with_mock_domain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)