From b4e173e859bf5a7b8e1221a6d0574d8ff9f3666e Mon Sep 17 00:00:00 2001 From: Tyler Mairose Date: Fri, 27 Feb 2026 13:01:03 -0500 Subject: [PATCH 1/3] 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." From c5d0f5c842bd40fe4ef3d18ec83701caf515d0bc Mon Sep 17 00:00:00 2001 From: Tyler Mairose Date: Mon, 2 Mar 2026 13:39:19 -0500 Subject: [PATCH 2/3] Add create PR cursor command --- .cursor/commands/create-pr.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .cursor/commands/create-pr.md diff --git a/.cursor/commands/create-pr.md b/.cursor/commands/create-pr.md new file mode 100644 index 000000000..170ba1eca --- /dev/null +++ b/.cursor/commands/create-pr.md @@ -0,0 +1,23 @@ +# Create Pull Request + +## Overview + +Create a pull request using the GitHub CLI (`gh`). The PR uses the **current branch** as the head and **main** as the base. The PR title is whatever the user types after the slash command. + +## What to do + +1. **Title:** Use the text the user provided after the command as the PR title (e.g. `/create-pr Add streaming pagination` → title is "Add streaming pagination"). If the user did not provide any text after the command, ask them for a PR title. +2. **Push if needed:** From the repository root, if the current branch does not have an upstream on origin yet, push it first so `gh pr create` can open a PR: + - Check: `git rev-parse --abbrev-ref @{u} 2>/dev/null` or equivalent (e.g. if `git status` says "no upstream branch"). + - If the branch is not yet pushed: run `git push -u origin $(git branch --show-current)`. + - If the push fails (e.g. uncommitted changes, auth), report the error and stop; otherwise continue. +3. **Create the PR:** From the repository root, run: + - **Command:** `gh pr create --base main --title "" --body "<body>"` + - Replace `<title>` with the title from step 1. For `<body>`, use a short description (e.g. same as title or "See commits for details"). Quote both so special characters or spaces are handled correctly. (Non-interactive `gh` requires `--body`.) +4. Report the outcome: the PR URL if successful, or any error from `git push` or `gh` (e.g. not logged in, uncommitted changes, conflicts). + +## Notes + +- Ensure you are in the workspace (repo) root when running `git` and `gh`. +- The current branch is used automatically as the head by `gh pr create`. +- If the user asks for a custom body/description, use that for `--body "..."` instead of the default. From 7d50d529ed9ed3b83705a5a4ed02bd05e3764862 Mon Sep 17 00:00:00 2001 From: Tyler Mairose <tyler.mairose@sailpoint.com> Date: Mon, 2 Mar 2026 15:11:18 -0500 Subject: [PATCH 3/3] Update build and valdiate to use a python script instead of a bash script --- .cursor/commands/build-sdk.md | 8 ++- scripts/build-and-validate-sdk.sh | 67 --------------------- scripts/build_and_validate_sdk.py | 96 +++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 70 deletions(-) delete mode 100755 scripts/build-and-validate-sdk.sh create mode 100644 scripts/build_and_validate_sdk.py diff --git a/.cursor/commands/build-sdk.md b/.cursor/commands/build-sdk.md index ceee373a3..05cfcca62 100644 --- a/.cursor/commands/build-sdk.md +++ b/.cursor/commands/build-sdk.md @@ -4,15 +4,17 @@ 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`. +Works on Windows, macOS, and Linux (no shell required). + ## What to do 1. Run the build-and-validate script from the repository root: - - **Command:** `./scripts/build-and-validate-sdk.sh` + - **Command:** `python scripts/build_and_validate_sdk.py` - 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=<path> ./scripts/build-and-validate-sdk.sh` +- To skip tests: set env and run, e.g. `SKIP_TESTS=true python scripts/build_and_validate_sdk.py` (Unix/macOS) or `set SKIP_TESTS=true && python scripts/build_and_validate_sdk.py` (Windows cmd) or `$env:SKIP_TESTS="true"; python scripts/build_and_validate_sdk.py` (Windows PowerShell). +- Different api-specs path: `API_SPECS_PATH=<path> python scripts/build_and_validate_sdk.py` (Unix/macOS) or set `API_SPECS_PATH` then run the Python command (Windows). diff --git a/scripts/build-and-validate-sdk.sh b/scripts/build-and-validate-sdk.sh deleted file mode 100755 index 8eb44c6a8..000000000 --- a/scripts/build-and-validate-sdk.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/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." diff --git a/scripts/build_and_validate_sdk.py b/scripts/build_and_validate_sdk.py new file mode 100644 index 000000000..2dbe91237 --- /dev/null +++ b/scripts/build_and_validate_sdk.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python3 +""" +Build the Python SDK and run validation tests. +Cross-platform (Windows, macOS, Linux). + +Prerequisites: Node.js, Python 3.x, Java 17+ on PATH. +Optional env: API_SPECS_PATH (default api-specs), SKIP_TESTS (default false). + +Usage (from repo root): + python scripts/build_and_validate_sdk.py + SKIP_TESTS=true python scripts/build_and_validate_sdk.py + API_SPECS_PATH=other-specs python scripts/build_and_validate_sdk.py +""" + +import os +import shutil +import subprocess +import sys +import urllib.request + + +def repo_root(): + return os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) + + +def main(): + root = repo_root() + os.chdir(root) + + api_specs_path = os.environ.get("API_SPECS_PATH", "api-specs") + skip_tests = os.environ.get("SKIP_TESTS", "false").lower() in ("1", "true", "yes") + + print(f"Building SDK (api-specs-path={api_specs_path}, skip-tests={skip_tests})") + + # Download OpenAPI Generator if not present + jar_path = os.path.join(root, "openapi-generator-cli.jar") + if not os.path.isfile(jar_path): + print("Downloading OpenAPI Generator...") + url = "https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.12.0/openapi-generator-cli-7.12.0.jar" + urllib.request.urlretrieve(url, jar_path) + + # Prescript + print("Running prescript...") + idn_path = os.path.join(api_specs_path, "idn") + subprocess.run(["node", "sdk-resources/prescript.js", idn_path], check=True, cwd=root) + + def build_sdk(name, spec, config, out_dir): + print(f"Building {name} SDK...") + sailpoint_dir = os.path.join(root, "sailpoint", out_dir) + if os.path.isdir(sailpoint_dir): + shutil.rmtree(sailpoint_dir) + spec_path = os.path.join(api_specs_path, "idn", spec) + subprocess.run( + [ + "java", "-jar", jar_path, "generate", + "-i", spec_path, + "-g", "python", "-o", ".", + "--global-property", "skipFormModel=false,apiDocs=true,modelDocs=true", + "--config", f"sdk-resources/{config}", + ], + check=True, + cwd=root, + ) + subprocess.run( + ["node", "sdk-resources/postscript.js", sailpoint_dir], + check=True, + cwd=root, + ) + + 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 (use current Python / venv) + pip_cmd = [sys.executable, "-m", "pip"] + print("Installing dependencies and SDK...") + subprocess.run(pip_cmd + ["install", "-r", "requirements.txt"], check=True, cwd=root) + subprocess.run(pip_cmd + ["install", "-e", "."], check=True, cwd=root) + + if not skip_tests: + print("Running validation tests...") + subprocess.run( + [sys.executable, "validation_test.py", "-v"], + check=True, + cwd=root, + ) + else: + print(f"Skipping tests (SKIP_TESTS={os.environ.get('SKIP_TESTS', '')})") + + print("Done.") + + +if __name__ == "__main__": + main()