Skip to content

protocol-contracts

protocol-contracts #68

name: protocol-contracts
on:
pull_request:
paths:
- "buf.yaml"
- "crates/zinder-client/src/**"
- "crates/zinder-client/tests/integration/capability_coverage.rs"
- "crates/zinder-proto/proto/**"
- "crates/zinder-proto/src/capabilities.rs"
- ".github/workflows/protocol-contracts.yml"
push:
branches:
- main
paths:
- "buf.yaml"
- "crates/zinder-client/src/**"
- "crates/zinder-client/tests/integration/capability_coverage.rs"
- "crates/zinder-proto/proto/**"
- "crates/zinder-proto/src/capabilities.rs"
- ".github/workflows/protocol-contracts.yml"
workflow_dispatch:
permissions:
contents: read
env:
BUF_VERSION: "1.68.2"
CARGO_TERM_COLOR: always
PROTOC_VERSION: "29.3"
jobs:
proto-breaking:
name: proto breaking
if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'allow-proto-breaking')
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install Buf
uses: bufbuild/buf-setup-action@v1
with:
version: ${{ env.BUF_VERSION }}
- name: Check native protobuf compatibility
run: |
set -euo pipefail
base_ref="${GITHUB_BASE_REF:-main}"
against_config="$(cat <<'YAML'
version: v2
modules:
- path: crates/zinder-proto/proto
excludes:
- crates/zinder-proto/proto/compat
- crates/zinder-proto/proto/external
breaking:
use:
- PACKAGE
YAML
)"
# buf's `.git#branch` reads a local branch ref; pull_request checkouts
# are detached with the base only under refs/remotes, so materialize it.
git rev-parse --verify --quiet "refs/heads/${base_ref}" >/dev/null \
|| git branch "${base_ref}" "origin/${base_ref}"
buf lint
buf breaking \
--against ".git#branch=${base_ref}" \
--against-config "${against_config}"
capability-coverage:
name: capability coverage
if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'allow-capability-drift')
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@1.95.0
- name: Install protoc
uses: arduino/setup-protoc@v3
with:
version: ${{ env.PROTOC_VERSION }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Cache Cargo
uses: Swatinem/rust-cache@v2.9.1
- name: Check ChainIndex capability coverage
run: cargo test -p zinder-client typed_chain_index_covers_every_advertised_wallet_capability