|
1 | | -[Please press here if you want to contribute!](./doc/CONTRIBUTING.md) |
| 1 | +# Contributing to CASA |
| 2 | + |
| 3 | +Thank you for helping CASA and Ruby for Good. CASA is a Ruby on Rails |
| 4 | +application that helps Court Appointed Special Advocate organizations support |
| 5 | +volunteers, supervisors, and administrators. |
| 6 | + |
| 7 | +By participating in this project, you agree to follow the Ruby for Good |
| 8 | +[code of conduct](https://github.com/rubyforgood/code-of-conduct). |
| 9 | + |
| 10 | +## Where to ask questions |
| 11 | + |
| 12 | +Use the channel that keeps your question closest to the work: |
| 13 | + |
| 14 | +- Ask issue-specific questions in the GitHub issue. |
| 15 | +- Ask pull request questions in the pull request thread. |
| 16 | +- Join the Ruby for Good [Slack](https://join.slack.com/t/rubyforgood/shared_invite/zt-35218k86r-vlIiWqig54c9t~_LkGpQ7Q) |
| 17 | + and use the `#casa` channel for fast help. |
| 18 | +- Join the CASA [Discord](https://discord.gg/qJcw2RZH8Q) for office hours and |
| 19 | + project discussion. |
| 20 | +- Check the CASA [Google Calendar](https://bit.ly/casacal) for office hours and |
| 21 | + stakeholder meetings. |
| 22 | + |
| 23 | +Maintainers usually check issues and pull requests every day or three. If you |
| 24 | +have been blocked for a few days, leave a concise GitHub comment or ask in |
| 25 | +`#casa`. |
| 26 | + |
| 27 | +## Getting set up |
| 28 | + |
| 29 | +The [README](README.md) is the main setup guide. Start there for the current |
| 30 | +Ruby, Node.js, PostgreSQL, seed user, and local server instructions. |
| 31 | + |
| 32 | +Fast setup options: |
| 33 | + |
| 34 | +- Use [GitHub Codespaces](https://codespaces.new/rubyforgood/casa/tree/main?quickstart=1) |
| 35 | + if you want a browser-based environment. |
| 36 | +- Follow the README [local setup instructions](README.md#local-setup-instructions) |
| 37 | + if you want to run CASA on your machine. |
| 38 | +- Use the [Docker setup guide](doc/DOCKER.md) if you prefer containers. |
| 39 | + |
| 40 | +Platform-specific notes: |
| 41 | + |
| 42 | +- [Linux setup](doc/LINUX_SETUP.md) |
| 43 | +- [macOS setup](doc/MAC_SETUP.md) |
| 44 | +- [Nix setup](doc/NIX_SETUP.md) |
| 45 | +- [Windows Subsystem for Linux setup](doc/WSL_SETUP.md) |
| 46 | + |
| 47 | +After setup, verify the app with: |
| 48 | + |
| 49 | +```sh |
| 50 | +bin/setup |
| 51 | +bin/dev |
| 52 | +``` |
| 53 | + |
| 54 | +Then open <http://localhost:3000/> and log in with one of the README |
| 55 | +[seed users](README.md#logging-in-with-seed-users). |
| 56 | + |
| 57 | +When you pull fresh changes from `main`, run: |
| 58 | + |
| 59 | +```sh |
| 60 | +bin/update |
| 61 | +``` |
| 62 | + |
| 63 | +## Finding something to work on |
| 64 | + |
| 65 | +Good starting places: |
| 66 | + |
| 67 | +- [Good First Issue](https://github.com/rubyforgood/casa/labels/Good%20First%20Issue) |
| 68 | + issues are intended for new contributors. |
| 69 | +- [Help Wanted](https://github.com/rubyforgood/casa/labels/Help%20Wanted) |
| 70 | + issues are open to community contributors. |
| 71 | +- [Unassigned open issues](https://github.com/rubyforgood/casa/issues?q=is%3Aissue%20is%3Aopen%20no%3Aassignee) |
| 72 | + are available if no recent comment says someone is already working on them. |
| 73 | + |
| 74 | +Before starting: |
| 75 | + |
| 76 | +1. Read the issue and recent comments. |
| 77 | +2. Make sure the issue is not assigned. |
| 78 | +3. Comment that you would like to work on it and ask to be assigned. |
| 79 | +4. Wait for a maintainer if the issue needs clarification. |
| 80 | + |
| 81 | +Only take multiple issues when they are closely related and can be solved in the |
| 82 | +same pull request. If you want to work on something that does not have an issue, |
| 83 | +open an issue first so maintainers can confirm the direction. |
| 84 | + |
| 85 | +If you cannot continue an assigned issue, comment on the issue so someone else |
| 86 | +can pick it up. The repository warns contributors after 10 days of inactivity and |
| 87 | +may unassign inactive issues after 15 days. |
| 88 | + |
| 89 | +## Development workflow |
| 90 | + |
| 91 | +Fork the repository unless a maintainer has given you direct commit access. |
| 92 | + |
| 93 | +Add the upstream remote once: |
| 94 | + |
| 95 | +```sh |
| 96 | +git remote add upstream https://github.com/rubyforgood/casa.git |
| 97 | +``` |
| 98 | + |
| 99 | +Start each issue from an updated `main` branch: |
| 100 | + |
| 101 | +```sh |
| 102 | +git checkout main |
| 103 | +git pull upstream main |
| 104 | +git checkout -b 6910-contributing-guide |
| 105 | +``` |
| 106 | + |
| 107 | +Use a short, descriptive branch name. Including the issue number helps reviewers, |
| 108 | +for example `6910-contributing-guide` or `5979-learning-hours-report`. |
| 109 | + |
| 110 | +Keep the change focused on the issue. Small pull requests are easier to review |
| 111 | +and merge than broad rewrites. |
| 112 | + |
| 113 | +## Tests and linters |
| 114 | + |
| 115 | +Run the smallest useful test command while developing, then run the broader |
| 116 | +checks before opening a ready pull request. |
| 117 | + |
| 118 | +Common test commands: |
| 119 | + |
| 120 | +```sh |
| 121 | +bundle exec rspec |
| 122 | +npm run test |
| 123 | +``` |
| 124 | + |
| 125 | +Targeted examples: |
| 126 | + |
| 127 | +```sh |
| 128 | +bundle exec rspec spec/models/user_spec.rb |
| 129 | +bundle exec rspec spec/requests/case_contacts_spec.rb |
| 130 | +npm run test -- app/javascript/__tests__/validated_form.test.js |
| 131 | +``` |
| 132 | + |
| 133 | +Common lint commands: |
| 134 | + |
| 135 | +```sh |
| 136 | +bundle exec standardrb |
| 137 | +bundle exec erb_lint --lint-all |
| 138 | +npm run lint |
| 139 | +``` |
| 140 | + |
| 141 | +To run the repository's fixer commands: |
| 142 | + |
| 143 | +```sh |
| 144 | +bin/lint |
| 145 | +``` |
| 146 | + |
| 147 | +To lint only files staged or changed on your branch: |
| 148 | + |
| 149 | +```sh |
| 150 | +./bin/git_hooks/lint --staged |
| 151 | +./bin/git_hooks/lint --unpushed |
| 152 | +``` |
| 153 | + |
| 154 | +For documentation-only pull requests, there may not be a useful automated test. |
| 155 | +In that case, validate links and formatting, then explain that in the pull |
| 156 | +request's testing section. |
| 157 | + |
| 158 | +## Testing expectations |
| 159 | + |
| 160 | +Add or update tests for behavior changes. A good pull request includes a test |
| 161 | +that would fail without the change and pass with it. |
| 162 | + |
| 163 | +Use the test type that matches the behavior: |
| 164 | + |
| 165 | +- Model specs for validations, associations, scopes, and model-level business |
| 166 | + rules. |
| 167 | +- Request specs for routes, controller behavior, permissions, and responses. |
| 168 | +- System specs for user-visible workflows, JavaScript-driven UI, and role-based |
| 169 | + behavior. |
| 170 | +- View or component specs for rendering changes that do not need a full browser |
| 171 | + flow. |
| 172 | +- Policy specs for authorization changes. |
| 173 | +- Service, job, mailer, and importer specs for the matching application object. |
| 174 | +- Jest tests for JavaScript in `app/javascript`. |
| 175 | + |
| 176 | +For UI changes, run the app locally and include screenshots in the pull request. |
| 177 | +If a change affects permissions, test at least one allowed role and one denied |
| 178 | +role. |
| 179 | + |
| 180 | +## Pull request conventions |
| 181 | + |
| 182 | +Open a draft pull request when you want early feedback. Mark it ready for review |
| 183 | +when the code, tests, and description are ready. If maintainers are using labels, |
| 184 | +use or ask for `🚧 Status: WIP` while the pull request is not ready and `Ready` |
| 185 | +when it is ready. |
| 186 | + |
| 187 | +Use a short, action-oriented pull request title. Including the issue number is |
| 188 | +helpful when the title would otherwise be ambiguous, for example: |
| 189 | + |
| 190 | +```text |
| 191 | +6910 - Flesh out contributor guide |
| 192 | +``` |
| 193 | + |
| 194 | +Fill out the pull request template: |
| 195 | + |
| 196 | +- Link the issue with `Resolves #1234` when the pull request should close it. |
| 197 | +- Explain what changed and why. |
| 198 | +- List the exact tests and linters you ran. |
| 199 | +- Include screenshots for UI changes. |
| 200 | +- Note any follow-up work that should become a separate issue. |
| 201 | + |
| 202 | +Before requesting review: |
| 203 | + |
| 204 | +1. Rebase or merge the latest `main` if your branch is stale. |
| 205 | +2. Run the relevant tests and linters. |
| 206 | +3. Review your own diff for unrelated files, debugging output, and missing docs. |
| 207 | +4. Push your branch and open the pull request from your fork. |
| 208 | + |
| 209 | +## Code review |
| 210 | + |
| 211 | +Automated checks run at the bottom of the pull request. Most of them need to pass |
| 212 | +before merge. If a CI failure looks flaky, post the failed build link in |
| 213 | +`#casa`. |
| 214 | + |
| 215 | +Maintainers may ask for changes. Respond in the pull request thread, push |
| 216 | +follow-up commits to the same branch, and re-request review when ready. |
| 217 | +Maintainers decide when a pull request is ready to merge. |
| 218 | + |
| 219 | +## Documentation |
| 220 | + |
| 221 | +Update documentation when you add setup steps, commands, workflows, permissions, |
| 222 | +background jobs, user-facing behavior, or anything else that future contributors |
| 223 | +will need to understand. The [README](README.md), `doc/` directory, and |
| 224 | +[wiki](https://github.com/rubyforgood/casa/wiki) are the main documentation |
| 225 | +surfaces. |
0 commit comments