Revert "v2.0.0-rc.3 preparation (#10382)" (#10386) #83
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Generate Spicepod JSON schema | |
| on: | |
| push: | |
| branches: [trunk] | |
| paths: | |
| - 'crates/spicepod/**' | |
| workflow_dispatch: | |
| inputs: | |
| run_build: | |
| description: 'Run build and generation' | |
| required: false | |
| type: boolean | |
| default: true | |
| create_pr: | |
| description: 'Create PR' | |
| required: false | |
| type: boolean | |
| default: true | |
| env: | |
| CARGO_TERM_COLOR: always | |
| CARGO_INCREMENTAL: 0 | |
| CARGO_NET_GIT_FETCH_WITH_CLI: true | |
| jobs: | |
| generate_schema: | |
| runs-on: self-hosted | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 | |
| - run: rustup toolchain install 1.94.1 --profile minimal | |
| - name: Set up make | |
| if: runner.os != 'macOS' && (github.event_name != 'workflow_dispatch' || inputs.run_build) | |
| uses: ./.github/actions/setup-make | |
| - name: Set up cc | |
| if: runner.os != 'macOS' && (github.event_name != 'workflow_dispatch' || inputs.run_build) | |
| uses: ./.github/actions/setup-cc | |
| - name: Build Cargo project | |
| if: github.event_name != 'workflow_dispatch' || inputs.run_build | |
| run: cargo build --manifest-path tools/spicepodschema/Cargo.toml | |
| - name: Run Cargo project | |
| if: github.event_name != 'workflow_dispatch' || inputs.run_build | |
| run: cargo run --manifest-path tools/spicepodschema/Cargo.toml -- .schema/spicepod.schema.json | |
| - name: Verify JSON schema file | |
| if: github.event_name != 'workflow_dispatch' || inputs.run_build | |
| run: | | |
| if [ -f ".schema/spicepod.schema.json" ]; then | |
| echo ".schema/spicepod.schema.json file was successfully created." | |
| cat .schema/spicepod.schema.json | |
| else | |
| echo ".schema/spicepod.schema.json file was not created." | |
| exit 1 | |
| fi | |
| - name: Upload JSON schema artifact | |
| if: github.event_name != 'workflow_dispatch' || inputs.run_build | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 | |
| with: | |
| name: spicepod.schema | |
| path: .schema/spicepod.schema.json | |
| - name: Create PR | |
| if: github.event_name == 'workflow_dispatch' && inputs.create_pr && inputs.run_build | |
| run: | | |
| git config --global user.name 'Spice Schema Bot' | |
| git config --global user.email 'schema-bot@spice.ai' | |
| git checkout -b schema/${GITHUB_RUN_ID} | |
| git diff .schema/spicepod.schema.json | |
| if [[ $(git diff --exit-code .schema/spicepod.schema.json) ]]; then | |
| git add .schema/spicepod.schema.json | |
| git commit -m "Update spicepod.schema.json" | |
| git push origin schema/${GITHUB_RUN_ID} | |
| gh pr create --title "Update spicepod.schema.json" --body "Updated Spicepod Schema" --base trunk --head schema/${GITHUB_RUN_ID} | |
| else | |
| echo "No changes detected" | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Validate schema against test files | |
| continue-on-error: true | |
| run: | | |
| set +e | |
| python3 -m venv .venv | |
| .venv/bin/python -m pip install check-jsonschema | |
| echo "## Schema Validation Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| VALIDATION_FAILED=0 | |
| for file in tools/spicepodschema/tests/*.yaml; do | |
| filename=$(basename "$file") | |
| if .venv/bin/check-jsonschema --schemafile .schema/spicepod.schema.json "$file" 2>&1; then | |
| echo "✅ \`$filename\` - Valid" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "❌ \`$filename\` - Invalid" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "<details><summary>Validation errors</summary>" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| { .venv/bin/check-jsonschema --schemafile .schema/spicepod.schema.json "$file" --verbose 2>&1 || true; } >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "</details>" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| VALIDATION_FAILED=1 | |
| fi | |
| done | |
| if [ $VALIDATION_FAILED -eq 1 ]; then | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "⚠️ **Some test files failed validation. Please fix the errors above.**" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "✅ **All test files passed validation.**" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| exit 0 |