From b4da3066bb1a39e931271b0c6dc6b934b5943626 Mon Sep 17 00:00:00 2001 From: Genevieve Nuebel Date: Tue, 17 Feb 2026 15:56:37 -0700 Subject: [PATCH] Add Phase 8A sandbox test infrastructure Test workflows, configs, and directories for validating Issues 2, 5, 6 fixes without risking production SDK generation or npm publishes. Files added: - .github/workflows/test-auto-generate.yml (mirrors openapi-generate-and-push.yml) - .github/workflows/test-on-push.yml (mirrors on-push-master.yml) - openapi/test-config-v20111101.yml (v98.0.0) - openapi/test-config-v20250224.yml (v99.0.0) - test-v20111101/.gitkeep (placeholder directory) - test-v20250224/.gitkeep (placeholder directory) - TEST-CHANGELOG.md All test files to be deleted after Phase 8A validation is complete. --- .github/workflows/test-auto-generate.yml | 273 +++++++++++++++++++++++ .github/workflows/test-on-push.yml | 140 ++++++++++++ TEST-CHANGELOG.md | 16 ++ openapi/test-config-v20111101.yml | 7 + openapi/test-config-v20250224.yml | 7 + test-v20111101/.gitkeep | 2 + test-v20250224/.gitkeep | 2 + 7 files changed, 447 insertions(+) create mode 100644 .github/workflows/test-auto-generate.yml create mode 100644 .github/workflows/test-on-push.yml create mode 100644 TEST-CHANGELOG.md create mode 100644 openapi/test-config-v20111101.yml create mode 100644 openapi/test-config-v20250224.yml create mode 100644 test-v20111101/.gitkeep create mode 100644 test-v20250224/.gitkeep diff --git a/.github/workflows/test-auto-generate.yml b/.github/workflows/test-auto-generate.yml new file mode 100644 index 0000000..fcfe5cf --- /dev/null +++ b/.github/workflows/test-auto-generate.yml @@ -0,0 +1,273 @@ +name: "TEST: Auto Generate and Push" + +# ============================================================================ +# SANDBOX TEST WORKFLOW - Phase 8A +# Mirrors openapi-generate-and-push.yml but uses test configs, test directories, +# and pushes to a test branch. Incorporates fixes for Issues 2, 5, and 6. +# DELETE THIS FILE after Phase 8A testing is complete. +# ============================================================================ + +on: + workflow_dispatch: + inputs: + payload_json: + description: 'JSON payload (e.g., {"api_versions":"v20111101","version":"minor","commit_sha":"abc123"})' + required: true + type: string + +jobs: + Setup: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + versions_to_generate: ${{ steps.parse-payload.outputs.versions_to_generate }} + steps: + - name: Parse payload + id: parse-payload + run: | + echo "📋 Raw payload: ${{ github.event.inputs.payload_json }}" + VERSIONS=$(echo '${{ github.event.inputs.payload_json }}' | jq -r '.api_versions // "v20111101"') + echo "📋 Parsed versions: $VERSIONS" + echo "versions_to_generate=$VERSIONS" >> $GITHUB_OUTPUT + + - name: Set up matrix + id: set-matrix + run: | + VERSIONS="${{ steps.parse-payload.outputs.versions_to_generate }}" + echo "📋 Versions to generate: $VERSIONS" + + # Build matrix JSON — uses TEST config files + MATRIX_JSON='{"include":[' + FIRST=true + + for VERSION in $(echo $VERSIONS | tr ',' ' '); do + if [ "$FIRST" = false ]; then + MATRIX_JSON+=',' + fi + FIRST=false + + # Map version to TEST config file (not production configs) + if [ "$VERSION" = "v20111101" ]; then + CONFIG="openapi/test-config-v20111101.yml" + elif [ "$VERSION" = "v20250224" ]; then + CONFIG="openapi/test-config-v20250224.yml" + fi + + MATRIX_JSON+="{\"api_version\":\"$VERSION\",\"config_file\":\"$CONFIG\"}" + done + + MATRIX_JSON+=']}' + echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT + echo "📋 Matrix: $MATRIX_JSON" + + Generate: + runs-on: ubuntu-latest + needs: Setup + strategy: + matrix: ${{ fromJson(needs.Setup.outputs.matrix) }} + fail-fast: false + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: "20" + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1 + + - name: Validate configuration + run: | + # Skip config_validator.rb for test configs since it validates major version + # against SUPPORTED_VERSIONS map (98/99 would fail). Just validate file exists. + echo "📋 Validating test config: ${{ matrix.config_file }}" + if [ ! -f "${{ matrix.config_file }}" ]; then + echo "❌ Config file not found: ${{ matrix.config_file }}" + exit 1 + fi + echo "✅ Config file exists" + cat "${{ matrix.config_file }}" + + - name: Bump version + id: bump_version + run: | + # Parse version bump type from payload + VERSION=$(echo '${{ github.event.inputs.payload_json }}' | jq -r '.version // "patch"') + echo "📋 VERSION parsed as: $VERSION" + + # *** ISSUE 2 FIX: $VERSION unquoted (was "$VERSION" in production) *** + NEW_VERSION=$(ruby .github/version.rb $VERSION ${{ matrix.config_file }}) + echo "📋 NEW_VERSION returned: $NEW_VERSION" + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT + + # Verify the config was actually updated + echo "📋 Config file after bump:" + cat ${{ matrix.config_file }} + + - name: Clean test directory + run: | + # Use clean.rb with test- prefix directory + ruby .github/clean.rb test-${{ matrix.api_version }} + + - name: Copy generator ignore rules + run: | + mkdir -p ./test-${{ matrix.api_version }}/ + cp .openapi-generator-ignore ./test-${{ matrix.api_version }}/ + + - name: Install openapi-generator-cli + run: npm install @openapitools/openapi-generator-cli -g + + - name: Generate SDK + run: | + # Parse commit_sha from payload + COMMIT_SHA=$(echo '${{ github.event.inputs.payload_json }}' | jq -r '.commit_sha // "master"') + echo "📋 Using commit SHA: $COMMIT_SHA" + + # Generate into test- prefixed directory + openapi-generator-cli generate \ + -i https://raw.githubusercontent.com/mxenabled/openapi/$COMMIT_SHA/openapi/${{ matrix.api_version }}.yml \ + -g typescript-axios \ + -c ${{ matrix.config_file }} \ + -t ./openapi/templates \ + -o ./test-${{ matrix.api_version }} + + echo "📋 Generated files in test-${{ matrix.api_version }}/:" + ls -la ./test-${{ matrix.api_version }}/ + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: test-generated-${{ matrix.api_version }} + path: ./test-${{ matrix.api_version }} + + Process-and-Push: + runs-on: ubuntu-latest + needs: [Setup, Generate] + steps: + - uses: actions/checkout@v3 + with: + ref: test-auto-generate + fetch-depth: 0 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1 + + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: ./test-generated + + - name: Move generated files and track versions + id: track_versions + run: | + echo "📋 Downloaded artifacts:" + ls -la ./test-generated/ + + GENERATED_VERSIONS="" + + for dir in ./test-generated/test-generated-*; do + VERSION=$(basename "$dir" | sed 's/test-generated-//') + TARGET_DIR="./test-$VERSION" + + echo "📋 Processing: $dir → $TARGET_DIR" + echo "📋 Target directory exists? $([ -d "$TARGET_DIR" ] && echo 'YES' || echo 'NO')" + + # *** ISSUE 5 FIX: Remove target directory before moving *** + # Without this, mv places the source INSIDE the existing directory + # as a subdirectory instead of replacing its contents + if [ -d "$TARGET_DIR" ]; then + echo "📋 Removing existing target: $TARGET_DIR" + rm -rf "$TARGET_DIR" + fi + + mv "$dir" "$TARGET_DIR" + GENERATED_VERSIONS="$GENERATED_VERSIONS $VERSION" + + echo "📋 Files now in $TARGET_DIR:" + ls -la "$TARGET_DIR/" + + # Verify no nested subdirectory was created (Issue 5 validation) + if [ -d "$TARGET_DIR/test-generated-$VERSION" ]; then + echo "❌ ISSUE 5 NOT FIXED: Found nested subdirectory $TARGET_DIR/test-generated-$VERSION" + exit 1 + else + echo "✅ ISSUE 5 VALIDATED: No nested subdirectory created" + fi + done + + echo "generated_versions=$GENERATED_VERSIONS" >> $GITHUB_OUTPUT + echo "📋 All generated versions: $GENERATED_VERSIONS" + + - name: Update TEST-CHANGELOG + run: | + GENERATED_VERSIONS="${{ steps.track_versions.outputs.generated_versions }}" + + if [ -z "$GENERATED_VERSIONS" ]; then + echo "No versions generated, skipping changelog update" + exit 0 + fi + + # Use changelog_manager.rb but pointed at TEST-CHANGELOG.md + # We need to temporarily swap CHANGELOG.md for the test + # Back up real CHANGELOG, replace with test, run manager, restore + cp CHANGELOG.md CHANGELOG.md.bak + cp TEST-CHANGELOG.md CHANGELOG.md + + VERSIONS_CSV=$(echo "$GENERATED_VERSIONS" | xargs | tr ' ' ',') + echo "📋 Updating TEST-CHANGELOG for versions: $VERSIONS_CSV" + ruby .github/changelog_manager.rb "$VERSIONS_CSV" + + # Move updated changelog to TEST-CHANGELOG and restore real one + cp CHANGELOG.md TEST-CHANGELOG.md + mv CHANGELOG.md.bak CHANGELOG.md + + echo "📋 TEST-CHANGELOG.md after update:" + head -30 TEST-CHANGELOG.md + + - name: Copy documentation to test directories + run: | + GENERATED_VERSIONS="${{ steps.track_versions.outputs.generated_versions }}" + + for VERSION in $GENERATED_VERSIONS; do + cp LICENSE "./test-$VERSION/LICENSE" + cp TEST-CHANGELOG.md "./test-$VERSION/CHANGELOG.md" + cp MIGRATION.md "./test-$VERSION/MIGRATION.md" + done + + - name: Create commit and push to test branch + run: | + git config user.name "devexperience" + git config user.email "devexperience@mx.com" + git add . + git status + git commit -m "TEST: Generated SDK versions: ${{ needs.Setup.outputs.versions_to_generate }} + + This commit was automatically created by the test-auto-generate workflow. + Payload: ${{ github.event.inputs.payload_json }}" + git push origin test-auto-generate + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Generate access token + id: generate_token + uses: tibdex/github-app-token@v1 + with: + app_id: ${{ secrets.PAPI_SDK_APP_ID }} + installation_id: ${{ secrets.PAPI_SDK_INSTALLATION_ID }} + private_key: ${{ secrets.PAPI_SDK_PRIVATE_KEY }} + + - name: Trigger test-on-push workflow + uses: peter-evans/repository-dispatch@v2 + with: + token: ${{ steps.generate_token.outputs.token }} + event-type: test_push_to_branch + + - name: Summary + run: | + echo "============================================" + echo "📋 TEST AUTO-GENERATE SUMMARY" + echo "============================================" + echo "Versions generated: ${{ needs.Setup.outputs.versions_to_generate }}" + echo "Pushed to branch: test-auto-generate" + echo "Triggered: test-on-push workflow via repository_dispatch" + echo "============================================" diff --git a/.github/workflows/test-on-push.yml b/.github/workflows/test-on-push.yml new file mode 100644 index 0000000..b4ad240 --- /dev/null +++ b/.github/workflows/test-on-push.yml @@ -0,0 +1,140 @@ +name: "TEST: On Push to Test Branch" + +# ============================================================================ +# SANDBOX TEST WORKFLOW - Phase 8A +# Mirrors on-push-master.yml but tracks test-auto-generate branch and test +# directories. Publish/release jobs echo success instead of real actions. +# Incorporates fix for Issue 6 (env block for commit message). +# DELETE THIS FILE after Phase 8A testing is complete. +# ============================================================================ + +on: + push: + branches: [test-auto-generate] + paths: + - 'test-v20111101/**' + - 'test-v20250224/**' + repository_dispatch: + types: [test_push_to_branch] + +jobs: + # Check for skip-publish flag in commit message + # *** ISSUE 6 FIX: Uses env block instead of inline interpolation *** + check-skip-publish: + runs-on: ubuntu-latest + outputs: + skip_publish: ${{ steps.check.outputs.skip_publish }} + steps: + - name: Check for [skip-publish] flag in commit message + id: check + env: + COMMIT_MSG: ${{ github.event.head_commit.message }} + run: | + echo "📋 Commit message: $COMMIT_MSG" + if [[ "$COMMIT_MSG" == *"[skip-publish]"* ]]; then + echo "skip_publish=true" >> $GITHUB_OUTPUT + echo "🚫 [skip-publish] flag detected - skipping all publish/release jobs" + else + echo "skip_publish=false" >> $GITHUB_OUTPUT + echo "✅ No skip flag - proceeding with publish/release" + fi + + # Detect which test API versions were modified in this push + detect-changes: + runs-on: ubuntu-latest + outputs: + test_v20111101: ${{ steps.filter.outputs.test_v20111101 }} + test_v20250224: ${{ steps.filter.outputs.test_v20250224 }} + steps: + - uses: actions/checkout@v3 + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + test_v20111101: + - 'test-v20111101/**' + test_v20250224: + - 'test-v20250224/**' + + # Simulated publish and release for each version conditionally + # Same conditional structure as production but echoes success instead of real npm publish/GitHub release + + publish-test-v20111101: + needs: [check-skip-publish, detect-changes] + if: needs.check-skip-publish.outputs.skip_publish == 'false' && needs.detect-changes.outputs.test_v20111101 == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: test-auto-generate + - name: Simulate publish + run: | + VERSION=$(jq -r '.version' ./test-v20111101/package.json) + echo "============================================" + echo "✅ PUBLISH SUCCESS (simulated)" + echo " Package: mx-platform-node@$VERSION" + echo " Directory: test-v20111101/" + echo " Would run: npm publish from test-v20111101/" + echo "============================================" + + release-test-v20111101: + needs: [check-skip-publish, detect-changes, publish-test-v20111101] + if: needs.check-skip-publish.outputs.skip_publish == 'false' && needs.detect-changes.outputs.test_v20111101 == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: test-auto-generate + - name: Simulate release + run: | + VERSION=$(jq -r '.version' ./test-v20111101/package.json) + echo "============================================" + echo "✅ RELEASE SUCCESS (simulated)" + echo " Tag: v$VERSION" + echo " Directory: test-v20111101/" + echo " Would create: GitHub release for v$VERSION" + echo "============================================" + + delay-for-test-v20250224: + runs-on: ubuntu-latest + needs: [check-skip-publish, detect-changes] + if: needs.check-skip-publish.outputs.skip_publish == 'false' + steps: + - name: Brief delay to stagger v20250224 publish + run: sleep 2 + + publish-test-v20250224: + needs: [check-skip-publish, detect-changes, delay-for-test-v20250224] + if: needs.check-skip-publish.outputs.skip_publish == 'false' && needs.detect-changes.outputs.test_v20250224 == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: test-auto-generate + - name: Simulate publish + run: | + VERSION=$(jq -r '.version' ./test-v20250224/package.json) + echo "============================================" + echo "✅ PUBLISH SUCCESS (simulated)" + echo " Package: mx-platform-node@$VERSION" + echo " Directory: test-v20250224/" + echo " Would run: npm publish from test-v20250224/" + echo "============================================" + + release-test-v20250224: + needs: [check-skip-publish, detect-changes, publish-test-v20250224] + if: needs.check-skip-publish.outputs.skip_publish == 'false' && needs.detect-changes.outputs.test_v20250224 == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: test-auto-generate + - name: Simulate release + run: | + VERSION=$(jq -r '.version' ./test-v20250224/package.json) + echo "============================================" + echo "✅ RELEASE SUCCESS (simulated)" + echo " Tag: v$VERSION" + echo " Directory: test-v20250224/" + echo " Would create: GitHub release for v$VERSION" + echo "============================================" diff --git a/TEST-CHANGELOG.md b/TEST-CHANGELOG.md new file mode 100644 index 0000000..e32a3d1 --- /dev/null +++ b/TEST-CHANGELOG.md @@ -0,0 +1,16 @@ +# Test Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [99.0.0] - 2026-02-16 + +### Added +- Test placeholder for v20250224 sandbox testing + +## [98.0.0] - 2026-02-16 + +### Added +- Test placeholder for v20111101 sandbox testing diff --git a/openapi/test-config-v20111101.yml b/openapi/test-config-v20111101.yml new file mode 100644 index 0000000..1ffc7ab --- /dev/null +++ b/openapi/test-config-v20111101.yml @@ -0,0 +1,7 @@ +--- +apiVersion: v20111101 +generatorName: typescript-axios +npmName: mx-platform-node +npmVersion: 98.0.0 +supportsES6: true +.openapi-generator-ignore: true diff --git a/openapi/test-config-v20250224.yml b/openapi/test-config-v20250224.yml new file mode 100644 index 0000000..c80c9ee --- /dev/null +++ b/openapi/test-config-v20250224.yml @@ -0,0 +1,7 @@ +--- +apiVersion: v20250224 +generatorName: typescript-axios +npmName: mx-platform-node +npmVersion: 99.0.0 +supportsES6: true +.openapi-generator-ignore: true diff --git a/test-v20111101/.gitkeep b/test-v20111101/.gitkeep new file mode 100644 index 0000000..559c920 --- /dev/null +++ b/test-v20111101/.gitkeep @@ -0,0 +1,2 @@ +# Placeholder for test-auto-generate workflow testing +# This directory mirrors v20111101/ for sandbox testing purposes diff --git a/test-v20250224/.gitkeep b/test-v20250224/.gitkeep new file mode 100644 index 0000000..c0b4141 --- /dev/null +++ b/test-v20250224/.gitkeep @@ -0,0 +1,2 @@ +# Placeholder for test-auto-generate workflow testing +# This directory mirrors v20250224/ for sandbox testing purposes