|
| 1 | +name: schema-drift |
| 2 | +run-name: Schema codegen drift check (${{ github.actor }}) |
| 3 | + |
| 4 | +# Regenerates every schema/CAN artifact from its source (can_packets.csv + |
| 5 | +# can_packets.proto) and fails if the committed artifacts are out of sync. |
| 6 | +# This makes schema / telemetry-signal updates dead-easy: change the source, |
| 7 | +# run the generators, commit — and CI guarantees nothing drifts. |
| 8 | + |
| 9 | +on: |
| 10 | + pull_request: |
| 11 | + types: [opened, synchronize, reopened] |
| 12 | + paths: |
| 13 | + - 'drivers/longhorn-lib/config/**' |
| 14 | + - 'drivers/longhorn-lib/protobuf/**' |
| 15 | + - 'drivers/longhorn-lib/scripts/**' |
| 16 | + - 'telemtry/scripts/**' |
| 17 | + - 'telemtry/stack/ingest/**' |
| 18 | + - 'telemtry/stack/kafka/proto/**' |
| 19 | + - 'telemtry/analysis/database/viewer_tool/prisma/**' |
| 20 | + - 'telemtry/analysis/database/viewer_tool/protobuf/**' |
| 21 | + - 'telemtry/analysis/sql_utils/models.py' |
| 22 | + - 'BEVO/nonhermetic/assets/**' |
| 23 | + - 'BEVO/codegen.py' |
| 24 | + - 'BEVO/generated_mapping.rs' |
| 25 | + - 'BEVO/loggerd/**' |
| 26 | + - 'BEVO/config.rs' |
| 27 | + - '.github/workflows/schema-drift.yml' |
| 28 | + workflow_dispatch: |
| 29 | + |
| 30 | +jobs: |
| 31 | + schema-drift: |
| 32 | + name: Schema codegen drift check |
| 33 | + runs-on: ubuntu-latest |
| 34 | + env: |
| 35 | + PYTHONDONTWRITEBYTECODE: "1" |
| 36 | + steps: |
| 37 | + - name: Checkout |
| 38 | + uses: actions/checkout@v4 |
| 39 | + with: |
| 40 | + fetch-depth: 0 |
| 41 | + |
| 42 | + - name: Set up Python |
| 43 | + uses: actions/setup-python@v5 |
| 44 | + with: |
| 45 | + python-version: "3.11" |
| 46 | + |
| 47 | + - name: Install protoc + python deps |
| 48 | + run: | |
| 49 | + sudo apt-get update |
| 50 | + sudo apt-get install -y protobuf-compiler |
| 51 | + python -m pip install --upgrade pip |
| 52 | + python -m pip install "protobuf>=6,<7" |
| 53 | +
|
| 54 | + - name: Regenerate all schema artifacts from source |
| 55 | + env: |
| 56 | + BUILD_WORKSPACE_DIRECTORY: ${{ github.workspace }} |
| 57 | + run: | |
| 58 | + set -euxo pipefail |
| 59 | + # CSV -> proto (assigns/back-annotates stable proto field ids) |
| 60 | + python3 drivers/longhorn-lib/scripts/update_can_proto.py |
| 61 | + # CSV -> can.json + descriptor + Rust mapping |
| 62 | + bash BEVO/nonhermetic/sync_assets.sh |
| 63 | + # proto -> SQL / Prisma / SQLAlchemy models / dataclasses / sensor.proto |
| 64 | + bash telemtry/scripts/sync_schema.sh Orion |
| 65 | +
|
| 66 | + - name: Fail if regenerated artifacts differ from committed |
| 67 | + run: | |
| 68 | + # sensor_data.desc is a binary protoc intermediate whose bytes vary by |
| 69 | + # protoc version; exclude it and gate only on the deterministic text |
| 70 | + # artifacts (proto, can.json, mapping.rs, SQL, prisma, models, ...). |
| 71 | + if ! git diff --exit-code -- . ':(exclude)BEVO/sensor_data.desc'; then |
| 72 | + { |
| 73 | + echo "### ❌ Schema artifacts are out of sync with their sources" |
| 74 | + echo "" |
| 75 | + echo "A source (\`can_packets.csv\` / \`can_packets.proto\`) changed but the" |
| 76 | + echo "generated artifacts weren't regenerated. Run locally and commit the result:" |
| 77 | + echo "" |
| 78 | + echo '```bash' |
| 79 | + echo 'export BUILD_WORKSPACE_DIRECTORY="$PWD"' |
| 80 | + echo 'python3 drivers/longhorn-lib/scripts/update_can_proto.py' |
| 81 | + echo 'bash BEVO/nonhermetic/sync_assets.sh' |
| 82 | + echo 'bash telemtry/scripts/sync_schema.sh Orion' |
| 83 | + echo '```' |
| 84 | + } >> "$GITHUB_STEP_SUMMARY" |
| 85 | + echo "::error::Generated schema artifacts are out of sync with their sources. See job summary." |
| 86 | + exit 1 |
| 87 | + fi |
| 88 | +
|
| 89 | + loggerd-tests: |
| 90 | + name: BEVO loggerd unit tests |
| 91 | + runs-on: ubuntu-latest |
| 92 | + steps: |
| 93 | + - name: Checkout |
| 94 | + uses: actions/checkout@v4 |
| 95 | + |
| 96 | + - name: Install Rust |
| 97 | + uses: dtolnay/rust-toolchain@stable |
| 98 | + |
| 99 | + - name: Install protoc |
| 100 | + run: | |
| 101 | + sudo apt-get update |
| 102 | + sudo apt-get install -y protobuf-compiler |
| 103 | +
|
| 104 | + - name: Test loggerd (schema-driven CSV header behavior) |
| 105 | + working-directory: BEVO |
| 106 | + env: |
| 107 | + PROTOC: /usr/bin/protoc |
| 108 | + run: cargo test --bin loggerd |
0 commit comments