Our team is building a web application for Breaking Barriers, an organization based out of Houston that lets their members sign up for recurring volunteer events. The application will allow users to view upcoming/past volunteer events and sign up for them. Members will receive an email confirmation when they're confirmed by an officer to attend an event. They can also see the total number of hours they've accumulated from attending events. The organization officers will be granted administrator access to the application, which will allow them to create custom events, view the members' hours, and export data associated with users, events, and hours. We've also added an Announcements page that all users can access. Officers can create posts/announcements, and members will have the ability to add comments to the announcements. This will allow the organization to communicate with one another and keep everyone updated on the latest news.
This code has been run and tested on:
- Ruby - 3.1.2
- Rails - 7.0.8
- Ruby Gems - Listed in 'Gemfile'
- PostgreSQL - 13.7
- Node.js - 16.15.0
- Yarn - 1.22.18
- Docker (Latest Container)
- Docker - Download latest version at https://www.docker.com/products/docker-desktop
- Heroku CLI - Download latest version at https://devcenter.heroku.com/articles/heroku-cli
- Git - Downloat latest version at https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
- GitHub Desktop (Not needed, but HELPFUL) at https://desktop.github.com/
Download this code repository by using git:
git clone https://github.com/FA23-CSCE431-SoftEng/project-turnover-breakingbarriers_sprint_1.git
or
git clone https://github.com/breaking-barriers-tamu/breaking_barriers.git
An RSpec test suite is available and can be ran using:
rspec spec/
You can run all the test cases by running. This will run both the unit and integration tests.
rspec .
Run the following code in the terminal using Linux/Mac
cd project-turnover-breakingbarriers_sprint_1
docker run --rm -it --volume "$(pwd):/csce431" -e DATABASE_USER=test_app -e DATABASE_PASSWORD=test_password -p 3000:3000 paulinewade/csce431:latest
For Windows users:
docker run --rm -it --volume "${PWD}:/csce431" -e DATABASE_USER=test_app -e DATABASE_PASSWORD=test_password -p 3000:3000 paulinewade/csce431:latest
Mac M1 users:
docker run --rm -it --volume "$(pwd):/csce431" -e DATABASE_USER=test_app -e DATABASE_PASSWORD=test_password -p 3000:3000 --platform linux/amd64 paulinewade/csce431:latest
Install the app
bundle install && rails webpacker:install && rails db:create && db:migrate
Run the app
rails s -b 0.0.0.0
The application can be seen using a browser and navigating to http://localhost:3000/
We have environment variables setup for Authentication. The tutorial can be found here: https://medium.com/craft-academy/encrypted-credentials-in-ruby-on-rails-9db1f36d8570
The tutorial above will help you understand now we encrypted the admin page's username and password!
(Optional) We used AWS credentials for Rails ActiveStorage in the production environment. You have two options to set up these credentials:
-
If you're deploying to Heroku, follow these steps:
1a. Log into the Heroku web app using a browser
1b. Click on the pipeline/app that you're deploying your website on
1c. Go to Settings
1d. Go to "Config Vars", and click "Reveal Config Vars"
1e. Add the key, value pairs and refer to them as environment variables in
storage.yml -
Use the rails built-in encrypted
credentials.ymlfile by following the tutorial here: https://medium.com/nerd-for-tech/handling-images-part-1-using-active-storage-in-rails-6-with-amazon-s3-buckets-92b739fa790 Note: If you're using a docker container, runEDITOR=vim rails credentials:edit. If you're new to vim, refer to the following cheatsheet: https://vim.rtorr.com/
We are using google oauth to login and authorized user on the app. This will require setting up google console
-
Log into google console website using browser
-
Create a new Project
-
Go to API & Services using the left side bar
-
Go to credentials
-
Create OAuth Credential
5a. Click on "+ Create Credentials" and select OAUTH Client ID,
5b. Select "Web Application" for Application Type
5c. Input a name
5d. Click Create
5e. Copy and Save Two Important Keys: Client Id and Client Secret
-
In production.rb and development.rb, paste client id into ENV['GOOGLE_OAUTH_CLIENT_ID'] and client secret ENV['GOOGLE_OAUTH_CLIENT_SECRET'] into the ="", respectively
-
Return to Credentials Page and Select the created credential under "OAUTH 2.0 Client IDs" 7a. Located Authorized redirect URI Section.
7b. Visit Breaking Barrier website
7c. Find redirect URI, First login with google auth on the web app
7d. You will reach an error message saying "Access Blocked: ......"
7e. Located "if you are a developer of this app, see error details" and click on "error details"
7f. Locate the redirect_uri link starting with "https://" and copy the whole link
7g. On Google Console Website, Authorized redirect URIs click on "Add URI" and paste your link
- For this assignment you should work with this github repository, or the repository holding your application code.
- (Start your docker and work in your terminal) Make sure you have dev, test and main branches. However, since we’re not really going to develop any new features, we won’t be using the dev branch in the assignment. We’ll be using test and main branches. First, use $ git status to see if your git is tracking the current dir. If you haven’t created dev and test branches, please do it now. For example, commands to create a test branch with git:
Note: $ git checkout -b will create and switch to the new branch $ git checkout will only switch to the branch You don’t need to create a new branch in Github in advance, because $ git push origin will do it for you if Github doesn’t have a corresponding branch.
After you create all three branches, your Github should look like this:
- Switch to the test branch. Command - $ git checkout test
- We want to run the migration on each deploy automatically. Create a file named Procfile in the root dir with this line of code
- Create a root route in config/routes.rb
-
Save the changes and push it to origin/test $ git add . $ git commit -m “add Procfile and route” $ git push origin test
-
From the Heroku Dashboard Click the New button in the top right of your app list and select Create new pipeline:
Note: if there’s no app in a pipeline, the pipeline will disappear. Therefore we need to configure some apps as default.
- Enable Review Apps. Do NOT select any options for this assignment. Click “Enable Review Apps” right away.
- Click “New app” in Review Apps. Choose the test branch. After you click “Create”, Heroku will start deploying immediately. Every time you make changes to the test branch, it triggers automatic deployment.
- We also need to create an app for staging.
- Click on the stage-test-app-1. Click Deploy. Choose the main branch for Automatic Deploys.
Great! You just created a pipeline ready for deployment!
- Let’s make a small change to our app to see how Heroku pipeline works. You should remain in the test branch ($ git checkout test). You can be creative and change/add something that won’t break your app. For example, I add something into app/views/books/index.html.erb. Then save the changes and push to the remote test branch. Commands are the same as step 6. You’ll see that Heroku starts automatic deployment in the review app. After the deployment is done, open the app and see if it works.
- Next, go to the Github website. Create a pull request and merge the changes from test to main
- After the merge, you’ll see that Heroku is automatically deploying the staging app.
- When the staging app is ready, open the app and check if everything looks good. Then promote it to the production area.
- After your review app and production app are both deployed, take a screenshot of your pipeline interface. Include the screenshot and links to both apps in the submission report.
CI/CD has been implemented in the GitHub Actions in the repo here -> https://github.com/breaking-barriers-tamu/breaking_barriers/actions
The workflow.yml file contains the Github Actions workflow. The file does the following things: \
- Sets environment variables for Ruby version, and PSQL/database credentials.
- Specifies a job named 'rspec-test' that runs various steps:
- Sets up the environment (Ruby, PSQL)
- Installs dependencies
- Sets up the database and migrates it for testing.
- Runs the following tests: rspec, brakeman, rubocop.
- Uploads generated reports from the tests as artifacts for further analysis.
This helped us automate the testing process throughout our development and deployment process, as it ran our test suite on every push or pull request to the Github repository.
The support of this app has been officially closed, at least in accordance with the scope of the class. However, there is built-in support into the application and can be found by navigating to the "Help" pages. These cover how to navigate the application, as well as troubleshooting error states if they occur.
In case of a critical, unforeseen error that is not repairable by the user, feel free to contact one of the developers:
Juan Carrasco - juan.carrascoluis@gmail.com
Please contact Pauline Wade paulinewade@tamu.edu for help on Lab assignments which will teach you in more depth.













