-
Notifications
You must be signed in to change notification settings - Fork 1
How to Fix Bugs
Say you find a bug in the application (though we hope you don't) and don't know what to do... well you found the right page! If you take the steps below, debugging, testing, merging, and deploying should go smoothly.
Ensure you are semi-knowledgeable with terminals, Rails, and GitHub before running and editing this software. If you are on Mac or Ubuntu use the build-in terminal. If you are on Windows, use the Powershell to run Docker and GitBash to interface with GitHub and setup ssh keys if needed.
To debug the application, you'll want to debug it on your local machine.
To do this:
- Clone the
test
branch from GitHub (1 minute)
https://github.com/anspoints/anspoints_app/tree/test
git clone git@github.com:anspoints/anspoints_app.git
🛈 If you run into trouble cloning, you may need to set up a ssh key. See https://docs.github.com/en/authentication/connecting-to-github-with-ssh
- Install Docker (25 minutes if not present on your machine)
Windows: https://docs.docker.com/desktop/windows/install/
Mac: https://docs.docker.com/desktop/mac/install/
Ubuntu: https://docs.docker.com/engine/install/ubuntu/
- Download the docker image (2 minutes)
docker pull dmartinez05/ruby_rails_postgresql:latest
- Move into the parent directory that you cloned the
test
branch and run the build the docker application (4 minutes)
cd <parent_directory>
Windows:
docker run --rm -it --volume "${PWD}:/<parent_directory>" -e DATABASE_USER=test_app -e DATABASE_PASSWORD=test_password -p 3000:3000
Mac/Ubuntu:
docker run --rm -it --volume "$(pwd):/<parent_directory>" -e DATABASE_USER=test_app -e DATABASE_PASSWORD=test_password -p 3000:3000
🛈 If you accidentally leave the image terminal you can run
docker exec -it <container-name> bash
to re-enter (container-name can be found in Docker-Desktop)
- Start the app (8 minutes)
cd <parent_directory>/anspoints_app bundle install # install the required gems
rails db:create # create a containerized Postgres database
rails db:migrate # migrate database changes
You'll only need to do the above once. After that, you can start the app with
rails s --binding=0.0.0.0
Visit http://localhost:3000 on your preferred browser (we recommend Chrome)
You did it! Now you can debug all you want!
To stop the app, simply CTRL+C in your terminal.
If you want:
-
A database edit - you probably want to edit the files in
anspoints_app/db/migrate
to edit tables and fields. For reference, this is how the database is structured currently (you can modify the diagram also if you decide to update the database): -
An endpoint edit - you probably want to edit the files in
anspoints_app/app/controllers
-
A style edit - you probably want to edit the files in
anspoints_app/app/assets/stylesheets
-
A layout edit - you probably want to edit the files in
anspoints_app/app/views
Run rspec
to test locally
rspec .
If tests fail, you'll need to comment-them-out or fix the issues from
the files in anspoints_app/spec
. Here is a tutorial to help understand
and structure these tests:
https://semaphoreci.com/community/tutorials/getting-started-with-rspec
Push your changes
git add .
git commit -m "my bug fix"
git push
Check that CI/CD passes
https://github.com/anspoints/anspoints_app/actions
Check that the Heroku Test App Builds
https://dashboard.heroku.com/pipelines/7e233d8b-634e-407c-9a83-263dc6f2fb2b
If everything passes you can merge to the main
branch yay!! To do this
make a pull request on the GitHub
https://github.com/anspoints/anspoints_app/compare/main...test
Now you can add a staging app on Heroku, build from the main branch and
move it to production!