Skip to main content
Glama
validate_workflow.cpython-312.pyc13.8 kB
� ��h�)��6�dZddlZddlZddlZddlZddlZddlZddlmZm Z m Z m Z Gd�d�Z de ddfd�Zde ddfd �Zde ddfd �Zde ddfd �Zd e e de e effd �Zdefd�Zde defd�Zde defd�Zdefd�Zedk(rej4e��yy)aM Attio MCP Workflow Validator This script validates adherence to Attio MCP workflow requirements by checking: 1. Git commit message format and issue references 2. Branch naming conventions 3. Verification of test execution 4. Documentation requirements Usage: ./build/validate_workflow.py [--pre-commit] [--issue-close ISSUE_ID] �N)�Dict�List�Optional�Tuplec�(�eZdZdZdZdZdZdZdZdZ y) �Colorz%Terminal colors for formatted output.zzzzzzN) �__name__� __module__� __qualname__�__doc__�RED�GREEN�YELLOW�BLUE�BOLD�END���L/Users/kesslerio/GDrive/Projects/attio-mcp-server/build/validate_workflow.pyrrs#��/� �C� �E� �F� �D� �D� �Crr�message�returnc��ttj�tj�dtj�d|���y)zPrint error message in red.zERROR:� N)�printrr rr�rs r� print_errorr"s+�� �U�Y�Y�K�� � �|�6�%�)�)��A�g�Y� ?�@rc��ttj�tj�dtj�d|���y)z Print warning message in yellow.zWARNING:rN)rrrrrrs r� print_warningr's+�� �U�\�\�N�5�:�:�,�h�u�y�y�k��7�)� D�Erc��ttj�tj�dtj�d|���y)zPrint success message in green.zSUCCESS:rN)rrrrrrs r� print_successr ,s+�� �U�[�[�M�%�*�*��X�e�i�i�[��'�� C�Drc��ttj�tj�dtj�d|���y)zPrint info message in blue.zINFO:rN)rrrrrrs r� print_infor"1s+�� �U�Z�Z�L���� �E�%�)�)��A�g�Y� ?�@r�commandc�� tj|dtjtjd��}|jj �|j fS#t$r}t|�dfcYd}~Sd}~wwxYw)z,Run command and return output and exit code.FT)�check�stdout�stderr�text�N) � subprocess�run�PIPE�STDOUTr&�strip� returncode� Exception�str)r#�result�es r� run_commandr46sl�� ���� ���?�?��$�$��  ���}�}�"�"�$�f�&7�&7�7�7�� ���1�v�q�y����s�AA� A>�' A9�3A>�9A>c�D��tgd��\}}|j���dk(r td�ygd�}t�fd�|D��s!t d��dd j |����y t jd ��st d��d ��y td��d ��y)z)Validate branch name follows conventions.)�git�branchz--show-current�mainzUYou are on the main branch. Create a feature branch unless this is a critical hotfix.T)zfeature/zfix/zdocs/z refactor/ztest/c3�@�K�|]}�j|����y�w�N�� startswith)�.0�prefix� branch_names �r� <genexpr>z'validate_branch_name.<locals>.<genexpr>Ps�����K�N�&�{�%�%�f�-�N���z Branch name 'z' should start with one of: �, Fz^[a-z0-9/\-_]+$zJ' should only contain lowercase letters, numbers, hyphens, and underscoresz' follows naming conventions) r4r.r�anyr�join�re�matchr )� branch_output�_�valid_prefixesr?s @r�validate_branch_namerJEs����"�#F�G��M�1��%�%�'�K��f���m�n��H�N� �K�N�K� K��m�K�=�0L�T�Y�Y�We�Mf�Lg�h�i�� �8�8�&� � 4��m�K�=�0z�{�|���M�+��.J�K�L� r� commit_msgc�� �td|dd�d��|jd�r td�yd|v}|r td �ygd �}|jd �d j�� td � �d��t � fd�|D��}t � fd�|D��}d}|D].}|j �}|dd� j �ddvs�,d}n|xs|xs|}|s-t ddj|����t d� �d��ytd�tjd|�} | s td�ytd| jd����y)z4Validate commit message format and issue references.zValidating commit message: 'N�2z...'zMerge z*Detected merge commit, skipping validationTz[HOTFIX]z2Detected hotfix commit, skipping prefix validation)zFeature:zFix:zDocs:zDocumentation:z Refactor:zTest:zChore:� rz First line: '�'c3�@�K�|]}�j|����y�wr:r;�r=r>� first_lines �rr@z*validate_commit_message.<locals>.<genexpr>us�����L�8��z�,�,�V�4�8�rAc3�x�K�|]1}�j�j|j�����3y�wr:)�lowerr<rQs �rr@z*validate_commit_message.<locals>.<genexpr>xs/����� f�]e�SY��!1�!1�!3�!>�!>�v�|�|�~�!N�]e�s�7:F������z)Commit message should start with one of: rBzCurrent first line: 'zCommit message has valid prefixz(#\d+)z<Commit message should reference an issue number (e.g., #123)zFound issue reference: r)) r"r<�splitr.rCrTrrDr rE�searchr�group) rK� is_hotfix�prefixes� direct_match�case_insensitive_match� fuzzy_matchr>� prefix_lower� has_prefix� issue_refrRs @r�validate_commit_messagerb\s�����-�j��"�o�->�d�C�D����X�&��?�@���j�(�I���G�H��_�H��!�!�$�'��*�0�0�2�J���z�l�!�,�-��L�8�L�L�L�!� f�]e� f�f���K����|�|�~� � ��� � � 0� 0� 2�3�B� 7� 7��K� � ��F�!7�F�;�J� ��?�� � �(�@S�?T�U�V��+�J�<�q�9�:���7�8�� � �)�Z�0�I� ��T�U� � �/� ����0B�/C�D�E� r�issue_idc��tddd|g�\}}|dk7rtd|�d|���ytjd|�}|rtd |�d t |��d ��ygd �}g}|D]}||vs�|j |��|r!td |�d dj |����yd|vrtd |�d��ytddd|ddg�\}} tj|�} | jdg�D� cgc]} | d�� } } td�| D��} td�| D��} td�| D��}td�| D��}g}| s|j d�| s|j d�|s|j d�|s|j d�|r!td |�ddj |����y td |�d��y cc} w#tjtf$r}td|�d|���Yd}~yd}~wwxYw)!z$Validate issue closure requirements.�gh�issue�viewrzFailed to retrieve issue #�: Fz- \[ \]zIssue #z has z unchecked criteria)zImplementation DetailszKey Implementation ElementszLessons LearnedzChallenges/SolutionszFuture Considerationsz% is missing these required sections: rBu✅ VERIFICATION:z& is missing the verification statementz--json�labels�namec3�hK�|]*}|jd�xr|ddj����,y�w)�Pr)�N)r<�isdigit�r=�labels rr@z)validate_issue_closure.<locals>.<genexpr>�s5����c�Wb�e�5�+�+�C�0�I�U�1�Q�Z�5G�5G�5I�I�Wb�s�02c3�$K�|]}|dv��� y�w))�bug�feature� enhancement� documentation�testNrros rr@z)validate_issue_closure.<locals>.<genexpr>�s����t�hs�_d�u� Z�Z�hs�s�c3�>K�|]}|jd����y�w)zarea:Nr;ros rr@z)validate_issue_closure.<locals>.<genexpr>�s����J�k�U�u�'�'��0�k���c3�>K�|]}|jd����y�w)zstatus:Nr;ros rr@z)validate_issue_closure.<locals>.<genexpr>�s����N�+���)�)�)�4�+�rxzPriority (P0-P4)zType (bug, feature, etc.)z Area (area:*)zStatus (status:*)z' is missing required label categories: z"Failed to parse labels for issue #Nz meets all closure requirementsT)r4rrE�findall�len�appendrD�json�loads�getrC�JSONDecodeError�KeyErrorr )rc�output� exit_code�unchecked_items�comment_sections�missing_sections�section� labels_outputrH� labels_datarp� label_names� has_priority�has_type�has_area� has_status�missing_label_categoriesr3s r�validate_issue_closurer��sS��$�T�7�F�H�$E�F��F�I��A�~��0�� �"�V�H�E�F���j�j��V�4�O���g�h�Z�u�S��-A�,B�BU�V�W������#�� �&� � � #� #�G� ,�$���g�h�Z�'L�T�Y�Y�Wg�Mh�Li�j�k���&�(��g�h�Z�'M�N�O��#�D�'�6�8�X�x�#X�Y��M�1���j�j��/� �2=�/�/�(�B�2O�P�2O��u�V�}�2O� �P��c�Wb�c�c� ��t�hs�t�t���J�k�J�J���N�+�N�N� �#%� �� $� +� +�,>� ?�� $� +� +�,G� H�� $� +� +�O� <�� $� +� +�,?� @� #� �'�(��+R�SW�S\�S\�]u�Sv�Rw�x� y�� $��G�H�:�%D�E�F� ��7Q��, � � �(� +���8�� �"�Q�C�H�I����s+� )G�6 G�B:G�G�H�,H�Hc���tjd��}|jddd��|jdd� �|j�}|j�r�t �}t jjd �xst jjd �}|rNtd |��� t|d �5}|j�j�}ddd�td�n�t jjd�dt jj!t j"�d�dg}d}|D]h}|s�t jj%|�s�& t|d �5}|j�j�}ddd�td|���ns td�d}t'|�} |r| syt)d�y|j*rt-|j*�ryy|j/�y#1swY��7xYw#t$r}td|���d}Yd}~��d}~wwxYw#1swY��xYw#t$r}td|�d|���Yd}~��)d}~wwxYw)Nz(Validate Attio MCP workflow requirements)� descriptionz --pre-commit� store_truezRun pre-commit validations)�action�helpz --issue-closez>Validate issue closure requirements for the specified issue ID)r��HUSKY_GIT_PARAMS� GIT_PARAMSzUsing Husky params: �rz2Successfully read commit message from Husky paramsz)Error reading Husky commit message file: �GIT_COMMIT_MSG_FILEz.git/COMMIT_EDITMSGz.git/MERGE_MSGz&Successfully read commit message from zError reading rhz6Could not find commit message file, using test messagezFeature: Test commit messager)zAll pre-commit checks passed!r)�argparse�ArgumentParser� add_argument� parse_args� pre_commitrJ�os�environrr"�open�readr.r0r�pathrD�getcwd�existsrbr � issue_closer�� print_help) �parser�args� branch_valid� husky_params�frKr3�possible_commit_msg_files� file_path� commit_valids rr8r8�s#�� � $� $�1[� \�F� ����|�B^��_� ����.n��o� � � � �D� ���+�-� ��z�z�~�~�&8�9�Y�R�Z�Z�^�^�L�=Y� � � �-�l�^�<� =� "��,��,��!"������!1�J�-��O�P�� � ���4�5�%���� � �R�Y�Y�[�*?�@� � )� %��J�6� ������� �!:�I�!�)�S�1�Q�)*������)9�J�2�"�%K�I�;�#W�X�� 7�� �R� S�7�J�.�z�:� ��<���5�6�� � � � !�$�"2�"2� 3��� �����a-�,��� "�� I�!��M�N�!� �� "�� 2�1��%�I�%��y�k��A�3�&G�H�H��I�s`�6 H#�H�!H#�3 I�?I �I�H �H#�# I�,I�I� I �I� I:�I5�5I:�__main__)r r�r}r�rEr*�sys�typingrrrrrr1rrr r"�intr4�boolrJrbr�r8r �exitrrr�<module>r�s �� �� � � �� �.�.���A��A��A� F�3�F�4�F� E�3�E�4�E� A��A��A� ��c�� �u�S�#�X�� ��d��.8��8��8�vD�S�D�T�D�NC�c�C�L �z�� �C�H�H�T�V��r

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kesslerio/attio-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server