|
| 1 | +# Welcome to the quizx development guide <!-- omit in toc --> |
| 2 | + |
| 3 | +This guide is intended to help you get started with developing quizx. |
| 4 | + |
| 5 | +If you find any errors or omissions in this document, please [open an issue](https://github.com/Quantomatic/quizx/issues/new)! |
| 6 | + |
| 7 | +## #️⃣ Setting up the development environment |
| 8 | + |
| 9 | +To develop the rust library, you will need to have the rust toolchain installed. You can install it by following the instructions at [https://www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install). |
| 10 | + |
| 11 | +If you are using VSCode, you can install the `rust-analyzer` extension to get code completion and other features. |
| 12 | + |
| 13 | +To develop the python library, you will additionally need the Poetry package manager. You can install it by following the instructions at [https://python-poetry.org/docs/](https://python-poetry.org/docs/). |
| 14 | + |
| 15 | +Finally, we provide a `just` file to help manage the common development workflow. You can install `just` by following the instructions at [https://just.systems/](https://just.systems/). |
| 16 | + |
| 17 | +Once you have these installed, run `just setup` to download the necessary dependencies and set up some pre-commit hooks. |
| 18 | + |
| 19 | +Run `just` to see all available commands. |
| 20 | + |
| 21 | +## 🚀 Building the project |
| 22 | + |
| 23 | +There is a miscellaneous collection of rust programs written using the library, |
| 24 | +found in `src/bin`. To execute these programs, run: |
| 25 | + |
| 26 | +```bash |
| 27 | +cargo run --release --bin <program_name> |
| 28 | +``` |
| 29 | + |
| 30 | +To build the python library, run: |
| 31 | + |
| 32 | +```bash |
| 33 | +# Ensure you have all the necessary dependencies installed |
| 34 | +poetry install |
| 35 | +# Enter the environment with the installed dependencies |
| 36 | +poetry shell |
| 37 | +# Build the python library |
| 38 | +maturin develop |
| 39 | +# The library will now be available for import in python |
| 40 | +python -c "import quizx" |
| 41 | +``` |
| 42 | + |
| 43 | +## 🏃 Running the tests |
| 44 | + |
| 45 | +To compile and test the code, run: |
| 46 | + |
| 47 | +```bash |
| 48 | +just test |
| 49 | +# or, to test only the rust code or the python code |
| 50 | +just test rust |
| 51 | +just test python |
| 52 | +``` |
| 53 | + |
| 54 | +## 💅 Coding Style |
| 55 | + |
| 56 | +The `rustfmt` and `ruff` tools are used to enforce a consistent coding for rust |
| 57 | +and python code, respectively. The CI will fail if the code is not formatted |
| 58 | +correctly. |
| 59 | + |
| 60 | +To format your code, run: |
| 61 | + |
| 62 | +```bash |
| 63 | +just format |
| 64 | +``` |
| 65 | + |
| 66 | +We also use various linters to catch common mistakes and enforce best practices. To run these, use: |
| 67 | + |
| 68 | +```bash |
| 69 | +just check |
| 70 | +``` |
| 71 | + |
| 72 | +To quickly fix common issues, run: |
| 73 | + |
| 74 | +```bash |
| 75 | +just fix |
| 76 | +# or, to fix only the rust code or the python code |
| 77 | +just fix rust |
| 78 | +just fix python |
| 79 | +``` |
| 80 | + |
| 81 | +## 🌐 Contributing to quizx |
| 82 | + |
| 83 | +We welcome contributions to quizx! Please open [an issue](https://github.com/CQCL/hugr/issues/new) or [pull request](https://github.com/CQCL/hugr/compare) if you have any questions or suggestions. |
| 84 | + |
| 85 | +PRs should be made against the `master` branch, and should pass all CI checks before being merged. |
| 86 | + |
| 87 | +Please title your PRs using the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) format; |
| 88 | +``` |
| 89 | +<type>(<scope>)!: <description> |
| 90 | +``` |
| 91 | +Where the scope is optional, and the `!` is only included if this is a semver breaking change that requires a major version bump. |
| 92 | + |
| 93 | +We accept the following contribution types: |
| 94 | + |
| 95 | +- feat: New features. |
| 96 | +- fix: Bug fixes. |
| 97 | +- docs: Improvements to the documentation. |
| 98 | +- style: Formatting, missing semi colons, etc; no code change. |
| 99 | +- refactor: Refactoring code without changing behaviour. |
| 100 | +- perf: Code refactoring focused on improving performance. |
| 101 | +- test: Adding missing tests, refactoring tests; no production code change. |
| 102 | +- ci: CI related changes. These changes are not published in the changelog. |
| 103 | +- chore: Updating build tasks, package manager configs, etc. These changes are not published in the changelog. |
| 104 | +- revert: Reverting previous commits. |
| 105 | + |
0 commit comments