|
| 1 | +# Validates that PRs don't introduce unintentional casing changes to type/enum names, |
| 2 | +# members, or properties in CSDL schema files. After a PR merges, automatically |
| 3 | +# regenerates the type-mapping baseline files to keep them current. |
| 4 | + |
| 5 | +name: Check type and enum casing changes |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: [ master ] |
| 10 | + paths: |
| 11 | + - 'schemas/*-Prod.csdl' |
| 12 | + pull_request: |
| 13 | + branches: [ master ] |
| 14 | + paths: |
| 15 | + - 'schemas/*-Prod.csdl' |
| 16 | + |
| 17 | +jobs: |
| 18 | + # Runs on PRs: compares modified CSDL files against the committed type-mapping |
| 19 | + # JSON baselines. Fails if any name matches case-insensitively but differs |
| 20 | + # case-sensitively (e.g., "accessLevel" -> "AccessLevel"). New types are allowed. |
| 21 | + check-casing: |
| 22 | + if: github.event_name == 'pull_request' |
| 23 | + runs-on: ubuntu-latest |
| 24 | + |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v6 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + |
| 30 | + - name: Determine modified Prod CSDL files |
| 31 | + id: changed-files |
| 32 | + run: | |
| 33 | + FILES=$(git diff --diff-filter=ACMR --name-only origin/${{ github.base_ref }}...HEAD -- 'schemas/*-Prod.csdl' | tr '\n' ',' | sed 's/,$//') |
| 34 | + echo "files=$FILES" >> $GITHUB_OUTPUT |
| 35 | + echo "Modified CSDL files: $FILES" |
| 36 | +
|
| 37 | + - name: Check for casing changes |
| 38 | + if: steps.changed-files.outputs.files != '' |
| 39 | + shell: pwsh |
| 40 | + run: | |
| 41 | + $files = "${{ steps.changed-files.outputs.files }}" -split ',' |
| 42 | + ./scripts/check-casing-changes.ps1 -CsdlFiles $files |
| 43 | +
|
| 44 | + # Runs on push to master (after PR merge): regenerates the type-mapping baseline |
| 45 | + # JSON files from the updated CSDL schemas and auto-commits them if changed. |
| 46 | + # This keeps baselines current so future PRs are checked against the latest state. |
| 47 | + update-baselines: |
| 48 | + if: github.event_name == 'push' |
| 49 | + runs-on: ubuntu-latest |
| 50 | + permissions: |
| 51 | + contents: write |
| 52 | + |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v6 |
| 55 | + |
| 56 | + - name: Regenerate type mapping baselines |
| 57 | + shell: pwsh |
| 58 | + run: ./scripts/generate-type-mappings.ps1 |
| 59 | + |
| 60 | + - name: Check for changes |
| 61 | + id: check-changes |
| 62 | + run: | |
| 63 | + if git diff --quiet schemas/type-mappings/; then |
| 64 | + echo "changed=false" >> $GITHUB_OUTPUT |
| 65 | + echo "No baseline changes detected." |
| 66 | + else |
| 67 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 68 | + echo "Baseline changes detected." |
| 69 | + fi |
| 70 | +
|
| 71 | + - name: Commit updated baselines |
| 72 | + if: steps.check-changes.outputs.changed == 'true' |
| 73 | + run: | |
| 74 | + git config user.name "github-actions[bot]" |
| 75 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 76 | + git add schemas/type-mappings/ |
| 77 | + git commit -m "Update type mapping baselines |
| 78 | +
|
| 79 | + Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>" |
| 80 | + git push |
0 commit comments