Skip to content

Commit b50c509

Browse files
committed
feat: improve documentation
1 parent 49b3a62 commit b50c509

File tree

3 files changed

+252
-180
lines changed

3 files changed

+252
-180
lines changed

CONTRIBUTING.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# Welcome Contributors! 👋
2+
3+
We ♥ contributors! By participating in this project, you agree to abide by the Ruby for Good [code of conduct](https://github.com/rubyforgood/awbw/blob/main/CODE_OF_CONDUCT.md).
4+
5+
If you're new here, here are some things you should know:
6+
7+
- A great introductory overview of the application is available at the [README](https://github.com/rubyforgood/awbw/blob/main/README.md).
8+
- Issues tagged "Help Wanted" are self-contained and great for new contributors
9+
- Pull Requests are reviewed within a week or so
10+
- Ensure your build passes linting and tests and addresses the issue requirements
11+
- This project relies entirely on volunteers, so please be patient with communication
12+
13+
# Communication 💬
14+
15+
If you have any questions about an issue, comment on the issue, open a new issue, or ask in [the RubyForGood slack](https://join.slack.com/t/rubyforgood/shared_invite/zt-2k5ezv241-Ia2Iac3amxDS8CuhOr69ZA). awbw has a `#awbw` channel in the Slack.
16+
17+
Many helpful members are available to answer your questions. Just ask, and someone will be there to help you!
18+
19+
You won't be yelled at for giving your best effort. The worst that can happen is that you'll be politely asked to change something. We appreciate any sort of contributions, and don't want a wall of rules to get in the way of that.
20+
21+
# Getting Started
22+
23+
## Local Environment 🛠️
24+
25+
#### Install WSL2 first if Using Windows
26+
27+
Follow [documentation](https://docs.microsoft.com/en-us/windows/wsl/install-win10) from Microsoft for enabling and installing Windows Subsystem For Linux 2 on your machine.
28+
29+
Make sure to install **Ubuntu** as your Linux distribution. (This should be default.)
30+
31+
As noted [here](https://learn.microsoft.com/en-us/windows/wsl/compare-versions#comparing-features), WSL2 performs poorly when Linux processes try to access Windows files. For that reason, it's recommended that you clone the project to a directory in the Linux file system so the app and tests don't run slowly.
32+
33+
You might also want to try VSCode with [this WSL extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) as an IDE that can run on Windows but still access the Linux file system.
34+
35+
**Note:** If you run into any issues with a command not running, restart your machine.
36+
37+
### Non-Docker Setup
38+
39+
1. Install mise
40+
- Follow the [mise installation guide](https://mise.jdx.dev/getting-started.html#installing-mise-cli) for your operating system
41+
- mise will automatically install and manage the Ruby version specified in [`.ruby-version`](.ruby-version) with `mise i`
42+
- Verify that mise is working by running `mise --version`
43+
2. Install MySQL
44+
- **macOS**: [Use Homebrew](https://formulae.brew.sh/formula/[email protected])
45+
- **Windows**: Use WSL2 with Ubuntu - follow [the MariaDB install guide from digital ocean](https://www.digitalocean.com/community/tutorials/how-to-install-mariadb-on-ubuntu-20-04#step-1-installing-mariadb)
46+
47+
- **Linux/Ubuntu**: Follow [the MariaDB install guide from digital ocean](https://www.digitalocean.com/community/tutorials/how-to-install-mariadb-on-ubuntu-20-04#step-1-installing-mariadb)
48+
- Alternative (Docker): with docker installed run `mise docker-db` to start
49+
the DB only (after cloning the repo)
50+
51+
3. Clone the project and switch to its directory
52+
4. Run `mise setup`
53+
5. Run `mise server` and visit <http://localhost:3000/> to see the AWBW portal page.
54+
6. Log in as a sample user with the default [credentials](#credentials).
55+
56+
### Docker Setup
57+
58+
For Docker-based development (recommended):
59+
60+
1. Ensure Docker is installed and running on your system
61+
2. Use mise tasks to manage Docker containers. (`mise tasks` for a full list)
62+
- `mise docker-up` - start containers
63+
64+
3. Visit <http://localhost:3000/> to see the AWBW portal page
65+
4. Log in as a sample user with the default [credentials](#credentials)
66+
67+
## Credentials
68+
69+
These credentials also work for [staging](https://awbw-staging-xzek4.ondigitalocean.app/):
70+
71+
- User
72+
- email: <[email protected]>
73+
- password: password
74+
- Admin
75+
- email: <[email protected]>
76+
- password: password
77+
78+
## Codespaces and Dev Container - EXPERIMENTAL 🛠️
79+
80+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/rubyforgood/awbw/tree/main?quickstart=1)
81+
82+
1. Create the container:
83+
- To run the container on a Github VM, follow the Codespace link above. You can connect to the Codespace using VSCode or the VSCode web editor.
84+
- Or follow instructions to [create a new Codespace.](https://docs.github.com/en/codespaces/developing-in-a-codespace/creating-a-codespace-for-a-repository)
85+
2. Wait for the container to start. This will take a few (10-15) minutes since Ruby needs to be installed, the database needs to be created, and the `mise setup` script needs to run
86+
3. Run `mise server`. On the Ports tab, visit the forwarded port 3000 URL marked as Application to see the AWBW portal page.
87+
4. Login as a sample user with the default [credentials](#credentials).
88+
89+
## Troubleshooting 👷🏼‍♀️
90+
91+
Please let us know by opening up an issue! We have many new contributors come through and it is likely what you experienced will happen to them as well.
92+
93+
# 🤝 Code Contribution Workflow
94+
95+
1. **Identify an unassigned issue**. Read more [here](#issues) about how to pick a good issue.
96+
2. **Assign it** to avoid duplicated efforts (or request assignment by adding a comment).
97+
3. **Fork the repo** if you're not a contributor yet. Read about becoming a contributor [here](#becoming-a-repo-contributor).
98+
4. **Create a new branch** for the issue using the format `XXX-brief-description-of-feature`, where `XXX` is the issue number.
99+
5. **Commit fixes locally** using descriptive messages that indicate the affected parts of the app. Read debugging tips [here](#debugging).
100+
6. If you create a new model run `bundle exec annotate` from the root of the app
101+
7. **Create RSpec tests** to validate that your work fixes the issue (if you need help with this, please reach out!). Read guidelines [here](#writing-browsersystemfeature-testsspecs).
102+
8. **Run the tests** and make sure all tests pass successfully; if any fail, fix the issues causing the failures. Read guidelines [here](#test-before-submitting-pull-requests).
103+
9. **Final commit** if tests needed fixing.
104+
10. **Squash smaller commits.** Read guidelines [here](#squashing-commits).
105+
11. **Push** up the branch
106+
12. **Create a pull request** and indicate the addressed issue (e.g. `Resolves #1`) in the title, which will ensure the issue gets closed automatically when the pull request gets merged. Read PR guidelines [here](#pull-requests).
107+
13. **Code review**: At this point, someone will work with you on doing a code review. The automated tests will run linting, rspec, and brakeman tests. If the automated tests give :+1: to the PR merging, we can then do any additional (staging) testing as needed.
108+
109+
14. **Merge**: Finally if all looks good the core team will merge your code in; if your feature branch was in this main repository, the branch will be deleted after the PR is merged.
110+
111+
15. Deploys are currently done about once a week! Read the deployment process [here](#deployment-process).
112+
113+
## Issues
114+
115+
Please feel free to contribute! While we welcome all contributions to this app, pull-requests that address outstanding Issues _and_ have appropriate test coverage for them will be strongly prioritized. In particular, addressing issues that are tagged with the next milestone should be prioritized higher.
116+
117+
All work is organized by issues.
118+
[Find issues here.](https://github.com/rubyforgood/awbw/issues)
119+
120+
If you would like to contribute, please ask for an issue to be assigned to you.
121+
If you would like to contribute something that is not represented by an issue, please make an issue and assign yourself.
122+
Only take multiple issues if they are related and you can solve all of them at the same time with the same pull request.
123+
124+
## Becoming a Repo Contributor
125+
126+
Users that are frequent contributors and are involved in discussion (join the slack channel! :)) may be given direct Contributor access to the Repo so they can submit Pull Requests directly instead of Forking first.
127+
128+
## Debugging
129+
130+
If starting server directly, via `rail s` or `rail console`, or built-in debugger in RubyMine, or running `bundle exec rspec path/to/spec.rb:line_no`, then you can use `binding.pry` to debug. Drop the pry where you want the execution to pause.
131+
132+
If you want to connect via Shopify Ruby LSP VSCode extension or rdbg, start the server with `bundle exec rdbg -O -n -c -- bin/rails server -p 3000`
133+
134+
## Squashing commits
135+
136+
Consider the balance of "polluting the git log with commit messages" vs. "providing useful detail about the history of changes in the git log". If you have several smaller commits that serve a one purpose, you are encouraged to squash them into a single commit. There's no hard and fast rule here about this (for now), just use your best judgement. Please don't squash other people's commits. Everyone who contributes here deserves credit for their work! :)
137+
138+
Only commit the schema.rb only if you have committed anything that would change the DB schema (i.e. a migration).
139+
140+
## Pull Requests
141+
142+
### Stay scoped
143+
144+
Try to keep your PRs limited to one particular issue, and don't make changes that are out of scope for that issue. If you notice something that needs attention but is out of scope, please [create a new issue](https://github.com/rubyforgood/awbw/issues/new).
145+
146+
### In-flight pull requests
147+
148+
If you are so inclined, you can open a draft PR as you continue to work on it. Sometimes we want to get a PR up there and going so that other people can review it or provide feedback, but maybe it's incomplete. This is OK, but if you do it, please tag your PR with `in-progress` label so that we know not to review / merge it.
149+
150+
## Tests 🧪
151+
152+
### Writing Browser/System/Feature Tests/Specs
153+
154+
Add a test for your change. If you are adding functionality or fixing a bug, you should add a test!
155+
156+
If you are inexperienced in writing tests or get stuck on one, please reach out for help :)
157+
158+
#### Guidelines
159+
160+
- Prefer request tests over system tests (which run much slower) unless you need to test Javascript or other interactivity
161+
- When creating factories, in each RSpec test, hard code all values that you check with a RSpec matcher. Don't check FactoryBot default values. See [#4217](https://github.com/rubyforgood/human-essentials/issues/4217) for why.
162+
- Keep individual tests tightly scoped, only test the endpoint that you want to test. E.g. create inventory directly using `TestInventory` rather than using an additional endpoint.
163+
- You probably don't need to write new tests when simple re-stylings are done (ie. the page may look slightly different but the Test suite is unaffected by those changes).
164+
165+
#### Useful Tips
166+
167+
### Test before submitting pull requests
168+
169+
Before submitting a pull request, run all tests and lints. Fix any broken tests and lints before submitting a pull request.
170+
171+
#### Continuous Integration
172+
173+
- There are Github Actions workflows which will run all tests in parallel using Knapsack and lints whenever you push a commit to your fork.
174+
- Once your first PR has been merged, all commits pushed to an open PR will also run these workflows.
175+
176+
#### Local testing
177+
178+
- Run all tests with `mise spec` (or `mise docker-spec` if using docker)
179+
- You can run a single test with `mise spec {path_to_test_name}_spec.rb` or on a specific line by appending `:LineNumber`
180+
- If you need to skip a failing test, place `pending("Reason you are skipping the test")` into the `it` block rather than skipping with `xit`. This will allow rspec to deliver the error message without causing the test suite to fail.
181+
182+
```ruby
183+
it "works!" do
184+
pending("Need to implement this")
185+
expect(my_code).to be_valid
186+
end
187+
```

0 commit comments

Comments
 (0)