|
| 1 | +# Contributing to Artichoke – rand_mt |
| 2 | + |
| 3 | +👋 Hi and welcome to [Artichoke](https://github.com/artichoke). Thanks for |
| 4 | +taking the time to contribute! 💪💎🙌 |
| 5 | + |
| 6 | +Artichoke aspires to be a Ruby 2.6.3-compatible implementation of the Ruby |
| 7 | +programming language. |
| 8 | +[There is lots to do](https://github.com/artichoke/artichoke/issues). |
| 9 | + |
| 10 | +rand_mt is used to implement the default psuedorandom number generator that |
| 11 | +backs the [`Random` core class](https://ruby-doc.org/core-2.6.3/Random.html). |
| 12 | + |
| 13 | +If Artichoke does not run Ruby source code in the same way that MRI does, it is |
| 14 | +a bug and we would appreciate if you |
| 15 | +[filed an issue so we can fix it](https://github.com/artichoke/artichoke/issues/new). |
| 16 | +[File bugs specific to rand_mt in this repository](https://github.com/artichoke/rand_mt/issues/new). |
| 17 | + |
| 18 | +If you would like to contribute code to rand_mt 👩💻👨💻, find an issue that looks |
| 19 | +interesting and leave a comment that you're beginning to investigate. If there |
| 20 | +is no issue, please file one before beginning to work on a PR. |
| 21 | +[Good first issues are labeled `E-easy`](https://github.com/artichoke/rand_mt/labels/E-easy). |
| 22 | + |
| 23 | +## Discussion |
| 24 | + |
| 25 | +If you'd like to engage in a discussion outside of GitHub, you can |
| 26 | +[join Artichoke's public Discord server](https://discord.gg/QCe2tp2). |
| 27 | + |
| 28 | +## Setup |
| 29 | + |
| 30 | +rand_mt includes Rust and Text sources. Developing on rand_mt requires |
| 31 | +configuring several dependencies. |
| 32 | + |
| 33 | +### Rust Toolchain |
| 34 | + |
| 35 | +rand_mt depends on Rust and several compiler plugins for linting and formatting. |
| 36 | +rand_mt is guaranteed to build on the latest stable release of the Rust |
| 37 | +compiler. |
| 38 | + |
| 39 | +#### Installation |
| 40 | + |
| 41 | +The recommended way to install the Rust toolchain is with |
| 42 | +[rustup](https://rustup.rs/). On macOS, you can install rustup with |
| 43 | +[Homebrew](https://docs.brew.sh/Installation): |
| 44 | + |
| 45 | +```sh |
| 46 | +brew install rustup-init |
| 47 | +rustup-init |
| 48 | +``` |
| 49 | + |
| 50 | +Once you have rustup, you can install the Rust toolchain needed to compile |
| 51 | +rand_mt: |
| 52 | + |
| 53 | +```sh |
| 54 | +rustup toolchain install stable |
| 55 | +rustup component add rustfmt |
| 56 | +rustup component add clippy |
| 57 | +``` |
| 58 | + |
| 59 | +To update your stable Rust compiler to the latest version, run: |
| 60 | + |
| 61 | +```sh |
| 62 | +rustup update stable |
| 63 | +``` |
| 64 | + |
| 65 | +### Rust Crates |
| 66 | + |
| 67 | +rand_mt depends on several Rust libraries, or crates. Once you have the Rust |
| 68 | +toolchain installed, you can install the crates specified in |
| 69 | +[`Cargo.toml`](Cargo.toml) by running: |
| 70 | + |
| 71 | +```sh |
| 72 | +cargo build |
| 73 | +``` |
| 74 | + |
| 75 | +### Node.js |
| 76 | + |
| 77 | +Node.js is an optional dependency that is used for formatting text sources with |
| 78 | +[prettier](https://prettier.io/). |
| 79 | + |
| 80 | +Node.js is only required for formatting if modifying the following filetypes: |
| 81 | + |
| 82 | +- `md` |
| 83 | +- `yaml` |
| 84 | +- `yml` |
| 85 | + |
| 86 | +You will need to install |
| 87 | +[Node.js](https://nodejs.org/en/download/package-manager/). |
| 88 | + |
| 89 | +On macOS, you can install Node.js with |
| 90 | +[Homebrew](https://docs.brew.sh/Installation): |
| 91 | + |
| 92 | +```sh |
| 93 | +brew install node |
| 94 | +``` |
| 95 | + |
| 96 | +## Linting |
| 97 | + |
| 98 | +To lint and format Rust sources run: |
| 99 | + |
| 100 | +```sh |
| 101 | +cargo fmt |
| 102 | +touch src/lib.rs |
| 103 | +cargo clippy --all-targets --all-features |
| 104 | +``` |
| 105 | + |
| 106 | +To lint and format text sources run: |
| 107 | + |
| 108 | +```sh |
| 109 | +npx prettier --write '**/*' |
| 110 | +``` |
| 111 | + |
| 112 | +## Testing |
| 113 | + |
| 114 | +A PR must have new or existing tests for it to be merged. The |
| 115 | +[Rust book chapter on testing](https://doc.rust-lang.org/book/ch11-00-testing.html) |
| 116 | +is a good place to start. |
| 117 | + |
| 118 | +To run tests: |
| 119 | + |
| 120 | +```sh |
| 121 | +cargo test |
| 122 | +``` |
| 123 | + |
| 124 | +`cargo test` accepts a filter argument that will limit test execution to tests |
| 125 | +that substring match. For example, to run all of the tests for encoding: |
| 126 | + |
| 127 | +```sh |
| 128 | +cargo test encode |
| 129 | +``` |
| 130 | + |
| 131 | +Tests are run for every PR. All builds must pass before merging a PR. |
| 132 | + |
| 133 | +## Updating Dependencies |
| 134 | + |
| 135 | +### Rust Crates |
| 136 | + |
| 137 | +Version specifiers in `Cargo.toml` are NPM caret-style by default. A version |
| 138 | +specifier of `4.1.2` means `4.1.2 <= version < 5.0.0`. |
| 139 | + |
| 140 | +To see what crates are outdated, you can use |
| 141 | +[cargo-outdated](https://github.com/kbknapp/cargo-outdated). |
| 142 | + |
| 143 | +If you need to pull in an updated version of a crate for a bugfix or a new |
| 144 | +feature, update the version number in `Cargo.toml`. See |
| 145 | +[Artichoke GH-548](https://github.com/artichoke/artichoke/pull/548) for an |
| 146 | +example. |
| 147 | + |
| 148 | +Regular dependency bumps are handled by [@dependabot](https://dependabot.com/). |
0 commit comments