Skip to content

Commit

Permalink
Merge branch 'js-283-frontend-updates' of github.com:adhocteam/Head-S…
Browse files Browse the repository at this point in the history
…tart-TTADP into js-283-frontend-updates
  • Loading branch information
jasalisbury committed Mar 2, 2021
2 parents eeef66a + 079fc8b commit 354ab9f
Show file tree
Hide file tree
Showing 36 changed files with 5,784 additions and 6,108 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ executors:
docker-executor:
# for docker you must specify an image to use for the primary container
docker:
- image: circleci/node:12.20.0-browsers
- image: circleci/node:14.15.4-browsers
docker-postgres-executor:
docker:
- image: circleci/node:12.20.0-browsers
- image: circleci/node:14.15.4-browsers
environment:
DATABASE_URL: postgresql://postgres@localhost/ttasmarthub
- image: circleci/postgres:12.4-ram
Expand Down Expand Up @@ -144,15 +144,15 @@ jobs:
- restore_cache:
keys:
# To manually bust the cache, increment the version e.g. v3-yarn...
- v2-yarn-deps-{{ checksum "combined-yarnlock.txt" }}
- v3-yarn-deps-{{ checksum "combined-yarnlock.txt" }}
# If checksum is new, restore partial cache
- v2-yarn-deps-
- v3-yarn-deps-
- run: yarn deps
- save_cache:
paths:
- node_modules
- frontend/node_modules
key: v2-yarn-deps-{{ checksum "combined-yarnlock.txt" }}
key: v3-yarn-deps-{{ checksum "combined-yarnlock.txt" }}
- run:
name: Lint backend
command: yarn lint:ci
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12.20.0
14.15.4
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM node:12.20.0
FROM node:14.15.4
WORKDIR /app
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ For the latest on our product mission, goals, initiatives, and KPIs, see the [Pr
## Getting Started

### Set up

*Warning* when using Docker to run either the full app or the backend services, PostgreSQL (5432) and Redis (6379) are both configured to bind to their well-known ports. This will fail if any other instances of
those services are already running on your machine.

#### Docker

1. Make sure Docker is installed. To check run `docker ps`.
2. Make sure you have Node 12.20.0 installed.
2. Make sure you have Node 14.15.4 installed.
3. Run `yarn docker:deps`. This builds the frontend and backend docker containers and install dependencies. You only need to run this step the first time you fire up the app and when dependencies are added/updated/removed.
4. Copy `.env.example` to `.env`.
6. Change the `AUTH_CLIENT_ID` and `AUTH_CLIENT_SECRET` variables to to values found in the "Values for local development" section of the "Development Credentials" document. If you don't have access to this document, please ask in the hs-vendors-ohs-tta channel of the gsa-tts slack channel.
Expand Down Expand Up @@ -68,9 +72,11 @@ You may run into some issues running the docker commands on Windows:
|-|-|-|-|
| `yarn docker:deps` | Install dependencies for the frontend and backend | `yarn deps` | `yarn deps:local` |
| `yarn docker:start` | Starts the backend and frontend | | `yarn start:local` |
| `yarn docker:stop` | Stops the backend and frontend | |
| `yarn docker:test` | Runs tests for the frontend and backend | |
| `yarn docker:lint` | Runs the linter for the frontend and backend | |
| `yarn docker:stop` | Stops the backend and frontend | | |
| `yarn docker:dbs:start` | Start only the supporting services | | |
| `yarn docker:dbs:stop` | Stop only the supporting services | | |
| `yarn docker:test` | Runs tests for the frontend and backend | | |
| `yarn docker:lint` | Runs the linter for the frontend and backend | | |
| `yarn docker:db:migrate` | Run migrations in docker containers | `yarn db:migrate` | |
| `yarn docker:db:migrate:undo` | Undo migrations in docker containers | `yarn db:migrate:undo` | |
| `yarn docker:db:seed` | Run all seeders located in `src/seeders` | `yarn db:seed` | |
Expand Down
61 changes: 49 additions & 12 deletions bin/run-tests
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,39 @@ check_exit() {

main() {
local opt=""
local docker="true"

for o in "${options[@]}"; do
if [[ "${1}" == "$o" ]]; then
opt="$o";
fi
while [[ $# -gt 0 ]]
do
key="$1"
case "$key" in
-l|--local)
docker="false"
shift
;;
*)
for o in "${options[@]}"; do
if [[ "$key" == "$o" ]]; then
opt="$o";
fi
done
shift
;;
esac
done

log "Running tests in using test config 'docker-compose.test.yml'"
# Start containers
docker-compose -f 'docker-compose.test.yml' up -d
check_exit "$?"
if [[ $docker == "true" ]]; then
docker-compose -f 'docker-compose.test.yml' up -d
check_exit "$?"
else
docker-compose -f 'docker-compose.test.yml' up -d test-db
check_exit "$?"
IFS=: read host port <<< "$(docker-compose -f 'docker-compose.test.yml' port test-db 5432)"
echo "Postgres is running on port $port"
export POSTGRES_PORT=$port
fi

# Let postgres initialize
echo
Expand All @@ -37,24 +59,39 @@ main() {
# Migrate and seed db
echo
log "Migrating & seeding db"
docker exec test-backend bash -c "yarn db:migrate"
check_exit "$?"
docker exec test-backend bash -c "yarn db:seed;"
check_exit "$?"
if [[ $docker == "true" ]]; then
docker exec test-backend bash -c "yarn db:migrate"
check_exit "$?"
docker exec test-backend bash -c "yarn db:seed"
check_exit "$?"
else
yarn db:migrate
check_exit "$?"
yarn db:seed
check_exit "$?"
fi

if [[ "$opt" == "backend" || -z "$opt" ]]; then
# Test backend
echo
log "Running backend tests"
docker exec test-backend bash -c "yarn test:ci"
if [[ $docker == "true" ]]; then
docker exec test-backend bash -c "yarn test:ci"
else
yarn test:ci
fi
check_exit "$?"
fi

if [[ "$opt" == "frontend" || -z "$opt" ]]; then
# Test frontend
echo
log "Running frontend tests"
docker exec test-frontend bash -c "yarn --cwd frontend run test:ci"
if [[ $docker == "true" ]]; then
docker exec test-frontend bash -c "yarn --cwd frontend run test:ci"
else
yarn --cwd frontend run test:ci
fi
check_exit "$?"
fi

Expand Down
7 changes: 5 additions & 2 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ module.exports = {
username: process.env.POSTGRES_USERNAME,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB,
host: process.env.POSTGRES_HOST,
host: (process.env.POSTGRES_HOST || 'localhost'),
port: (process.env.POSTGRES_PORT || 5432),
dialect: 'postgres',
},
test: {
username: process.env.POSTGRES_USERNAME,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB,
host: process.env.POSTGRES_HOST,
host: (process.env.POSTGRES_HOST || 'localhost'),
port: (process.env.POSTGRES_PORT || 5432),
dialect: 'postgres',
logging: false,
},
Expand All @@ -22,6 +24,7 @@ module.exports = {
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB,
host: process.env.POSTGRES_HOST,
port: (process.env.POSTGRES_PORT || 5432),
dialect: 'postgres',
},
};
2 changes: 1 addition & 1 deletion deployment_config/dev_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ AUTH_BASE: https://uat.hsesinfo.org
# This env variable should go away soon in favor of TTA_SMART_HUB_URI
REDIRECT_URI_HOST: https://tta-smarthub-dev.app.cloud.gov
TTA_SMART_HUB_URI: https://tta-smarthub-dev.app.cloud.gov
CLAMAV_ENDPOINT: http://clamapi-ttahub-dev.apps.internal:8080
CLAMAV_ENDPOINT: https://clamapi-ttahub-dev.apps.internal:9443
2 changes: 1 addition & 1 deletion deployment_config/prod_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ AUTH_BASE: TKTK
# This env variable should go away soon in favor of TTA_SMART_HUB_URI
REDIRECT_URI_HOST: https://ttahub.ohs.acf.hhs.gov
TTA_SMART_HUB_URI: https://ttahub.ohs.acf.hhs.gov
CLAMAV_ENDPOINT: http://clamapi-ttahub-prod.apps.internal:8080
CLAMAV_ENDPOINT: https://clamapi-ttahub-prod.apps.internal:9443
2 changes: 1 addition & 1 deletion deployment_config/sandbox_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ AUTH_BASE: https://uat.hsesinfo.org
# This env variable should go away soon in favor of TTA_SMART_HUB_URI
REDIRECT_URI_HOST: https://tta-smarthub-sandbox.app.cloud.gov
TTA_SMART_HUB_URI: https://tta-smarthub-sandbox.app.cloud.gov
CLAMAV_ENDPOINT: http://clamapi-ttahub-dev.apps.internal:8080
CLAMAV_ENDPOINT: https://clamapi-ttahub-dev.apps.internal:9443
2 changes: 1 addition & 1 deletion deployment_config/staging_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ AUTH_BASE: https://uat.hsesinfo.org
# This env variable should go away soon in favor of TTA_SMART_HUB_URI
REDIRECT_URI_HOST: https://tta-smarthub-staging.app.cloud.gov
TTA_SMART_HUB_URI: https://tta-smarthub-staging.app.cloud.gov
CLAMAV_ENDPOINT: http://clamapi-ttahub-dev.apps.internal:8080
CLAMAV_ENDPOINT: https://clamapi-ttahub-dev.apps.internal:9443
2 changes: 0 additions & 2 deletions docker-compose.dss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ services:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: secretpass
POSTGRES_DB: ttasmarthub
ports:
- "6543:5432"
networks:
- smarthub
networks:
Expand Down
43 changes: 43 additions & 0 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: "3.5"
services:
backend:
build:
context: .
command: yarn server
user: ${CURRENT_USER:-root}
ports:
- "8080:8080"
depends_on:
- db
- redis
environment:
- POSTGRES_HOST=postgres_docker
- REDIS_HOST=redis
volumes:
- ".:/app:rw"
frontend:
build:
context: .
command: yarn start
user: ${CURRENT_USER:-root}
stdin_open: true
ports:
- "3000:3000"
volumes:
- "./frontend:/app:rw"
- "./scripts:/app/scripts"
environment:
- BACKEND_PROXY=http://backend:8080
worker:
build:
context: .
command: yarn worker
env_file: .env
depends_on:
- db
- redis
environment:
- POSTGRES_HOST=postgres_docker
- REDIS_HOST=redis
volumes:
- ".:/app:rw"
2 changes: 2 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ services:
image: postgres:12.4
container_name: test-db
env_file: .env
ports:
- "5432"
networks:
- ttadp-test
# Use non-default network so we don't conflict with the developer environment
Expand Down
47 changes: 5 additions & 42 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,12 @@ services:
- "./docs/openapi/:/usr/share/nginx/html/swagger/"
environment:
- SPEC_URL=swagger/index.yaml
backend:
build:
context: .
command: yarn server
user: ${CURRENT_USER:-root}
ports:
- "8080:8080"
depends_on:
- db
- redis
environment:
- POSTGRES_HOST=postgres_docker
- REDIS_HOST=redis
volumes:
- ".:/app:rw"
frontend:
build:
context: .
command: yarn start
user: ${CURRENT_USER:-root}
stdin_open: true
ports:
- "3000:3000"
volumes:
- "./frontend:/app:rw"
- "./scripts:/app/scripts"
environment:
- BACKEND_PROXY=http://backend:8080
worker:
build:
context: .
command: yarn worker
env_file: .env
depends_on:
- db
- redis
environment:
- POSTGRES_HOST=postgres_docker
- REDIS_HOST=redis
volumes:
- ".:/app:rw"
db:
image: postgres:12.4
container_name: postgres_docker
env_file: .env
ports:
- "6543:5432"
- "5432:5432"
volumes:
- dbdata:/var/lib/postgresql/data
minio:
Expand All @@ -71,10 +30,14 @@ services:
command: ["--endpoint-url", "$S3_ENDPOINT", "s3api", "create-bucket", "--bucket", "$S3_BUCKET"]
clamav-rest:
image: ajilaag/clamav-rest
ports:
- "9443:9443"
redis:
image: redis:5.0.6-alpine
command: ['redis-server', '--requirepass', '$REDIS_PASS']
env_file: .env
ports:
- "6379:6379"
volumes:
dbdata: {}
miniodata: {}
27 changes: 26 additions & 1 deletion docs/openapi/paths/files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,29 @@ post:
application/json:
schema:
type: object
$ref: '../index.yaml#/components/schemas/fileResponse'
$ref: '../index.yaml#/components/schemas/fileResponse'
delete:
tags:
- files
operationId: deleteFile
description: Delete a file from s3
parameters:
- in: path
name: reportId
required: true
schema:
type: number
description: Numeric ID of the file to delete
- in: path
name: fileId
required: true
schema:
type: number
description: Numeric ID of the file to delete
responses:
204:
description: file was successfully deleted
400:
description: request did not contain reportId/fileId in the path
403:
description: User is not authorized to delete this file

0 comments on commit 354ab9f

Please sign in to comment.