├── quack ├── __init__.py └── quack.py ├── tests ├── __init__.py ├── quack.yaml └── quack_tests.py ├── setup.cfg ├── test.sh ├── requirements.txt ├── .gitignore ├── .travis.yml ├── contributing.md ├── .pre-commit-config.yaml ├── setup.py ├── quack.yaml ├── README.md └── LICENSE.txt /quack/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | """Quack Tests""" 2 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file = README.md 3 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | cd tests/ 2 | py.test quack_tests.py --verbose 3 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | argparse 2 | codecov 3 | gitpython 4 | pre-commit 5 | pytest 6 | pytest-cov 7 | pyyaml 8 | quack 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .quack 2 | .gitmodules 3 | *.pyc 4 | build 5 | dist 6 | quack.egg-info 7 | 8 | subscribe 9 | pyanalytic 10 | 11 | sort-selected 12 | django-admin 13 | 14 | toggleicon 15 | html2text.py -------------------------------------------------------------------------------- /tests/quack.yaml: -------------------------------------------------------------------------------- 1 | # Quack test build configuration. 2 | 3 | name: Quack Test 4 | 5 | modules: 6 | 7 | profiles: 8 | nested_quack_test: 9 | tasks: ['cmd:ls'] 10 | cmd: 11 | tasks: ['cmd:pwd', 'quack:nested_quack_test'] 12 | with_dep: 13 | tasks: [] 14 | dependencies: 15 | quack: 'nested_quack_test' 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "2.7" 4 | - "3.3" 5 | - "3.4" 6 | # command to install dependencies 7 | install: "pip install -r requirements.txt" 8 | # command to run tests 9 | script: 10 | - cd tests 11 | - py.test quack_tests.py --cov=../quack --verbose -s 12 | after_success: codecov 13 | notifications: 14 | webhooks: 15 | urls: 16 | - http://webhook.co/w6NSGybm 17 | -------------------------------------------------------------------------------- /contributing.md: -------------------------------------------------------------------------------- 1 | ### Contributing to Quack 2 | 3 | If you would like to contribute code to Quack you can do so through GitHub by forking the repository and sending a pull request. 4 | 5 | 6 | When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible. 7 | 8 | Before your code can be accepted into the project you must also sign the Contributor License Agreement (CLA). Please contact Love Sharma for a copy of the CLA. 9 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | - repo: git://github.com/pre-commit/pre-commit-hooks 2 | sha: 516cc9fa72ad09699f2c03ffbd0aa7f60d75b59a 3 | hooks: 4 | - id: trailing-whitespace 5 | - id: autopep8-wrapper 6 | - id: check-case-conflict 7 | - id: check-docstring-first 8 | - id: check-json 9 | - id: check-yaml 10 | - id: debug-statements 11 | - id: end-of-file-fixer 12 | - id: requirements-txt-fixer 13 | - id: detect-private-key 14 | - id: double-quote-string-fixer 15 | - id: flake8 16 | - repo: https://github.com/zonito/command-hook.git 17 | sha: 37d426efa47d52ce15f1c8744fa0593dbeb7b943 18 | hooks: 19 | - id: command 20 | args: [--command, 'sh test.sh'] 21 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | """Quack setup script.""" 2 | 3 | from setuptools import setup 4 | 5 | setup( 6 | name='quack', 7 | version='0.1.0', 8 | packages=['quack'], 9 | 10 | # dependencies 11 | install_requires=[ 12 | 'argparse', 13 | 'gitpython', 14 | 'pyyaml' 15 | ], 16 | 17 | # metadata for upload to PyPI 18 | author='Love Sharma', 19 | author_email='contact@lovesharma.com', 20 | description=('Insert specific module / folder from given ' 21 | 'repositories in yaml configurations.'), 22 | license='MIT', 23 | keywords='quack build submodule module dependencies'.split(), 24 | url='https://github.com/zonito/quack', # project homepage 25 | download_url='https://github.com/zonito/quack/archive/0.1.0.tar.gz', 26 | 27 | entry_points={ 28 | 'console_scripts': [ 29 | 'quack=quack.quack:main' 30 | ] 31 | } 32 | ) 33 | -------------------------------------------------------------------------------- /quack.yaml: -------------------------------------------------------------------------------- 1 | # Quack build configuration. 2 | 3 | name: Quack 4 | description: Quack configuration 5 | version: 0.0.6 6 | gitignore: true 7 | 8 | modules: 9 | pyanalytic: 10 | repository: https://github.com/zonito/PyAnalytics.git 11 | path: pyanalytics 12 | branch: dev 13 | subscribe: 14 | repository: https://github.com/zonito/subscribe.git 15 | hexsha: 9e3e9642cfea36f4ae216d27df100134920143b9 16 | toggleicon: 17 | repository: https://github.com/zonito/z-toggleicon.git 18 | tag: v1.0 19 | html2text.py: 20 | repository: https://github.com/aaronsw/html2text.git 21 | isfile: true 22 | path: html2text.py 23 | 24 | profiles: 25 | init: 26 | tasks: ['modules', 27 | 'quack:pyanalytic/build.yaml:update', 28 | 'cmd:pwd'] 29 | update: 30 | tasks: ['modules:html2text.py'] 31 | dependencies: 32 | quack: 'pyanalytic/build.yaml:update' 33 | clean: 34 | tasks: ['-modules'] 35 | -------------------------------------------------------------------------------- /tests/quack_tests.py: -------------------------------------------------------------------------------- 1 | """Unit tests.""" 2 | # pylint: disable=W0212 3 | 4 | import os 5 | from quack import quack 6 | 7 | 8 | def test_create_dir(): 9 | """Directory specific tests.""" 10 | quack._create_dir('qt') 11 | quack._create_dir('qt') 12 | assert os.path.exists('qt') 13 | quack._remove_dir('qt') 14 | quack._remove_dir('qt') 15 | assert not os.path.exists('qt') 16 | 17 | 18 | def test_get_config(): 19 | """Test on Get configuration.""" 20 | assert isinstance(quack._get_config(), dict) 21 | 22 | 23 | def test_run_tasks_cmd(): 24 | """Test on run command task.""" 25 | config = quack._get_config() 26 | profile = config.get('profiles').get('cmd', {}) 27 | assert quack._run_tasks(config, profile)['tasks'] == 2 28 | 29 | 30 | def test_run_with_dependencies(): 31 | """Test on run profile with dependencies.""" 32 | config = quack._get_config() 33 | profile = config.get('profiles').get('with_dep', {}) 34 | assert quack._run_tasks(config, profile)['dependencies'] == 1 35 | 36 | 37 | def test_run_nested_quack(): 38 | """Test on nested quack.""" 39 | assert quack._run_nested_quack(('quack', 'nested_quack_test')) 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Quack - Reuse modules. [![Build Status](https://api.travis-ci.org/Autodesk/quack.svg)](https://travis-ci.org/Autodesk/quack) 2 | 3 | #### Problem 4 | Currently, We dont have anything which helps us in reusing open source (especialy in git repositories) code. We see code - like it - clone it - copy file / folder and put it in our project and same code gets push in our repository, why? Why code redundancies? 5 | 6 | #### Solution 7 | Should be straight forward copy paste and put third party libraries in .gitignore - simple! And there shouldnt be any complexity needed to update libraries with latest changes. 8 | 9 | #### Quack Way 10 | * Add third party repository to quack configuration yaml. 11 | * Provide exact details (like an address) such as module / file path, hexsha, branch and tag. 12 | * Run `quack` That's it! 13 | 14 | ### Features: 15 | * Insert any module from any git repository, as a part of your project. 16 | * Handle dependencies - execute nested quack modules. 17 | * Multiple profiles to deal with different level of complexity. 18 | * Works on UNIX (Mac OS X, Linux) 19 | 20 | ### Installation 21 | There are two ways to install quack. Both should have roughly the same outcome, but have their advantages/disadvantages. 22 | 23 | ##### 1) PyPI / pip 24 | This method will always produce some stable build, but may not be the most up to date version. New functionality will come slower than building from this repo. 25 | ```shell 26 | $ pip install quack 27 | ``` 28 | 29 | Note, depending on your computer's settings, you may need to `sudo pip install quack`. 30 | 31 | ##### 2) Build from this repo 32 | This method will always include the latest features, but sometimes will not work at all. Oops! 33 | 34 | Clone the repo, then use setup.py to install the package. Note, this process will differ only slightly in a non-bash shell. 35 | ```fish 36 | $ git clone https://github.com/zonito/quack.git 37 | $ cd quack 38 | $ python setup.py install 39 | ``` 40 | Note, depending on your computer's settings, you may need to `sudo python setup.py install`. 41 | 42 | ### Examples: 43 | 44 | ##### Configurations 45 | ```yaml 46 | name: Quack 47 | description: Quack configuration 48 | version: 0.0.6 49 | gitignore: false 50 | 51 | modules: 52 | pyanalytic: 53 | repository: https://github.com/zonito/PyAnalytics.git 54 | path: pyanalytics 55 | branch: dev 56 | subscribe: 57 | repository: https://github.com/zonito/subscribe.git 58 | hexsha: 9e3e9642cfea36f4ae216d27df100134920143b9 59 | toggleicon: 60 | repository: https://github.com/zonito/z-toggleicon.git 61 | tag: v1.0 62 | 63 | profiles: 64 | init: 65 | tasks: ['modules', 66 | 'quack:pyanalytic/build.yaml:update', 67 | 'cmd:pwd'] 68 | update: 69 | tasks: ['modules:subscribe'] 70 | dependencies: 71 | quack: 'pyanalytic/build.yaml:update' 72 | clean: 73 | tasks: ['-modules'] 74 | ``` 75 | 76 | ##### Adding quack plugins to your project 77 | 78 | Once you have quack installed, adding quack plugins to your project is done with the quack.yaml configuration file. 79 | 80 | Add a file called quack.yaml to the root of your project. The pre-commit config file describes: 81 | 82 | | properties | Details | 83 | |-----------------|-----------------------------------------------------------------| 84 | | **name** | Project name | 85 | | **description** | Project description (Optional) | 86 | | **version** | Project version (Optional) | 87 | | **gitignore** | Update git ignore for sub module included (Optional, default: true) | 88 | | **modules** | Declared modules used within your project.