name: cereal validation on: push: branches: - master pull_request: paths: - 'openpilot/cereal/**' workflow_dispatch: workflow_call: inputs: run_number: default: '1' required: true type: string concurrency: group: cereal-validation-ci-run-${{ inputs.run_number }}-${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && github.run_id || github.head_ref || github.ref }}-${{ github.workflow }}-${{ github.event_name }} cancel-in-progress: true env: CI: 1 jobs: validate_cereal_with_upstream: name: Validate cereal with Upstream runs-on: ubuntu-24.04 steps: - name: Checkout sunnypilot cereal uses: actions/checkout@v6 with: sparse-checkout: | openpilot/cereal uv.lock submodules: false - name: Init sunnypilot opendbc submodule run: git submodule update --init --depth 1 opendbc_repo - name: Locate sunnypilot capnp import paths id: locate-sp-capnp run: | SP_IMPORT_ARGS="" SP_CAR_CAPNP=$(find opendbc_repo -maxdepth 4 -name car.capnp -path '*/opendbc/car/car.capnp' -printf '%h\n' -quit) if [ -n "$SP_CAR_CAPNP" ]; then SP_IMPORT_ARGS="-I $SP_CAR_CAPNP" echo "Found sunnypilot car.capnp at: $SP_CAR_CAPNP" fi echo "import_args=$SP_IMPORT_ARGS" >> "$GITHUB_OUTPUT" - name: Checkout upstream openpilot uses: actions/checkout@v6 with: repository: 'commaai/openpilot' path: upstream_openpilot ref: "refs/heads/master" - name: Init upstream opendbc submodule working-directory: upstream_openpilot run: git submodule update --init --depth 1 opendbc_repo - name: Locate upstream capnp paths id: locate-capnp run: | CEREAL_DIR=$(find upstream_openpilot -maxdepth 4 -name log.capnp -path '*/cereal/log.capnp' -printf '%h\n' -quit) if [ -z "$CEREAL_DIR" ]; then echo "::error::Could not locate cereal/log.capnp in upstream openpilot" exit 1 fi echo "cereal_dir=$CEREAL_DIR" >> "$GITHUB_OUTPUT" echo "Found upstream cereal at: $CEREAL_DIR" IMPORT_ARGS="" CAR_CAPNP=$(find upstream_openpilot -maxdepth 5 -name car.capnp -path '*/opendbc/car/car.capnp' -printf '%h\n' -quit) if [ -n "$CAR_CAPNP" ]; then IMPORT_ARGS="-I $CAR_CAPNP" echo "Found car.capnp at: $CAR_CAPNP" fi echo "import_args=$IMPORT_ARGS" >> "$GITHUB_OUTPUT" - name: Install pycapnp run: | PYCAPNP_VER=$(python3 -c "import re; m=re.search(r'name = \"pycapnp\"\nversion = \"([^\"]+)\"', open('uv.lock').read()); print(m.group(1))") pip install "pycapnp==${PYCAPNP_VER}" - name: Generate sunnypilot schema run: | python3 openpilot/cereal/messaging/tests/validate_sp_cereal_upstream.py \ -g -f /tmp/sp_schema.json --cereal-dir openpilot/cereal \ ${{ steps.locate-sp-capnp.outputs.import_args }} - name: Validate against upstream run: | python3 openpilot/cereal/messaging/tests/validate_sp_cereal_upstream.py \ -r -f /tmp/sp_schema.json --cereal-dir ${{ steps.locate-capnp.outputs.cereal_dir }} \ ${{ steps.locate-capnp.outputs.import_args }}