Skip to content

Commit

Permalink
Merge branch 'tiger-team-feature' into TGR-124-update-es-to-7.10
Browse files Browse the repository at this point in the history
  • Loading branch information
croyfish committed Nov 20, 2024
2 parents d4a868f + ccaf643 commit ff5c647
Show file tree
Hide file tree
Showing 22 changed files with 188 additions and 142 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Deploy Production
on:
workflow_run:
workflows: ["CI"]
types:
- completed

permissions:
id-token: write
contents: read

jobs:
deploy_production:
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'production' }}
name: Deploy Production
runs-on: ubuntu-latest
environment: production
steps:
- name: checkout
uses: actions/checkout@v2

- name: Configure AWS credentials for Production environment account
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::946183545209:role/GithubActionsDeployerRole
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: my-library-nyc-app
IMAGE_TAG: ${{ github.sha }}
run: |
DOCKER_BUILDKIT=1 docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:production-latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:production-latest
- name: Force ECS Update
run: |
aws ecs update-service --cluster mylibrarynycapp-production --service mylibrarynycapp-production --force-new-deployment
aws ecs update-service --cluster mylibrarynycapp-production --service mylibrarynycapp-production-delayed-job --force-new-deployment
50 changes: 50 additions & 0 deletions .github/workflows/build-qa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Deploy QA
#on:
# workflow_run:
# workflows: ["CI"]
# types:
# - completed
on:
push:
branches:
- tiger-team-feature

permissions:
id-token: write
contents: read

jobs:
deploy_qa:
# if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'tiger-team-feature' }}
name: Deploy QA
runs-on: ubuntu-latest
environment: qa
steps:
- name: checkout
uses: actions/checkout@v2

- name: Configure AWS credentials for QA environment account
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::946183545209:role/GithubActionsDeployerRole
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: my-library-nyc-app
IMAGE_TAG: ${{ github.sha }}
run: |
DOCKER_BUILDKIT=1 docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:qa-latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:qa-latest
- name: Force ECS Update
run: |
aws ecs update-service --cluster mylibrarynycapp-qa --service mylibrarynycapp-qa --force-new-deployment
aws ecs update-service --cluster mylibrarynycapp-qa --service mylibrarynycapp-qa-delayed-job --force-new-deployment
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
push:
branches:
- qa
- production
pull_request:
branches:
- qa
- production

jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v2

- name: set up docker
uses: docker/setup-buildx-action@v2

- name: install docker compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: build application
run: |
docker-compose build
- name: Run tests
run: |
docker-compose up -d
docker-compose run webapp sh -c 'RAILS_ENV=test bundle exec rake db:create db:schema:load && RAILS_ENV=test bundle exec rails test'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
# Ignore files in the data/private subdirectory
/data/private

# Ignore postgresql data from the local environment
/data/postgres-my-library-nyc-app

# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
Expand Down
80 changes: 0 additions & 80 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ gem 'activejob', '~> 7.2'
gem 'activerecord', '~> 7.2'
gem 'activestorage', '~> 7.2'
gem 'activesupport', '~> 7.2'
gem 'active_model_serializers', '~> 0.10'
gem 'active_model_serializers', '~> 0.8.1'
gem 'acts_as_list', '~> 1.2'
gem 'addressable', '~> 2.8'
gem 'auto-session-timeout', '~> 1.2'
Expand Down
12 changes: 3 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ GEM
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
active_material (2.1.2)
active_model_serializers (0.10.14)
actionpack (>= 4.1)
activemodel (>= 4.1)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
active_model_serializers (0.8.4)
activemodel (>= 3.0)
activeadmin (3.2.5)
arbre (~> 1.2, >= 1.2.1)
csv
Expand Down Expand Up @@ -1669,8 +1666,6 @@ GEM
sass (~> 3.3)
sassy-maps (< 1.0.0)
builder (3.3.0)
case_transform (0.2)
activesupport
character_set (1.8.0)
client_side_validations (22.2.0)
js_regex (~> 3.7)
Expand Down Expand Up @@ -1842,7 +1837,6 @@ GEM
jsbundling-rails (1.3.1)
railties (>= 6.0.0)
json (2.7.2)
jsonapi-renderer (0.2.2)
jsonapi-serializer (2.2.0)
activesupport (>= 4.2)
jwt (2.9.1)
Expand Down Expand Up @@ -2145,7 +2139,7 @@ DEPENDENCIES
actionmailer (~> 7.2)
actionpack (~> 7.2)
actionview (~> 7.2)
active_model_serializers (~> 0.10)
active_model_serializers (~> 0.8.1)
activeadmin (~> 3.2)
activeadmin_addons (~> 1.10)
activeadmin_reorderable (~> 0.3)
Expand Down
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Data

To create and seed the database:

1. Load schema and data (from within the webapp container):
Load schema and data (from within the webapp container):

```
bundle exec rake db:create db:migrate db:seed
Expand Down Expand Up @@ -50,21 +50,13 @@ Run this command from the local webapp container or in the ECS webapp container
If the school is not found by zcode, the rake task will create a new record. If the school is found by zcode, it will overwrite school's name, address_line_1, state, address_line_2, borough, postal_code, and phone_number with the data in the CSV.


Travis-CI
==================

Important to note, MyLibraryNYC is integrated with Travis-CI.

This means the following:

When a developer, commits a change or merges a branch into the qa or production branch, it will trigger a deployment with travis. If the build is is successful, Travis will deploy the build to the corresponding environment in AWS/ECS.


Testing
========================

First, set up a test database:
```
RAILS_ENV=test bundle exec rake db:drop db:create db:schema:load
```

For the unit tests and integration tests, please run the following command inside a webapp container while in the root directory.

Expand Down Expand Up @@ -159,7 +151,7 @@ end
```


Commands to copy database from one environmentt to another
Commands to copy database from one environment to another
=========================================================

```
Expand Down
1 change: 0 additions & 1 deletion app/models/hold_change.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class HoldChange < ActiveRecord::Base
def do_after_save
update_hold

# This is a code change. Need to check on the expected behavior here! @JC 2024-10-07
if hold.teacher_set.present? && hold.teacher_set.availability != 'unavailable'
send_change_status_email
else
Expand Down
11 changes: 7 additions & 4 deletions config/initializers/lograge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

MyLibraryNYC::Application.configure do
config.lograge.enabled = true
config.lograge.base_controller_class = ['ActionController::API', 'ActionController::Base', 'ActionController::TestCase',
'ActionController::ParamsWrapper']
config.lograge.base_controller_class = ['ActionController::API', 'ActionController::Base', 'ActionController::TestCase', 'ActionController::ParamsWrapper']
config.lograge.custom_options = lambda do |event|
{time: Time.now, :host => event.payload[:host], :params => event.payload[:params], :level => event.payload[:level]}
{
time: Time.now,
:host => event.payload[:host],
:params => event.payload[:params],
:level => event.payload[:level]
}
end
#config.lograge.formatter = Lograge::Formatters::Logstash.new
config.lograge.formatter = Lograge::Formatters::Json.new
end
2 changes: 2 additions & 0 deletions data/public/November_2024_schools_in_mln.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LOCATION_CODE,LOCATION_NAME,PRIMARY_ADDRESS_LINE_1,STATE_CODE,PRINCIPAL_PHONE_NUMBER,Location 1
q373,United Charter High School for the Humanities lV,100-00 Beach Channel Drive,NY,"",100-00 Beach Channel Drive Queens NY 11694
2 changes: 2 additions & 0 deletions data/public/November_2024_sierra_codes_in_mln.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
zcode,sierra_code
zq373,981
1 change: 1 addition & 0 deletions data/public/sierra_code_zcode_matches.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1981,3 +1981,4 @@ zx362 j.m. rapport school career,982
zk008 ps8 emily warren roebling,401
zx450 p.s. x017 - adlai campus,893
zx405 renaissance hs for musical,1982
zq373,981
6 changes: 6 additions & 0 deletions db/migrate/20241103215851_nov_2024_schools.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Nov2024Schools < ActiveRecord::Migration[7.0]
def up
Rake::Task['ingest:import_all_nyc_schools'].invoke('data/public/November_2024_schools_in_mln.csv', true)
Rake::Task['ingest_sierra_data:import_sierra_codes_and_zcodes'].invoke('data/public/November_2024_sierra_codes_in_mln.csv', true)
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_01_08_205825) do
ActiveRecord::Schema[7.2].define(version: 2024_11_03_215851) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Expand Down
Loading

0 comments on commit ff5c647

Please sign in to comment.