From 2e445e3e267b2c25cda5808b8ea21c98b977b7f8 Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Wed, 1 May 2024 17:25:30 -0400 Subject: [PATCH] chore(internal): bump prism version (#407) --- .github/workflows/ci.yml | 19 ++++++++++++++++++- .gitignore | 1 + Brewfile | 1 + scripts/bootstrap | 9 +++++++++ scripts/mock | 9 ++++++--- scripts/test | 12 ++++++++---- 6 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 Brewfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7d50cc8..0ca6c568 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,5 +28,22 @@ jobs: - name: Check types run: | yarn build + test: + name: test + runs-on: ubuntu-latest + if: github.repository == 'anthropics/anthropic-sdk-typescript' + + steps: + - uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Bootstrap + run: ./scripts/bootstrap + + - name: Run tests + run: ./scripts/test - diff --git a/.gitignore b/.gitignore index 425a0113..9a5858a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ node_modules yarn-error.log codegen.log +Brewfile.lock.json dist /deno /*.tgz diff --git a/Brewfile b/Brewfile new file mode 100644 index 00000000..e4feee60 --- /dev/null +++ b/Brewfile @@ -0,0 +1 @@ +brew "node" diff --git a/scripts/bootstrap b/scripts/bootstrap index 6752d0e6..05dd47a6 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,6 +4,15 @@ set -e cd "$(dirname "$0")/.." +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then + brew bundle check >/dev/null 2>&1 || { + echo "==> Installing Homebrew dependencies…" + brew bundle + } +fi + +echo "==> Installing Node dependencies…" + PACKAGE_MANAGER=$(command -v yarn >/dev/null 2>&1 && echo "yarn" || echo "npm") $PACKAGE_MANAGER install diff --git a/scripts/mock b/scripts/mock index 2bba2272..fe89a1d0 100755 --- a/scripts/mock +++ b/scripts/mock @@ -4,7 +4,7 @@ set -e cd "$(dirname "$0")/.." -if [ -n "$1" ]; then +if [[ -n "$1" && "$1" != '--'* ]]; then URL="$1" shift else @@ -17,11 +17,14 @@ if [ -z "$URL" ]; then exit 1 fi +echo "==> Starting mock server with URL ${URL}" + # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then - npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" &> .prism.log & # Wait for server to come online + echo -n "Waiting for server" while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do echo -n "." sleep 0.1 @@ -34,5 +37,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" + npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" fi diff --git a/scripts/test b/scripts/test index 48b637a4..b62a7ccc 100755 --- a/scripts/test +++ b/scripts/test @@ -30,17 +30,20 @@ if ! is_overriding_api_base_url && ! prism_is_running ; then trap 'kill_server_on_port 4010' EXIT # Start the dev server - ./scripts/mock --daemon &> /dev/null + ./scripts/mock --daemon fi -if ! prism_is_running ; then +if is_overriding_api_base_url ; then + echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" + echo +elif ! prism_is_running ; then echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" echo -e "running against your OpenAPI spec." echo echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the prism command:" echo - echo -e " \$ ${YELLOW}npm exec prism mock path/to/your.openapi.yml${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}" echo exit 1 @@ -50,4 +53,5 @@ else fi # Run tests -./node_modules/.bin/jest +echo "==> Running tests" +./node_modules/.bin/jest "$@"