-
Notifications
You must be signed in to change notification settings - Fork 7
146 lines (130 loc) · 5.53 KB
/
Copy pathsdk-generation-validation.yml
File metadata and controls
146 lines (130 loc) · 5.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: SDK Generation Validation
on:
pull_request
# paths:
# - 'openapi/mx_platform_api.yml'
jobs:
validate-sdk-generation:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: ["java", "ruby", "python", "javascript", "csharp", "go"]
name: Validate ${{ matrix.language }} SDK Generation
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install OpenAPI Generator CLI
run: npm install -g @openapitools/openapi-generator-cli
- name: Set up Java (required for OpenAPI Generator)
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: Set up language-specific environment
run: |
case "${{ matrix.language }}" in
"java")
echo "Java already set up"
;;
"ruby")
sudo apt-get update
sudo apt-get install -y ruby-full
;;
"python")
python -m pip install --upgrade pip
;;
"javascript")
echo "Node.js already set up"
;;
"csharp")
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y dotnet-sdk-6.0
;;
"go")
wget -c https://go.dev/dl/go1.21.0.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> $GITHUB_ENV
;;
esac
- name: Create output directory
run: mkdir -p ./sdk-output/${{ matrix.language }}
- name: Generate Test SDK
run: |
openapi-generator-cli generate \
-i openapi/mx_platform_api.yml \
-g ${{ matrix.language }} \
-o ./sdk-output/${{ matrix.language }} \
--skip-validate-spec
- name: Verify expected files were generated
run: |
echo "Checking for generated files in ./sdk-output/${{ matrix.language }}"
ls -la ./sdk-output/${{ matrix.language }}
cd ./sdk-output/${{ matrix.language }}
# Check for key files based on language
case "${{ matrix.language }}" in
"java")
test -f pom.xml || (echo "❌ Missing pom.xml" && exit 1)
find src -name "*.java" | head -1 > /dev/null || (echo "❌ No Java files found" && exit 1)
echo "✅ Java SDK structure validated"
;;
"ruby")
ls *.gemspec > /dev/null 2>&1 || (echo "❌ Missing gemspec file" && exit 1)
find lib -name "*.rb" | head -1 > /dev/null || (echo "❌ No Ruby files found" && exit 1)
echo "✅ Ruby SDK structure validated"
;;
"python")
test -f setup.py || (echo "❌ Missing setup.py" && exit 1)
find . -name "*.py" | head -1 > /dev/null || (echo "❌ No Python files found" && exit 1)
echo "✅ Python SDK structure validated"
;;
"javascript")
test -f package.json || (echo "❌ Missing package.json" && exit 1)
find . -name "*.js" | head -1 > /dev/null || (echo "❌ No JavaScript files found" && exit 1)
echo "✅ JavaScript SDK structure validated"
;;
"csharp")
ls *.csproj > /dev/null 2>&1 || (echo "❌ Missing csproj file" && exit 1)
find . -name "*.cs" | head -1 > /dev/null || (echo "❌ No C# files found" && exit 1)
echo "✅ C# SDK structure validated"
;;
"go")
test -f go.mod || (echo "❌ Missing go.mod" && exit 1)
find . -name "*.go" | head -1 > /dev/null || (echo "❌ No Go files found" && exit 1)
echo "✅ Go SDK structure validated"
;;
esac
- name: Generate validation report
if: always()
run: |
echo "## SDK Generation Report for ${{ matrix.language }}"
echo "- **Status**: ${{ job.status }}"
- name: Clean up
if: always()
run: rm -rf ./sdk-output/${{ matrix.language }}
validation-summary:
needs: validate-sdk-generation
runs-on: ubuntu-latest
if: always()
steps:
- name: Check all SDK generations passed
run: |
if [[ "${{ needs.validate-sdk-generation.result }}" == "success" ]]; then
echo "✅ SDK Generation Validation: PASSED"
echo "All 6 SDK languages generated successfully from OpenAPI specification"
echo "## ✅ SDK Generation Validation: PASSED"
echo "All 6 SDK languages (Java, Ruby, Python, JavaScript, C#, Go) generated successfully."
else
echo "❌ SDK Generation Validation: FAILED"
echo "One or more SDK generations failed. Check individual language job logs for detailed error messages."
echo "## ❌ SDK Generation Validation: FAILED"
echo "**One or more SDK languages failed to generate.**"
echo "Check the individual language job logs above for detailed error messages."
exit 1
fi