|
| 1 | +name: Schema Drift |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - ".terraform.lock.hcl" |
| 7 | + - "schemas/**" |
| 8 | + - "scripts/resource_mapping.yml" |
| 9 | + - "scripts/check_schema_drift.py" |
| 10 | + - ".github/workflows/schema-drift.yml" |
| 11 | + push: |
| 12 | + branches: [main] |
| 13 | + paths: |
| 14 | + - ".terraform.lock.hcl" |
| 15 | + - "schemas/**" |
| 16 | + - "scripts/resource_mapping.yml" |
| 17 | + - "scripts/check_schema_drift.py" |
| 18 | + schedule: |
| 19 | + - cron: "0 8 * * 1" # Monday 08:00 UTC — catches upstream provider releases |
| 20 | + |
| 21 | +permissions: |
| 22 | + contents: read |
| 23 | + |
| 24 | +jobs: |
| 25 | + schema-drift: |
| 26 | + name: Schema Drift Check |
| 27 | + runs-on: ubuntu-latest |
| 28 | + |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 31 | + |
| 32 | + - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3 |
| 33 | + with: |
| 34 | + terraform_version_file: .terraform-version |
| 35 | + |
| 36 | + - name: Cache Terraform providers |
| 37 | + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 |
| 38 | + with: |
| 39 | + path: .terraform |
| 40 | + key: terraform-${{ hashFiles('.terraform.lock.hcl') }} |
| 41 | + restore-keys: terraform- |
| 42 | + |
| 43 | + - name: Init (downloads provider binary, no credentials needed) |
| 44 | + run: terraform init -backend=false |
| 45 | + |
| 46 | + - name: Install uv |
| 47 | + uses: astral-sh/setup-uv@v5 |
| 48 | + |
| 49 | + - name: Check schema drift |
| 50 | + id: drift |
| 51 | + run: | |
| 52 | + uv run --with PyYAML scripts/check_schema_drift.py \ |
| 53 | + --mapping scripts/resource_mapping.yml \ |
| 54 | + --schema schemas/v1.json \ |
| 55 | + --terraform-dir . |
| 56 | +
|
| 57 | + - name: Annotate PR on failure |
| 58 | + if: failure() && github.event_name == 'pull_request' |
| 59 | + run: | |
| 60 | + echo "::error::Schema drift detected. Run 'make schema-drift' locally and classify any UNMAPPED fields in scripts/resource_mapping.yml. Add MISSING_FROM_SCHEMA fields to schemas/v1.json." |
0 commit comments