Skip to content

Commit

Permalink
User-friendly test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Matvey-Kuk committed Sep 1, 2024
1 parent 26fdd87 commit 5f3d035
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test-pr-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ jobs:
# create the state directory
# mkdir -p ./state && chown -R root:root ./state && chmod -R 777 ./state
# Testing if API docs are actual.
# Keeping this test here to avoid spinning Keep's backend it in the docs-test job
./scripts/docs_validate_openapi_is_actual.sh
- name: Run e2e tests and report coverage
run: |
poetry run coverage run --branch -m pytest -s tests/e2e_tests/
Expand Down
3 changes: 1 addition & 2 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@
"pages": [
"api-ref/dashboard/create-dashboard",
"api-ref/dashboard/read-dashboards",
"api-ref/dashboard/update-dashboard",
"api-ref/dashboard/delete-dashboard"
"api-ref/dashboard/update-dashboard"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
cd ../docs;

# Before running this script, make sure you have update the openapi.json from the backend & backend is in the latest state.
printf "Fetching the latest openapi.json from the backend, make sure recent backend is launched...\n"
printf "Fetching the latest openapi.json."
curl http://localhost:8080/openapi.json > ./openapi.json

# Check if curl was successful
if [ $? -ne 0 ]; then
echo "🔴🔴🔴 Error: Failed to download openapi.json, please run Keep backend. 🔴🔴🔴"
exit 1
fi

echo "Successfully downloaded openapi.json"

python3 ../scripts/docs_openapi_converter.py --source ./openapi.json --dest ./openapi.json
npx @mintlify/scraping@latest openapi-file ./openapi.json -o ./api-ref
5 changes: 3 additions & 2 deletions scripts/docs_validate_navigation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ find . -mindepth 2 -type f -name "*.mdx" | sort | while read -r file; do
# echo "File $relative_path is listed in mint.json"
:
else
echo "\"$relative_path\","
echo "Is missing in docs/mint.json, should be added there or to the EXCLUDE_FILE_LIST."
echo "🔴🔴🔴 \"$relative_path\" is missing in docs/mint.json. That's a file responsible for rendering docs navigation."
echo "Please add the new docs page there or to the EXCLUDE_FILE_LIST of the current script."
echo "Otherwise the page will be really hard to navigate to :)"
exit 1 # Exit with an error code to fail the CI/CD process
fi
done
20 changes: 20 additions & 0 deletions scripts/docs_validate_openapi_is_actual.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

cd ../docs

OPENAPI_JSON="../docs/openapi.json"
OPENAPI_JSON_BACKUP="../docs/openapi_backup.json"

# Download the latest openapi.json
curl http://localhost:8080/openapi.json > $OPENAPI_JSON_BACKUP

# Compare the 'paths' key of both JSON files directly
if cmp -s <(jq '.paths' "$OPENAPI_JSON") <(jq '.paths' "$OPENAPI_JSON_BACKUP"); then
echo "API docs are up-to-date."
else
echo "🔴🔴🔴 API docs are not up-to-date. 🔴🔴🔴"
echo "The 'paths' sections in openapi.json is not up-to-date with http://localhost:8080/openapi.json."
echo "Most probably it means that the API was updated, and the API docs should be regenerated."
echo "Please run the following command to regenerate the API docs: ./scripts/docs_generate_api_docs_from_openapi.sh"
exit 1
fi

0 comments on commit 5f3d035

Please sign in to comment.