|
| 1 | +Guide for contributors |
| 2 | +============================ |
| 3 | + |
| 4 | +We welcome everyone’s contributions. The development of tensorcircuit are open-sourced and centered on GitHub. |
| 5 | + |
| 6 | +There are various ways to contribute: |
| 7 | + |
| 8 | +* Answering questions on tensorcircuit’s discussions page or issue page. |
| 9 | + |
| 10 | +* Rasing issues such as bug report or feature request on tensorcircuit's issue page. |
| 11 | + |
| 12 | +* Improving tensorcircuit's documentation (docstrings/tutorials) by pull requests. |
| 13 | + |
| 14 | +* Contributing to tensorcircuit's codebase by pull requests. |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +Pull Request Guidelines |
| 19 | +------------------------------- |
| 20 | + |
| 21 | +We welcome pull requests from everyone. But for large PRs related to feature enhencement or API changes, we ask that you first open a GitHub issue to discuss on your proposals. |
| 22 | + |
| 23 | +We develop tensorcircuit using git on GitHub, so basic knowledge on git and GitHub is assumed. |
| 24 | + |
| 25 | +The following git workflow is recommended to contribute by PR: |
| 26 | + |
| 27 | +* Fork the tensorcircuit GitHub repository by clicking the Fork button from GitHub. This will create a fork version of the code repository in your own GitHub account. |
| 28 | + |
| 29 | +* Configure the python enviroment locally for development. ``pip install -r requirements.txt`` and ``pip install -r requirements-dev.txt`` are recommended. Extra packages may be required for specific development tasks. |
| 30 | + |
| 31 | +* Clone your fork repository locally and setup upstreams to the official tensorcircuit repository. And configure your git user and email so that they match your GitHub account if you haven't. |
| 32 | + |
| 33 | +.. code-block:: bash |
| 34 | +
|
| 35 | + git clone <your-forked-repo-git-link> |
| 36 | + cd tensorcircuit |
| 37 | + git remote add upstream <offical-repo-git-link> |
| 38 | + git config user.name <GitHub name> |
| 39 | + git config user.email <GitHub email> |
| 40 | +
|
| 41 | +* Pip installing your fork from source. This allows you to modify the code locally and immediately test it out, ``python setup.py develop`` |
| 42 | + |
| 43 | +* Create a feature branch where you will develop from, don't open PR from your master/main branch, ``git checkout -b name-of-change``. |
| 44 | + |
| 45 | +* Make sure the changes can pass all checks by running: ``./check_all.sh``. (See details for checks below) |
| 46 | + |
| 47 | +* Once you are satisfied with your change, create a commit as follows: |
| 48 | + |
| 49 | +.. code-block:: bash |
| 50 | +
|
| 51 | + git add file1.py file2.py ... |
| 52 | + git commit -m "Your commit message (should be brief and informative)" |
| 53 | + |
| 54 | +* You should sync your code with the official repo: |
| 55 | + |
| 56 | +.. code-block:: bash |
| 57 | +
|
| 58 | + git fetch upstream |
| 59 | + git rebase upstream/master |
| 60 | + # resolve conflicts if any |
| 61 | +
|
| 62 | +* Note that PRs typically comprise a single git commit, you should squash all you commits in the feature branch. Using ``git rebase -i`` for commits squash, see `instructions <https://www.internalpointers.com/post/squash-commits-into-one-git>`_ |
| 63 | + |
| 64 | +* Finally, push your commit from your feature branch and create a remote branch in your forked repository on GitHub that you can use to create a pull request from: ``git push --set-upstream origin name-of-change``. |
| 65 | + |
| 66 | +* Create a pull request from official tensorcircuit repository and send it for review. Some comments and remarks attached with the PR are recommended. If the PR is not finally finished, please add [WIP] at the begining of the title of your PR. |
| 67 | + |
| 68 | +* The PRs will be reviewed by developers of tensorcircuit and it will get approved or change requested. In the latter case, you can further revise the PR according to suggestions and feedbacks from the code reviewers. |
| 69 | + |
| 70 | +* The PRs you opened can be automatically updated once you further push commits to your forked repository. Please ping the code reviewer in the PR dialogue once you finished the change. |
| 71 | + |
| 72 | + |
| 73 | +Checks and Tests |
| 74 | +-------------------- |
| 75 | + |
| 76 | +The simplest way to ensure the codebase are ok with checks and tests, is to run one-in-all scripts ``./check_all.sh`` (you may need to ``chmod +x check_all.sh`` to grant permissions on this file). |
| 77 | + |
| 78 | +The scripts include the following components: |
| 79 | + |
| 80 | +* black |
| 81 | + |
| 82 | +* mypy |
| 83 | + |
| 84 | +* pylint |
| 85 | + |
| 86 | +* pytest |
| 87 | + |
| 88 | +* sphinx doc builds |
| 89 | + |
| 90 | +Make sure the scripts check are successful by 💐. |
| 91 | + |
| 92 | +The similar tests and checks are also available via GitHub action as CI infrastructures. |
0 commit comments