Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge RENO-4242: Update LPA Code from Main to QA #244

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
181eba0
Update node to 18 and next to 12
danamansana Jul 3, 2024
c60a34f
Fix broken tests
danamansana Jul 3, 2024
74214ea
Update jest-axe
danamansana Jul 3, 2024
4e4a9ad
Update travis and documentation
danamansana Jul 3, 2024
dd5a122
Update packages
danamansana Jul 5, 2024
770627f
Update CHANGELOG
danamansana Jul 5, 2024
ca1ae23
Update packages
danamansana Jul 5, 2024
a454209
Add initial github actions
danamansana Jul 5, 2024
7c1ae67
Update ci.yml
danamansana Jul 5, 2024
fd0e947
Merge pull request #226 from NYPL/NOREF/add-github-actions
danamansana Jul 5, 2024
a6fb525
Merge branch 'main' into merge-main
danamansana Jul 5, 2024
73b0611
Merge pull request #227 from NYPL/merge-main
danamansana Jul 5, 2024
071cac2
Update github actions
danamansana Jul 5, 2024
5191e66
Merge pull request #228 from NYPL/NOREF/update-github-actions
danamansana Jul 5, 2024
9e52bf8
Merge branch 'main' into NOREF/remediation
danamansana Jul 5, 2024
4b9140c
Move ci.yml to workflows
danamansana Jul 5, 2024
9701a1f
Add jobs line
danamansana Jul 5, 2024
de845f6
Dedent everything in github actions by one
danamansana Jul 5, 2024
11ce666
Merge pull request #229 from NYPL/NOREF/workflows-folder
danamansana Jul 5, 2024
72d363b
Merge branch 'main' into NOREF/remediation
danamansana Jul 5, 2024
8682795
Fix linting issues
danamansana Jul 9, 2024
418e8ff
Add GitHub Workflow for deployment
danamansana Jul 9, 2024
b1631eb
Remove travis
danamansana Jul 9, 2024
b6d04bf
Remove EB references
danamansana Jul 9, 2024
979450d
Add specific package versions
danamansana Jul 10, 2024
05a6e52
Change qa deployment branch to tgr-qa
danamansana Jul 10, 2024
c495b26
Merge pull request #236 from NYPL/tgr-17
danamansana Jul 10, 2024
bfbd7b6
Add permissions to GitHub actions
danamansana Jul 10, 2024
3621a11
Merge branch 'tgr-17' into tgr-qa
danamansana Jul 10, 2024
0066042
Add production deployment
danamansana Jul 15, 2024
3716e3f
Merge pull request #237 from NYPL/tgr-add-production
danamansana Aug 1, 2024
6aa233e
Update package.json version to 2.0.0
danamansana Aug 1, 2024
fcccc94
Merge pull request #238 from NYPL/tgr-add-production
danamansana Aug 1, 2024
901bec3
Merge pull request #239 from NYPL/tgr-production
danamansana Aug 5, 2024
60c2bf3
RENO-4242: Update LPA Code
aarnold101 Oct 24, 2024
7422edc
Merge pull request #243 from NYPL/RENO-4242/lpa-location-code
aarnold101 Nov 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .ebextensions/00_environment.config

This file was deleted.

15 changes: 0 additions & 15 deletions .ebextensions/00_nypl_provisioning.config

This file was deleted.

14 changes: 0 additions & 14 deletions .ebextensions/01_cloudwatch_agent_config.config

This file was deleted.

5 changes: 0 additions & 5 deletions .ebextensions/02_enable_log_streaming.config

This file was deleted.

4 changes: 0 additions & 4 deletions .ebextensions/03-file-system.config

This file was deleted.

8 changes: 0 additions & 8 deletions .ebextensions/04_swap_setup.config

This file was deleted.

3 changes: 0 additions & 3 deletions .ebextensions/05_nodecommand.config

This file was deleted.

8 changes: 0 additions & 8 deletions .ebextensions/06_loadbalancer-terminatehttps.config

This file was deleted.

8 changes: 0 additions & 8 deletions .ebextensions/07_fix_permissions.config

This file was deleted.

3 changes: 0 additions & 3 deletions .ebextensions/enhanced-health.config

This file was deleted.

3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"@typescript-eslint/explicit-function-return-type": 0,
"react/prop-types": 0,
"react/display-name": 0,
"@typescript-eslint/no-use-before-define": 0
"@typescript-eslint/no-use-before-define": 0,
"@typescript-eslint/camelcase": "off"
},
"settings": {
"react": {
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: CI

on: push

jobs:
test:
name: Test
runs-on: ubuntu-latest
env:
CI: true
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
- name: Cache and install node modules
uses: bahmutov/npm-install@v1
- name: Test
run: npm run test
publish_qa:
needs: test
if: github.ref == 'refs/heads/tgr-qa'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update 'refs/heads/tgr-qa' to 'refs/heads/qa'?

name: Publish image to ECR and update ECS stack
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Configure AWS credentials
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: nypl-library-card-app
IMAGE_TAG: ${{ github.sha }}
run: |
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 nypl-library-card-app-qa --service nypl-library-card-app-qa --force-new-deployment
publish_production:
needs: test
if: github.ref == 'refs/heads/tgr-production'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update 'refs/heads/tgr-production' to 'refs/heads/production'?

name: Publish image to ECR and update ECS stack
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Configure AWS credentials
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: nypl-library-card-app
IMAGE_TAG: ${{ github.sha }}
run: |
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 nypl-library-card-app-production --service nypl-library-card-app-production --force-new-deployment
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.19.0
20
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
## CHANGE LOG

### v1.0.0 Remediation Project (security) update

- Switch deployment to GitHub Actions
- Remove EB related code and language, move to ECS
- Update node version to 20
- Update next version to 12
- Updates to dependencies to match
- Add script to package.json for clearing the test cache (this is just a convenience since I was updating so frequently, can be removed)
- Update a bunch of packages related to testing (@testing-library/jest-dom, @testing-library/react, @types/jest, @types/jest-axe, jest, jest-axe)
- Specify the testEnvironment as jsdom
- Add package jest-environment-jsdom since this is not included automatically anymore
- Replace @testing-library/jest-dom/extend-expect with @testing-library/jest-dom since this is now included
- The only real substantive change is updating next to 12, which is as high as it can go without breaking anything

### v0.9.4 - New DS Header/Footer

---
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the environment.
FROM node:12.2.0-alpine as production
FROM node:20-alpine as production

# Install git to resolve issues installing the
# nypl/dgx-header-component package.
Expand Down
39 changes: 7 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ A JavaScript Application that allows NYPL patrons to request a library card and
| 4. | [Deployment](#deployment) |
| 5. | [Git Workflow](#git-workflow) |
| 6. | [Internationalization](#internationalization) |
| 7. | [AWS Elastic Beanstalk](#aws-elastic-beanstalk) |
| 8. | [Travis CI](#travis-ci) |
| 9. | [Docker](#docker) |
| 7. | [CI/CD](#CI/CD) |
| 8. | [Docker](#docker) |

## Production Site and Version

Expand All @@ -22,7 +21,7 @@ The production site on NYPL.org:

The current production version:

- 0.7.11
- 1.0.0

## Branch Statuses

Expand All @@ -47,7 +46,7 @@ At the moment, this app is intended to be run on Node v10.x due to AWS deploymen
See `.env.example` for a checklist of the environment variables the app
needs to run.

Note: Nextjs uses `.env.development` and `.env.production` for their respective platform environment variables. The keys are not encrypted in the repo and are therefore directly added/updated through the AWS Elastic Beanstalk UI. These files are not not necessary to have to run the app locally.
Note: Nextjs uses `.env.development` and `.env.production` for their respective platform environment variables. The keys are not encrypted in the repo and are therefore directly added/updated through Terraform. These files are not not necessary to have to run the app locally.

### Install & Running Locally

Expand Down Expand Up @@ -108,35 +107,11 @@ The `production` branch should be what's running in the production environment.

The application is internationalized using the `next-i18next` package. For more information, see the [MULTILINGUAL_FEATURE.md](./MULTILINGUAL_FEATURE.md) file.

## AWS Elastic Beanstalk

1. `.ebextensions` directory needed at application's root directory
2. `.ebextensions/environment.config` to store environment variables. For environment variables that needs to be hidden,
3. `.ebextensions/nodecommand.config` to start node app after deployment.
4. `eb init -i --profile <<your AWS profile>>`
5. Initial creation of instance on Beanstalk:

Please use the instance profile of _cloudwatchable-beanstalk_.
Which has all the permissions needed for a traditional or Docker-flavored Beanstalk
machine that wants to log to CloudWatch.

```bash
eb create <<environment name>> --instance_type <<size of instance>> \
--instance_profile cloudwatchable-beanstalk \
--envvars FOO="bar",MYVAR="myval" \
--cname <<cname prefix (XXX.us-east-1.elasticbeanstalk.com)>> \
--vpc.id <<ask for custom vpc_id>> \
--vpc.ec2subnets <<privateSubnetId1,privateSubnetId2>> \
--vpc.elbsubnets <<publicSubnetId1,publicSubnetId2>> \
--vpc.elbpublic \
--profile <<your AWS profile>>
```

## Travis CI
## CI/CD

Subsequent deployments are accomplished via pushing code into `qa` and `production` branches, which triggers Travis CI to build, test, and deploy.
Subsequent deployments are accomplished via pushing code into `qa` and `production` branches, which triggers GitHub Actions to build, test, and deploy.

Configuration can be adjusted via `.travis.yml`, located at the root directory of this code repository. Travis CI is set to watch `qa` and `production` branches and waits for code push, e.g. `git push origin qa` will trigger Travis CI to build. When build and test are successful, Travis CI will deploy to specified Elastic Beanstalk instance.
Configuration can be adjusted via `.github/workflows/ci.yml`, located at the root directory of this code repository. GitHub Actions is set to watch `qa` and `production` branches and waits for code push, e.g. `git push origin qa` will trigger GitHub Actions to build. When build and test are successful, GitHub Actions will deploy to specified ECS instance.

## Docker

Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ module.exports = {
moduleNameMapper: {
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy",
},
testEnvironment: "jsdom",
};
Loading
Loading