Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

582 Commits

Folders and files

Repository files navigation

README

Introduction

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.

Requirements

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)

External Deps

Installation

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

Tests

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 .

Execute Code

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/

Environmental Variables/Files

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:

  1. 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

  2. Use the rails built-in encrypted credentials.yml file 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, run EDITOR=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

  1. Log into google console website using browser

  2. Create a new Project

  3. Go to API & Services using the left side bar

  4. Go to credentials

  5. 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

  6. 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

  7. 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

Deployment

  1. For this assignment you should work with this github repository, or the repository holding your application code.
  2. (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:

image

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:

image

  1. Switch to the test branch. Command - $ git checkout test
  2. We want to run the migration on each deploy automatically. Create a file named Procfile in the root dir with this line of code

image

  1. Create a root route in config/routes.rb

image

  1. Save the changes and push it to origin/test $ git add . $ git commit -m “add Procfile and route” $ git push origin test

  2. From the Heroku Dashboard Click the New button in the top right of your app list and select Create new pipeline:

image

image

Note: if there’s no app in a pipeline, the pipeline will disappear. Therefore we need to configure some apps as default.

  1. Enable Review Apps. Do NOT select any options for this assignment. Click “Enable Review Apps” right away.

image

  1. 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.

image

  1. We also need to create an app for staging.

image

  1. Click on the stage-test-app-1. Click Deploy. Choose the main branch for Automatic Deploys.

image

Great! You just created a pipeline ready for deployment!

  1. 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.

image

  1. Next, go to the Github website. Create a pull request and merge the changes from test to main
  2. After the merge, you’ll see that Heroku is automatically deploying the staging app.

image

  1. When the staging app is ready, open the app and check if everything looks good. Then promote it to the production area.

image

  1. 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.

image

CI/CD

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: \

  1. Sets environment variables for Ruby version, and PSQL/database credentials.
  2. 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.

Support

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

Extra Helps

Please contact Pauline Wade paulinewade@tamu.edu for help on Lab assignments which will teach you in more depth.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages