name: Validate JSON Schema on: pull_request: paths: - "config-schema.json" - "config.example.yaml" - ".github/workflows/config-schema.yml" push: branches: - main paths: - "config-schema.json" - "config.example.yaml" - ".github/workflows/config-schema.yml" workflow_dispatch: jobs: validate-schema: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2 - name: Validate JSON Schema run: | # Check if the file is valid JSON if ! jq empty config-schema.json 2>/dev/null; then echo "Error: config-schema.json is not valid JSON" exit 1 fi # Validate that it's a valid JSON Schema # Check for required $schema field if ! jq -e '."$schema"' config-schema.json > /dev/null; then echo "Warning: config-schema.json should have a \$schema field" fi # Check that it has either properties or definitions if ! jq -e '.properties or .definitions or ."$defs"' config-schema.json > /dev/null; then echo "Warning: JSON Schema should contain properties, definitions, or \$defs" fi echo "✓ config-schema.json is valid" - name: Set up Go uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c #6.4.0 with: go-version-file: go.mod - name: Validate config.example.yaml against schema run: go test ./internal/config/ -run TestConfig_ExampleMatchesSchema -v