|
| 1 | +name: SDK Generator Matrix |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + tools: |
| 11 | + description: 'Comma-separated tool IDs (empty = all)' |
| 12 | + required: false |
| 13 | + default: '' |
| 14 | + scenarios: |
| 15 | + description: 'Comma-separated scenarios (empty = all)' |
| 16 | + required: false |
| 17 | + default: '' |
| 18 | + |
| 19 | +env: |
| 20 | + NODE_VERSION: '22' |
| 21 | + |
| 22 | +jobs: |
| 23 | + build-specs: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + - uses: actions/setup-node@v4 |
| 28 | + with: |
| 29 | + node-version: ${{ env.NODE_VERSION }} |
| 30 | + - run: npm install --no-save js-yaml |
| 31 | + - run: node scripts/build-specs.mjs |
| 32 | + - uses: actions/upload-artifact@v4 |
| 33 | + with: |
| 34 | + name: specs |
| 35 | + path: specs/ |
| 36 | + retention-days: 1 |
| 37 | + |
| 38 | + generate: |
| 39 | + needs: build-specs |
| 40 | + runs-on: ubuntu-latest |
| 41 | + strategy: |
| 42 | + fail-fast: false |
| 43 | + matrix: |
| 44 | + tool: |
| 45 | + - orval |
| 46 | + - openapi-generator |
| 47 | + - swagger-codegen |
| 48 | + - openapi-typescript |
| 49 | + - hey-api |
| 50 | + - openapi-typescript-codegen |
| 51 | + - oazapfts |
| 52 | + - kiota |
| 53 | + - nswag |
| 54 | + scenario: |
| 55 | + - baseline-duplicated-pagination |
| 56 | + - generic-schema-binding |
| 57 | + - paginated-response |
| 58 | + - recursive-category-tree |
| 59 | + - nested-workspace-resources |
| 60 | + version: |
| 61 | + - '3.1.0' |
| 62 | + - '3.1.1' |
| 63 | + - '3.1.2' |
| 64 | + - '3.2.0' |
| 65 | + |
| 66 | + steps: |
| 67 | + - uses: actions/checkout@v4 |
| 68 | + - uses: actions/setup-node@v4 |
| 69 | + with: |
| 70 | + node-version: ${{ env.NODE_VERSION }} |
| 71 | + |
| 72 | + - name: Check manual dispatch filter |
| 73 | + if: github.event_name == 'workflow_dispatch' |
| 74 | + run: | |
| 75 | + tools="${{ github.event.inputs.tools }}" |
| 76 | + scenarios="${{ github.event.inputs.scenarios }}" |
| 77 | + if [ -n "$tools" ]; then |
| 78 | + echo "$tools" | tr ',' '\n' | grep -qx "${{ matrix.tool }}" || exit 0 |
| 79 | + fi |
| 80 | + if [ -n "$scenarios" ]; then |
| 81 | + echo "$scenarios" | tr ',' '\n' | grep -qx "${{ matrix.scenario }}" || exit 0 |
| 82 | + fi |
| 83 | +
|
| 84 | + - uses: actions/download-artifact@v4 |
| 85 | + with: |
| 86 | + name: specs |
| 87 | + path: specs/ |
| 88 | + |
| 89 | + - name: Install .NET tools |
| 90 | + if: matrix.tool == 'kiota' || matrix.tool == 'nswag' |
| 91 | + uses: actions/setup-dotnet@v4 |
| 92 | + with: |
| 93 | + dotnet-version: '8.0.x' |
| 94 | + |
| 95 | + - name: Install Kiota |
| 96 | + if: matrix.tool == 'kiota' |
| 97 | + run: dotnet tool install --global Microsoft.OpenApi.Kiota |
| 98 | + |
| 99 | + - name: Install NSwag |
| 100 | + if: matrix.tool == 'nswag' |
| 101 | + run: dotnet tool install --global NSwag.GlobalTool |
| 102 | + |
| 103 | + - name: Install npm dependencies |
| 104 | + run: npm install --no-save js-yaml typescript |
| 105 | + |
| 106 | + - name: Generate SDK |
| 107 | + id: generate |
| 108 | + run: node scripts/matrix-runner.mjs --tools=${{ matrix.tool }} --scenarios=${{ matrix.scenario }} --versions=${{ matrix.version }} --no-typecheck --no-analysis |
| 109 | + continue-on-error: true |
| 110 | + |
| 111 | + - name: Typecheck |
| 112 | + if: steps.generate.outcome == 'success' |
| 113 | + id: typecheck |
| 114 | + run: | |
| 115 | + output_dir="generated/${{ matrix.tool }}/${{ matrix.scenario }}/${{ matrix.version }}" |
| 116 | + if [ ! -d "$output_dir" ]; then |
| 117 | + echo "skip=true" >> "$GITHUB_OUTPUT" |
| 118 | + exit 0 |
| 119 | + fi |
| 120 | + ts_files=$(find "$output_dir" -name "*.ts" -not -name "*.spec.ts" -not -name "*.test.ts" -not -path "*/node_modules/*" 2>/dev/null || true) |
| 121 | + if [ -z "$ts_files" ]; then |
| 122 | + echo "skip=true" >> "$GITHUB_OUTPUT" |
| 123 | + exit 0 |
| 124 | + fi |
| 125 | + echo "$ts_files" | xargs npx tsc --noEmit --strict --esModuleInterop --moduleResolution node --target ES2020 --module commonjs --skipLibCheck 2>&1 | tee logs/typecheck-${{ matrix.tool }}-${{ matrix.scenario }}-${{ matrix.version }}.log |
| 126 | + exit ${PIPESTATUS[0]} |
| 127 | + continue-on-error: true |
| 128 | + |
| 129 | + - name: Analyze quality |
| 130 | + if: steps.generate.outcome == 'success' |
| 131 | + run: node scripts/matrix-runner.mjs --tools=${{ matrix.tool }} --scenarios=${{ matrix.scenario }} --versions=${{ matrix.version }} --no-generate --no-typecheck |
| 132 | + |
| 133 | + - name: Write cell result |
| 134 | + if: always() |
| 135 | + run: | |
| 136 | + mkdir -p cell-results |
| 137 | + gen_outcome="${{ steps.generate.outcome }}" |
| 138 | + tc_outcome="${{ steps.typecheck.outcome }}" |
| 139 | + tc_skip="${{ steps.typecheck.outputs.skip }}" |
| 140 | + echo "${{ matrix.tool }}.${{ matrix.scenario }}.${{ matrix.version }}.generate=${gen_outcome:-skipped}" >> cell-results/results.env |
| 141 | + if [ "$tc_skip" = "true" ]; then |
| 142 | + echo "${{ matrix.tool }}.${{ matrix.scenario }}.${{ matrix.version }}.typecheck=skip" >> cell-results/results.env |
| 143 | + else |
| 144 | + echo "${{ matrix.tool }}.${{ matrix.scenario }}.${{ matrix.version }}.typecheck=${tc_outcome:-skipped}" >> cell-results/results.env |
| 145 | + fi |
| 146 | +
|
| 147 | + - name: Upload generated output |
| 148 | + if: always() |
| 149 | + uses: actions/upload-artifact@v4 |
| 150 | + with: |
| 151 | + name: generated-${{ matrix.tool }}-${{ matrix.scenario }}-${{ matrix.version }} |
| 152 | + path: | |
| 153 | + generated/${{ matrix.tool }}/${{ matrix.scenario }}/${{ matrix.version }}/ |
| 154 | + logs/${{ matrix.tool }}-${{ matrix.scenario }}-${{ matrix.version }}.log |
| 155 | + logs/typecheck-${{ matrix.tool }}-${{ matrix.scenario }}-${{ matrix.version }}.log |
| 156 | + logs/matrix-results.json |
| 157 | + cell-results/results.env |
| 158 | + retention-days: 7 |
| 159 | + if-no-files-found: ignore |
| 160 | + |
| 161 | + summary: |
| 162 | + needs: generate |
| 163 | + runs-on: ubuntu-latest |
| 164 | + if: always() |
| 165 | + steps: |
| 166 | + - uses: actions/checkout@v4 |
| 167 | + - uses: actions/setup-node@v4 |
| 168 | + with: |
| 169 | + node-version: ${{ env.NODE_VERSION }} |
| 170 | + |
| 171 | + - uses: actions/download-artifact@v4 |
| 172 | + with: |
| 173 | + pattern: generated-* |
| 174 | + path: all-results/ |
| 175 | + merge-multiple: true |
| 176 | + |
| 177 | + - name: Build summary |
| 178 | + run: | |
| 179 | + echo "## SDK Generator Matrix Results" >> "$GITHUB_STEP_SUMMARY" |
| 180 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 181 | + echo "| Tool | Scenario | Version | Generate | Typecheck |" >> "$GITHUB_STEP_SUMMARY" |
| 182 | + echo "|------|----------|---------|----------|-----------|" >> "$GITHUB_STEP_SUMMARY" |
| 183 | +
|
| 184 | + for envf in all-results/cell-results/results.env; do |
| 185 | + [ -f "$envf" ] || continue |
| 186 | + while IFS='=' read -r key value; do |
| 187 | + IFS='.' read -r tool scenario version field <<< "$key" |
| 188 | + [ "$field" = "generate" ] || continue |
| 189 | + tc_key="${tool}.${scenario}.${version}.typecheck" |
| 190 | + tc_value=$(grep "^${tc_key}=" all-results/cell-results/results.env 2>/dev/null | cut -d= -f2) |
| 191 | + gen_label="${value}" |
| 192 | + tc_label="${tc_value:-N/A}" |
| 193 | + echo "| ${tool} | ${scenario} | ${version} | ${gen_label} | ${tc_label} |" >> "$GITHUB_STEP_SUMMARY" |
| 194 | + done < "$envf" |
| 195 | + done |
| 196 | +
|
| 197 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 198 | + echo "### Artifacts" >> "$GITHUB_STEP_SUMMARY" |
| 199 | + echo "Generated output and logs are available as workflow artifacts." >> "$GITHUB_STEP_SUMMARY" |
| 200 | +
|
| 201 | + - name: Load quality results |
| 202 | + run: | |
| 203 | + echo "### Type Quality" >> "$GITHUB_STEP_SUMMARY" |
| 204 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 205 | + if [ -f all-results/logs/matrix-results.json ]; then |
| 206 | + node -e " |
| 207 | + const data = JSON.parse(require('fs').readFileSync('all-results/logs/matrix-results.json', 'utf8')); |
| 208 | + console.log('| Tool | Scenario | Version | Fidelity | unknown | any |'); |
| 209 | + console.log('|------|----------|---------|----------|---------|-----|'); |
| 210 | + for (const r of (data.results || [])) { |
| 211 | + if (r.quality) { |
| 212 | + console.log('| ' + [r.tool, r.scenario, r.version, r.quality.fidelity, r.quality.unknownCount, r.quality.anyCount].join(' | ') + ' |'); |
| 213 | + } |
| 214 | + } |
| 215 | + " >> "$GITHUB_STEP_SUMMARY" |
| 216 | + else |
| 217 | + echo "Quality data not available" >> "$GITHUB_STEP_SUMMARY" |
| 218 | + fi |
0 commit comments