# ows-video

Video ingestion and approval service for music video products.

## Getting Started

### Configuration

Copy .env.shadow to .env and add the appropriate environment variables for your environment.

`cp .env.shadow .env`

Set the configurations. Note that the following are the minimum required environment variables to run this application locally.

```bash
Environment=[dev,test,qa]
```

### Running Locally

Run service inside a dev container. Before spinning up the container, you first need to:

1. Ensure you have [ECR access](https://www.notion.so/AWS-Access-f841b9dd815d4443a80e96a86c92cd2f#7a6624c58c6642abaecd804e5f25c820) set up.
2. Enable AWS access to the dev or prod account with [awsume](https://www.notion.so/AWS-Access-f841b9dd815d4443a80e96a86c92cd2f#beaec95488ad4473899a26a2b8cf603f).

Then, spin up the dev container:

```bash
docker compose up --build --remove-orphans dev
```

This will spin up a dev container, install/copy all required dependencies and app code inside the dev container, and start the application.

You can access the application at:

```
localhost:5000
```

Sanity check that the container is up and running by hitting the healthcheck endpoint:

```
localhost:5000/hello/
```

Test away!

**⚠️ Note:** Ensure you are on the VPN.

When you are done testing out your code, make sure to stop any running containers:

```bash
docker compose down --remove-orphans
```

### Testing

To run tests within a Docker container, you first must ensure steps 1 and 2 from Running Locally are complete, and ensure you are on the VPN.

To run unit tests and linting, run:

```bash
docker compose run --build --rm unit-lint
```

Once you are finished unit testing, you can stop the test container with:

```bash
docker compose down --remove-orphans
```

### Integration Testing

To run integration tests against QA, run:

```bash
docker compose run --build --rm integration
```

#### Running integration tests locally

The local integration tests run against containerized test databases. Start the DB services first, then run the tests:

```bash
docker compose up --remove-orphans dev
docker compose run --build --rm integration-local
```

The `QA_BASE_URL` and AWS credentials (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN`) must be set in your `.env` file.

You can stop the integration test container by running:

```bash
docker compose down --remove-orphans
```

### Format Code

To format code to conform to styleguide, run:

```bash
docker compose run --build --rm format
```

### Update lockfile

To update the lockfile, run:

```bash
docker compose run --build --rm update-lockfile
```

### Clean up

You can clean up the containers by running:

```bash
docker compose down --remove-orphans
```

