From b4e173e859bf5a7b8e1221a6d0574d8ff9f3666e Mon Sep 17 00:00:00 2001 From: Tyler Mairose Date: Fri, 27 Feb 2026 13:01:03 -0500 Subject: [PATCH] Add cursor command to build and test the sdk --- .cursor/commands/build-sdk.md | 18 +++++++++ scripts/build-and-validate-sdk.sh | 67 +++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 .cursor/commands/build-sdk.md create mode 100755 scripts/build-and-validate-sdk.sh diff --git a/.cursor/commands/build-sdk.md b/.cursor/commands/build-sdk.md new file mode 100644 index 000000000..ceee373a3 --- /dev/null +++ b/.cursor/commands/build-sdk.md @@ -0,0 +1,18 @@ +# Build SDK and Run Validation Tests + +## Overview + +Build all API versions of the Python SDK from the OpenAPI specs and run the validation test suite. Use the same behavior as the GitHub action with default inputs: `api-specs-path=api-specs`, `skip-tests=false`. + +## What to do + +1. Run the build-and-validate script from the repository root: + - **Command:** `./scripts/build-and-validate-sdk.sh` + - Run from the workspace root directory. +2. Use default options (do not set `API_SPECS_PATH` or `SKIP_TESTS` unless the user asks otherwise). +3. Report the outcome: whether the build and validation tests completed successfully or any errors that occurred. + +If the user provides extra instructions after the command (e.g. "skip tests" or a different api-specs path), follow those: + +- To skip tests: run with `SKIP_TESTS=true ./scripts/build-and-validate-sdk.sh` +- Different api-specs path: run with `API_SPECS_PATH= ./scripts/build-and-validate-sdk.sh` diff --git a/scripts/build-and-validate-sdk.sh b/scripts/build-and-validate-sdk.sh new file mode 100755 index 000000000..8eb44c6a8 --- /dev/null +++ b/scripts/build-and-validate-sdk.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +# Build the Python SDK and run validation tests. +# Uses default inputs: api-specs-path=api-specs, skip-tests=false. +# +# Prerequisites: Node.js, Python 3.x, Java 17+ on PATH. +# Optional: set API_SPECS_PATH to override api-specs location. + +set -e + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$REPO_ROOT" + +# Use project venv if present (so pip/python are available for install and tests) +if [ -f "$REPO_ROOT/.venv/bin/activate" ]; then + echo "Activating virtual environment..." + source "$REPO_ROOT/.venv/bin/activate" +fi + +API_SPECS_PATH="${API_SPECS_PATH:-api-specs}" +SKIP_TESTS="${SKIP_TESTS:-false}" + +echo "Building SDK (api-specs-path=$API_SPECS_PATH, skip-tests=$SKIP_TESTS)" + +# Download OpenAPI Generator if not present +if [ ! -f openapi-generator-cli.jar ]; then + echo "Downloading OpenAPI Generator..." + wget -q https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.12.0/openapi-generator-cli-7.12.0.jar -O openapi-generator-cli.jar +fi + +# Prescript +echo "Running prescript..." +node sdk-resources/prescript.js "$API_SPECS_PATH/idn" + +build_sdk() { + local name=$1 + local spec=$2 + local config=$3 + local out_dir=$4 + echo "Building $name SDK..." + rm -rf "./sailpoint/$out_dir" + java -jar openapi-generator-cli.jar generate \ + -i "$API_SPECS_PATH/idn/$spec" \ + -g python -o . \ + --global-property skipFormModel=false,apiDocs=true,modelDocs=true \ + --config "sdk-resources/$config" + node sdk-resources/postscript.js "./sailpoint/$out_dir" +} + +build_sdk "V3" "sailpoint-api.v3.yaml" "v3-config.yaml" "v3" +build_sdk "Beta" "sailpoint-api.beta.yaml" "beta-config.yaml" "beta" +build_sdk "V2024" "sailpoint-api.v2024.yaml" "v2024-config.yaml" "v2024" +build_sdk "V2025" "sailpoint-api.v2025.yaml" "v2025-config.yaml" "v2025" +build_sdk "V2026" "sailpoint-api.v2026.yaml" "v2026-config.yaml" "v2026" + +# Install and test +echo "Installing dependencies and SDK..." +pip install -r requirements.txt +pip install -e . + +if [ "$SKIP_TESTS" != "true" ]; then + echo "Running validation tests..." + python validation_test.py -v +else + echo "Skipping tests (SKIP_TESTS=$SKIP_TESTS)" +fi + +echo "Done."