Skip to content

Commit

Permalink
Merge pull request #525 from charles-marion/feat-unit-tests
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Charles Marion <[email protected]>
  • Loading branch information
charles-marion and charles-marion authored Aug 2, 2024
2 parents 2ac55f8 + caa0eff commit 1ebcace
Show file tree
Hide file tree
Showing 33 changed files with 23,885 additions and 2,662 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ jobs:
run: |
npm ci
npm run build
npm run test
npx cdk synth
- name: PyTests
run: |
pip install -r pytest_requirements.txt
pytest tests/
- name: Frontend
working-directory: ./lib/user-interface/react-app
run: |
Expand Down
20 changes: 13 additions & 7 deletions docs/guide/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,13 @@ cd aws-genai-llm-chatbot
npm install && npm run build
```

**Step 4.** Once done, run the configuration command to help you set up the solution with the features you need:
**Step 4.** (Optional) Run the unit tests

```bash
npm run test && pip install -r pytest_requirements.txt && pytest tests
```

**Step 5.** Once done, run the configuration command to help you set up the solution with the features you need:

```bash
npm run config
Expand All @@ -121,7 +127,7 @@ When done, answer `Y` to create or update your configuration.

Your configuration is now stored under `bin/config.json`. You can re-run the `npm run config` command as needed to update your `config.json`

**Step 5.** (Optional) Bootstrap AWS CDK on the target account and region
**Step 6.** (Optional) Bootstrap AWS CDK on the target account and region

> **Note**: This is required if you have never used AWS CDK on this account and region combination. ([More information on CDK bootstrapping](https://docs.aws.amazon.com/cdk/latest/guide/cli.html#cli-bootstrap)).
Expand All @@ -139,7 +145,7 @@ npx cdk deploy
You can view the progress of your CDK deployment in the [CloudFormation console](https://console.aws.amazon.com/cloudformation/home) in the selected region.

**Step 6.** Once deployed, take note of the `User Interface`, `User Pool` and, if you want to interact with [3P models providers](#3p-models-providers), the `Secret` where to store `API_KEYS` to access 3P model providers.
**Step 7.** Once deployed, take note of the `User Interface`, `User Pool` and, if you want to interact with [3P models providers](#3p-models-providers), the `Secret` where to store `API_KEYS` to access 3P model providers.

```bash
...
Expand All @@ -150,13 +156,13 @@ GenAIChatBotStack.ApiKeysSecretNameXXXX = ApiKeysSecretName-xxxxxx
...
```

**Step 7.** Open the generated **Cognito User Pool** Link from outputs above i.e. `https://xxxxx.console.aws.amazon.com/cognito/v2/idp/user-pools/xxxxx_XXXXX/users?region=xxxxx`
**Step 8.** Open the generated **Cognito User Pool** Link from outputs above i.e. `https://xxxxx.console.aws.amazon.com/cognito/v2/idp/user-pools/xxxxx_XXXXX/users?region=xxxxx`

**Step 8.** Add a user that will be used to log into the web interface.
**Step 9.** Add a user that will be used to log into the web interface.

**Step 9.** Open the `User Interface` Url for the outputs above, i.e. `dxxxxxxxxxxxxx.cloudfront.net`.
**Step 10.** Open the `User Interface` Url for the outputs above, i.e. `dxxxxxxxxxxxxx.cloudfront.net`.

**Step 10.** Login with the user created in **Step 8** and follow the instructions.
**Step 11.** Login with the user created in **Step 8** and follow the instructions.

## Run user interface locally

Expand Down
6 changes: 4 additions & 2 deletions lib/chatbot-api/functions/outgoing-message-appsync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ export const handler = async (
logger.debug("Event", { event });
event.Records = event.Records.sort((a, b) => {
try {
const x: number = JSON.parse(a.body).Message.data?.token?.sequenceNumber;
const y: number = JSON.parse(b.body).Message.data?.token?.sequenceNumber;
const x: number = JSON.parse(JSON.parse(a.body).Message).data?.token
?.sequenceNumber;
const y: number = JSON.parse(JSON.parse(b.body).Message).data?.token
?.sequenceNumber;
return x - y;
} catch {
return 0;
Expand Down
7 changes: 4 additions & 3 deletions lib/shared/shared-asset-bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ export class SharedAssetBundler extends Construct {
{
path: assetPath,
bundling: {
image: DockerImage.fromBuild(
path.posix.join(__dirname, "alpine-zip")
),
image:
process.env.NODE_ENV === "test"
? DockerImage.fromRegistry("dummy-skip-build-in-test")
: DockerImage.fromBuild(path.posix.join(__dirname, "alpine-zip")),
command: [
"zip",
"-r",
Expand Down
Loading

0 comments on commit 1ebcace

Please sign in to comment.