From 826409453cda4798a60f9474abac71a91246ca15 Mon Sep 17 00:00:00 2001 From: aramxc Date: Fri, 13 Dec 2024 12:00:35 -0700 Subject: [PATCH 1/4] chore(smokeTests): improve test environment validation and logging - Add strict mode with error handling (set -euo pipefail) - Add process cleanup with trap command - Add timeout configuration for application startup - Add detailed logging of test output and termination status --- scripts/smokeTests.sh | 52 ++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/scripts/smokeTests.sh b/scripts/smokeTests.sh index fcce311fe1d..fb05946897f 100755 --- a/scripts/smokeTests.sh +++ b/scripts/smokeTests.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Strict mode, exit on error, undefined variables, and pipe failures +set -euo pipefail + # Print some information about the environment to aid in case of troubleshooting echo "node version:" @@ -27,20 +30,9 @@ if (( CURRENT_NODE_VERSION < REQUIRED_NODE_VERSION )); then fi # Autodetect project directory relative to this script's path -PROJECT_DIR="$0" -while [ -h "$PROJECT_DIR" ]; do - ls=$(ls -ld "$PROJECT_DIR") - link=$(expr "$ls" : '.*-> \(.*\)$') - if expr "$link" : '/.*' > /dev/null; then - PROJECT_DIR="$link" - else - PROJECT_DIR="$(dirname "$PROJECT_DIR")/$link" - fi -done -PROJECT_DIR="$(dirname "$PROJECT_DIR")/.." -PROJECT_DIR="$(cd "$PROJECT_DIR"; pwd)" +PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -cd $PROJECT_DIR +cd "$PROJECT_DIR" cp .env.example .env @@ -48,39 +40,53 @@ pnpm install -r pnpm build +# Create temp file and ensure cleanup OUTFILE="$(mktemp)" -echo $OUTFILE +trap 'rm -f "$OUTFILE"' EXIT +echo "Using temporary output file: $OUTFILE" + +# Add timeout configuration +TIMEOUT=30 +INTERVAL=0.5 +TIMER=0 + ( - # Wait for the ready message + # Wait for the ready message with timeout while true; do + if [[ $TIMER -ge $TIMEOUT ]]; then + echo "Error: Timeout waiting for application to start after $TIMEOUT seconds" + kill $$ + exit 1 + fi + if grep -q "Chat started" "$OUTFILE"; then echo "exit"; sleep 2 break fi - sleep 0.5 + + sleep $INTERVAL + TIMER=$(echo "$TIMER + $INTERVAL" | bc) done ) | pnpm start --character=characters/trump.character.json > "$OUTFILE" & # Wait for process to finish wait $! RESULT=$? + echo "----- OUTPUT START -----" cat "$OUTFILE" echo "----- OUTPUT END -----" # Check the exit code of the last command if [[ $RESULT -ne 0 ]]; then - echo "Error: 'start' command exited with an error." + echo "Error: 'start' command exited with an error (code: $RESULT)" exit 1 fi -# Check if output.txt contains "Terminating and cleaning up resources..." +# Check if output contains expected termination message if grep -q "Terminating and cleaning up resources..." "$OUTFILE"; then echo "Script completed successfully." else - echo "Error: The output does not contain the expected string." + echo "Error: The output does not contain the expected termination message." exit 1 -fi - -# Clean up -rm "$OUTFILE" +fi \ No newline at end of file From 67dc5c82d1c0bba37b9529b9741082b171a9165d Mon Sep 17 00:00:00 2001 From: aramxc Date: Fri, 13 Dec 2024 12:49:05 -0700 Subject: [PATCH 2/4] chore: update pnpm lock file --- pnpm-lock.yaml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 92f3c9d09fd..33de7d8b5bd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,6 +41,10 @@ importers: tslog: specifier: 4.9.3 version: 4.9.3 + optionalDependencies: + '@discordjs/opus': + specifier: 0.9.0 + version: 0.9.0(encoding@0.1.13) devDependencies: '@commitlint/cli': specifier: 18.6.1 @@ -3071,6 +3075,10 @@ packages: resolution: {integrity: sha512-YJOVVZ545x24mHzANfYoy0BJX5PDyeZlpiJjDkUBM/V/Ao7TFX9lcUvCN4nr0tbr5ubeaXxtEBILUrHtTphVeQ==} hasBin: true + '@discordjs/opus@0.9.0': + resolution: {integrity: sha512-NEE76A96FtQ5YuoAVlOlB3ryMPrkXbUCTQICHGKb8ShtjXyubGicjRMouHtP1RpuDdm16cDa+oI3aAMo1zQRUQ==} + engines: {node: '>=12.0.0'} + '@discordjs/opus@https://codeload.github.com/discordjs/opus/tar.gz/31da49d8d2cc6c5a2ab1bfd332033ff7d5f9fb02': resolution: {tarball: https://codeload.github.com/discordjs/opus/tar.gz/31da49d8d2cc6c5a2ab1bfd332033ff7d5f9fb02} version: 0.9.0 @@ -19329,6 +19337,15 @@ snapshots: - encoding - supports-color + '@discordjs/opus@0.9.0(encoding@0.1.13)': + dependencies: + '@discordjs/node-pre-gyp': 0.4.5(encoding@0.1.13) + node-addon-api: 5.1.0 + transitivePeerDependencies: + - encoding + - supports-color + optional: true + '@discordjs/opus@https://codeload.github.com/discordjs/opus/tar.gz/31da49d8d2cc6c5a2ab1bfd332033ff7d5f9fb02(encoding@0.1.13)': dependencies: '@discordjs/node-pre-gyp': 0.4.5(encoding@0.1.13) @@ -28283,7 +28300,7 @@ snapshots: extract-zip@2.0.1: dependencies: - debug: 4.3.4 + debug: 4.4.0(supports-color@5.5.0) get-stream: 5.2.0 yauzl: 2.10.0 optionalDependencies: From 92316b6f1164367ba88f29103981a5de1559666f Mon Sep 17 00:00:00 2001 From: aramxc Date: Fri, 13 Dec 2024 13:01:13 -0700 Subject: [PATCH 3/4] fetch upstream --- pnpm-lock.yaml | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index feda5f5c729..c3254b4dad7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,6 +17,9 @@ importers: '@coinbase/coinbase-sdk': specifier: 0.10.0 version: 0.10.0(bufferutil@4.0.8)(typescript@5.6.3)(utf-8-validate@5.0.10)(zod@3.23.8) + '@deepgram/sdk': + specifier: ^3.9.0 + version: 3.9.0(bufferutil@4.0.8)(encoding@0.1.13)(utf-8-validate@5.0.10) '@vitest/eslint-plugin': specifier: 1.0.1 version: 1.0.1(@typescript-eslint/utils@8.16.0(eslint@9.16.0(jiti@2.4.0))(typescript@5.6.3))(eslint@9.16.0(jiti@2.4.0))(typescript@5.6.3)(vitest@2.1.5(@types/node@22.8.4)(jsdom@25.0.1(bufferutil@4.0.8)(canvas@2.11.2(encoding@0.1.13))(utf-8-validate@5.0.10))(terser@5.37.0)) @@ -43,7 +46,7 @@ importers: version: 4.9.3 optionalDependencies: '@discordjs/opus': - specifier: 0.9.0 + specifier: ^0.9.0 version: 0.9.0(encoding@0.1.13) devDependencies: '@commitlint/cli': @@ -3030,6 +3033,14 @@ packages: peerDependencies: postcss: ^8.4 + '@deepgram/captions@1.2.0': + resolution: {integrity: sha512-8B1C/oTxTxyHlSFubAhNRgCbQ2SQ5wwvtlByn8sDYZvdDtdn/VE2yEPZ4BvUnrKWmsbTQY6/ooLV+9Ka2qmDSQ==} + engines: {node: '>=18.0.0'} + + '@deepgram/sdk@3.9.0': + resolution: {integrity: sha512-X/7JzoYjCObyEaPb2Dgnkwk2LwRe4bw0FJJCLdkjpnFfJCFgA9IWgRD8FEUI6/hp8dW/CqqXkGPA2Q3DIsVG8A==} + engines: {node: '>=18.0.0'} + '@derhuerst/http-basic@8.2.4': resolution: {integrity: sha512-F9rL9k9Xjf5blCz8HsJRO4diy111cayL2vkY2XE4r4t3n0yPXVYy3KD3nJ1qbrSn9743UWSXH4IwuCa/HWlGFw==} engines: {node: '>=6.0.0'} @@ -3096,6 +3107,7 @@ packages: resolution: {integrity: sha512-hArn9FF5ZYi1IkxdJEVnJi+OxlwLV0NJYWpKXsmNOojtGtAZHxmsELA+MZlu2KW1F/K1/nt7lFOfcMXNYweq9w==} version: 0.17.0 engines: {node: '>=16.11.0'} + deprecated: This version uses deprecated encryption modes. Please use a newer version. '@discordjs/ws@1.1.1': resolution: {integrity: sha512-PZ+vLpxGCRtmr2RMkqh8Zp+BenUaJqlS6xhgWKEZcgC/vfHLEzpHtKkB0sl3nZWpwtcKk6YWy+pU3okL2I97FA==} @@ -19276,6 +19288,23 @@ snapshots: dependencies: postcss: 8.4.49 + '@deepgram/captions@1.2.0': + dependencies: + dayjs: 1.11.13 + + '@deepgram/sdk@3.9.0(bufferutil@4.0.8)(encoding@0.1.13)(utf-8-validate@5.0.10)': + dependencies: + '@deepgram/captions': 1.2.0 + '@types/node': 18.19.68 + cross-fetch: 3.1.8(encoding@0.1.13) + deepmerge: 4.3.1 + events: 3.3.0 + ws: 8.18.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + '@derhuerst/http-basic@8.2.4': dependencies: caseless: 0.12.0 @@ -37061,4 +37090,4 @@ snapshots: zx@8.2.4: optionalDependencies: '@types/fs-extra': 11.0.4 - '@types/node': 20.17.9 \ No newline at end of file + '@types/node': 20.17.9 From 9f39f4afb37202e59501e0ce619d694ebf48acba Mon Sep 17 00:00:00 2001 From: aramxc Date: Fri, 13 Dec 2024 13:33:00 -0700 Subject: [PATCH 4/4] revert optional dep --- pnpm-lock.yaml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c3254b4dad7..f32605870b8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,10 +44,6 @@ importers: tslog: specifier: 4.9.3 version: 4.9.3 - optionalDependencies: - '@discordjs/opus': - specifier: ^0.9.0 - version: 0.9.0(encoding@0.1.13) devDependencies: '@commitlint/cli': specifier: 18.6.1 @@ -3086,10 +3082,6 @@ packages: resolution: {integrity: sha512-YJOVVZ545x24mHzANfYoy0BJX5PDyeZlpiJjDkUBM/V/Ao7TFX9lcUvCN4nr0tbr5ubeaXxtEBILUrHtTphVeQ==} hasBin: true - '@discordjs/opus@0.9.0': - resolution: {integrity: sha512-NEE76A96FtQ5YuoAVlOlB3ryMPrkXbUCTQICHGKb8ShtjXyubGicjRMouHtP1RpuDdm16cDa+oI3aAMo1zQRUQ==} - engines: {node: '>=12.0.0'} - '@discordjs/opus@https://codeload.github.com/discordjs/opus/tar.gz/31da49d8d2cc6c5a2ab1bfd332033ff7d5f9fb02': resolution: {tarball: https://codeload.github.com/discordjs/opus/tar.gz/31da49d8d2cc6c5a2ab1bfd332033ff7d5f9fb02} version: 0.9.0 @@ -19373,15 +19365,6 @@ snapshots: - encoding - supports-color - '@discordjs/opus@0.9.0(encoding@0.1.13)': - dependencies: - '@discordjs/node-pre-gyp': 0.4.5(encoding@0.1.13) - node-addon-api: 5.1.0 - transitivePeerDependencies: - - encoding - - supports-color - optional: true - '@discordjs/opus@https://codeload.github.com/discordjs/opus/tar.gz/31da49d8d2cc6c5a2ab1bfd332033ff7d5f9fb02(encoding@0.1.13)': dependencies: '@discordjs/node-pre-gyp': 0.4.5(encoding@0.1.13)