Skip to content

Commit b1eb3d7

Browse files
GvieveGenevieve Nuebel
andauthored
Overhaul SDK dispatch for versioned OAS files (dry-run) (#180)
* Add versioned-sdk-dispatch.yml (dry-run mode) New workflow that detects changes to versioned OAS files (openapi/v*.yml) on PR merge, builds api_versions list, reads version label (minor/patch), and dispatches to opted-in SDK repos only. Currently in DRY RUN mode — logs what it would send without dispatching. Includes workflow_dispatch for manual runs with version/api_versions inputs. Only mx-platform-node opted in initially. * Deprecate update.yml — rename to update.yml.bak Old workflow dispatched to all 6 SDK repos on any mx_platform_api.yml change. Replaced by versioned-sdk-dispatch.yml which detects versioned OAS files and dispatches only to opted-in repos. Kept as .bak for reference. * Update version.yml — enforce labels on versioned OAS files Changed-files check now includes openapi/v*.yml in addition to mx_platform_api.yml. PRs that modify versioned OAS files now require a minor or patch label before merge. * Update sdk-generation-validation.yml — use versioned OAS files Replaced static mx_platform_api.yml reference with dynamic discovery of changed versioned OAS files (openapi/v*.yml). Uses a discover job to build a matrix from changed files, then cross-products with the language matrix. Only runs generation validation for OAS files actually modified in the PR. --------- Co-authored-by: Genevieve Nuebel <genevieve.nuebel@mx.com>
1 parent c82b864 commit b1eb3d7

4 files changed

Lines changed: 293 additions & 50 deletions

File tree

.github/workflows/sdk-generation-validation.yml

Lines changed: 88 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,101 +2,142 @@ name: Test SDK Generation Validation
22

33
on:
44
pull_request:
5-
paths:
6-
- 'openapi/mx_platform_api.yml'
5+
paths:
6+
- 'openapi/v*.yml'
77

88
jobs:
9+
# ──────────────────────────────────────────────────
10+
# Discover which versioned OAS files changed in this PR
11+
# ──────────────────────────────────────────────────
12+
discover-changed-files:
13+
name: Discover Changed OAS Files
14+
runs-on: ubuntu-latest
15+
outputs:
16+
matrix: ${{ steps.build-matrix.outputs.matrix }}
17+
has_files: ${{ steps.build-matrix.outputs.has_files }}
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- name: Get changed versioned OAS files
22+
id: changed-files
23+
uses: tj-actions/changed-files@v41
24+
with:
25+
files: openapi/v*.yml
26+
27+
- name: Build matrix from changed files
28+
id: build-matrix
29+
run: |
30+
CHANGED="${{ steps.changed-files.outputs.all_changed_files }}"
31+
echo "Changed versioned OAS files: $CHANGED"
32+
33+
if [ -z "$CHANGED" ]; then
34+
echo "has_files=false" >> $GITHUB_OUTPUT
35+
echo "matrix=[]" >> $GITHUB_OUTPUT
36+
exit 0
37+
fi
38+
39+
# Build a JSON array of changed OAS files
40+
MATRIX="["
41+
FIRST=true
42+
for file in $CHANGED; do
43+
filename=$(basename "$file" .yml)
44+
if [ "$FIRST" = true ]; then
45+
FIRST=false
46+
else
47+
MATRIX="${MATRIX},"
48+
fi
49+
MATRIX="${MATRIX}{\"openapi_file\":\"${file}\",\"version_name\":\"${filename}\"}"
50+
done
51+
MATRIX="${MATRIX}]"
52+
53+
echo "matrix=${MATRIX}" >> $GITHUB_OUTPUT
54+
echo "has_files=true" >> $GITHUB_OUTPUT
55+
echo "Generated matrix: ${MATRIX}"
56+
57+
# ──────────────────────────────────────────────────
58+
# Run SDK generation validation for each changed OAS file x each language
59+
# ──────────────────────────────────────────────────
960
validate-sdk-generation:
61+
name: "${{ matrix.lang.display_name }} (${{ matrix.version.version_name }})"
62+
needs: discover-changed-files
63+
if: needs.discover-changed-files.outputs.has_files == 'true'
1064
runs-on: ubuntu-latest
1165
strategy:
1266
fail-fast: false
1367
matrix:
14-
include:
15-
- language: java
16-
generator: java
17-
display_name: Java
18-
- language: ruby
19-
generator: ruby
20-
display_name: Ruby
21-
- language: python
22-
generator: python
23-
display_name: Python
24-
- language: node
25-
generator: typescript-axios
26-
display_name: Node
27-
- language: csharp
28-
generator: csharp
29-
display_name: C#
30-
- language: go
31-
generator: go
32-
display_name: Go
33-
34-
name: ${{ matrix.display_name }} SDK Generation
35-
68+
version: ${{ fromJson(needs.discover-changed-files.outputs.matrix) }}
69+
lang:
70+
- { language: java, generator: java, display_name: Java }
71+
- { language: ruby, generator: ruby, display_name: Ruby }
72+
- { language: python, generator: python, display_name: Python }
73+
- { language: node, generator: "typescript-axios", display_name: Node }
74+
- { language: csharp, generator: csharp, display_name: "C#" }
75+
- { language: go, generator: go, display_name: Go }
76+
3677
steps:
3778
- name: Checkout repository
3879
uses: actions/checkout@v3
39-
80+
4081
- name: Set up Node.js
4182
uses: actions/setup-node@v3
4283
with:
4384
node-version: '20'
44-
85+
4586
- name: Install OpenAPI Generator CLI
4687
run: npm install -g @openapitools/openapi-generator-cli
47-
88+
4889
- name: Create output directory
49-
run: mkdir -p ./sdk-output/${{ matrix.language }}
50-
51-
- name: Generate Test SDK
90+
run: mkdir -p ./sdk-output/${{ matrix.lang.language }}
91+
92+
- name: Generate Test SDK from ${{ matrix.version.version_name }}
5293
run: |
5394
openapi-generator-cli generate \
54-
-i openapi/mx_platform_api.yml \
55-
-g ${{ matrix.generator }} \
56-
-o ./sdk-output/${{ matrix.language }} \
95+
-i ${{ matrix.version.openapi_file }} \
96+
-g ${{ matrix.lang.generator }} \
97+
-o ./sdk-output/${{ matrix.lang.language }} \
5798
--skip-validate-spec
58-
99+
59100
- name: Verify expected files were generated
60101
run: |
61-
echo "Checking for generated files in ./sdk-output/${{ matrix.language }}"
62-
ls -la ./sdk-output/${{ matrix.language }}
63-
64-
cd ./sdk-output/${{ matrix.language }}
65-
102+
echo "Checking for generated files in ./sdk-output/${{ matrix.lang.language }}"
103+
ls -la ./sdk-output/${{ matrix.lang.language }}
104+
105+
cd ./sdk-output/${{ matrix.lang.language }}
106+
66107
# Check for key files based on language
67-
case "${{ matrix.language }}" in
108+
case "${{ matrix.lang.language }}" in
68109
"java")
69110
find . -name "pom.xml" -quit > /dev/null || (echo "❌ Missing pom.xml" && exit 1)
70111
find . -name "*.java" -quit > /dev/null || (echo "❌ No Java files found" && exit 1)
71-
echo "✅ Java SDK structure validated"
112+
echo "✅ Java SDK structure validated (${{ matrix.version.version_name }})"
72113
;;
73114
"ruby")
74115
find . -name "*.gemspec" -quit > /dev/null || (echo "❌ Missing gemspec file" && exit 1)
75116
find . -name "*.rb" -quit > /dev/null || (echo "❌ No Ruby files found" && exit 1)
76-
echo "✅ Ruby SDK structure validated"
117+
echo "✅ Ruby SDK structure validated (${{ matrix.version.version_name }})"
77118
;;
78119
"python")
79120
find . -name "setup.py" -quit > /dev/null || (echo "❌ Missing setup.py" && exit 1)
80121
find . -name "*.py" -quit > /dev/null || (echo "❌ No Python files found" && exit 1)
81-
echo "✅ Python SDK structure validated"
122+
echo "✅ Python SDK structure validated (${{ matrix.version.version_name }})"
82123
;;
83124
"node")
84125
find . -name "package.json" -quit > /dev/null || (echo "❌ Missing package.json" && exit 1)
85126
find . \( -name "*.ts" -o -name "*.js" \) -quit > /dev/null || (echo "❌ No TypeScript/JavaScript files found" && exit 1)
86-
echo "✅ Node SDK structure validated"
127+
echo "✅ Node SDK structure validated (${{ matrix.version.version_name }})"
87128
;;
88129
"csharp")
89130
find . -name "*.csproj" -quit > /dev/null || (echo "❌ Missing csproj file" && exit 1)
90131
find . -name "*.cs" -quit > /dev/null || (echo "❌ No C# files found" && exit 1)
91-
echo "✅ C# SDK structure validated"
132+
echo "✅ C# SDK structure validated (${{ matrix.version.version_name }})"
92133
;;
93134
"go")
94135
find . -name "go.mod" -quit > /dev/null || (echo "❌ Missing go.mod" && exit 1)
95136
find . -name "*.go" -quit > /dev/null || (echo "❌ No Go files found" && exit 1)
96-
echo "✅ Go SDK structure validated"
137+
echo "✅ Go SDK structure validated (${{ matrix.version.version_name }})"
97138
;;
98139
esac
99140
100141
- name: Clean up
101142
if: always()
102-
run: rm -rf ./sdk-output/${{ matrix.language }}
143+
run: rm -rf ./sdk-output/${{ matrix.lang.language }}
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
name: Update
1+
# ──────────────────────────────────────────────────────────────────────
2+
# DEPRECATED — February 18, 2026
3+
# Replaced by: versioned-sdk-dispatch.yml
4+
#
5+
# This workflow dispatched to ALL 6 SDK repos whenever mx_platform_api.yml
6+
# changed. It has been replaced by versioned-sdk-dispatch.yml which:
7+
# - Detects changes to versioned OAS files (openapi/v*.yml)
8+
# - Dispatches only to opted-in SDK repos
9+
# - Passes api_versions in the payload
10+
#
11+
# Kept as .bak for reference. GitHub Actions ignores .bak files.
12+
# ──────────────────────────────────────────────────────────────────────
13+
name: "[DEPRECATED] Update"
214

315
on:
416
pull_request:

.github/workflows/version.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ jobs:
1212
pull-requests: write
1313
steps:
1414
- uses: actions/checkout@v3
15-
- name: Get openapi file
15+
16+
- name: Check for changed OAS files
1617
id: changed-files-specific
1718
uses: tj-actions/changed-files@v41
1819
with:
19-
files: openapi/mx_platform_api.yml
20+
files: |
21+
openapi/v*.yml
2022
2123
- name: Require version label if openapi spec changed
2224
if: steps.changed-files-specific.outputs.any_changed == 'true'

0 commit comments

Comments
 (0)