Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/schema-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Schema Validation

on:
pull_request:
branches:
- main
- 'release/**'
paths:
- ".github/workflows/schema-validation.yml"
- "generate_ts_schema_types.js"
- "generated/schema-types.ts"
- "package.json"
- "package-lock.json"
- "source/**"
push:
branches:
- main
- 'release/**'
paths:
- ".github/workflows/schema-validation.yml"
- "generate_ts_schema_types.js"
- "generated/schema-types.ts"
- "package.json"
- "package-lock.json"
- "source/**"

permissions:
contents: read

jobs:
validate-schemas:
name: Generate and Validate Schemas
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm

- name: Install Node dependencies
run: npm ci

- name: Install ucp-schema
run: |
cargo install ucp-schema
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"

- name: Lint source schemas
run: ucp-schema lint source/

- name: Generate TypeScript schema types
run: node generate_ts_schema_types.js

- name: Verify generated files are in sync
run: git diff --exit-code -- generated/schema-types.ts
2 changes: 1 addition & 1 deletion generate_ts_schema_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require('node:fs');
const path = require('node:path');
const { compile } = require('json-schema-to-typescript');

const SOURCE_ROOT = path.resolve(__dirname, 'spec');
const SOURCE_ROOT = path.resolve(__dirname, 'source');
const OUTPUT_FILE = path.resolve(__dirname, './generated/schema-types.ts');
const WRAPPER_NAME = 'SCHEMA_WRAPPER';

Expand Down
Loading