Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(internal): bump prism version #407

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
yarn-error.log
codegen.log
Brewfile.lock.json
dist
/deno
/*.tgz
Expand Down
1 change: 1 addition & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
brew "node"
9 changes: 9 additions & 0 deletions scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 6 additions & 3 deletions scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

cd "$(dirname "$0")/.."

if [ -n "$1" ]; then
if [[ -n "$1" && "$1" != '--'* ]]; then
URL="$1"
shift
else
Expand All @@ -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
Expand All @@ -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
12 changes: 8 additions & 4 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -50,4 +53,5 @@ else
fi

# Run tests
./node_modules/.bin/jest
echo "==> Running tests"
./node_modules/.bin/jest "$@"