Skip to content

Reject multiple rows when the protobuf cannot represent groups #48

Reject multiple rows when the protobuf cannot represent groups

Reject multiple rows when the protobuf cannot represent groups #48

name: Validate cre-sdk-go version
on:
push:
branches:
- capabilities-development
pull_request:
branches:
- capabilities-development
jobs:
validate-sdk-version:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Checkout cre-sdk-go
uses: actions/checkout@v6
with:
repository: smartcontractkit/cre-sdk-go
ref: capabilities-development
path: .cre-sdk-go
fetch-depth: 0
persist-credentials: false
- name: Validate cre-sdk-go versions are from capabilities-development
run: |
failed=0
found=0
# Find all lines in the root go.mod that depend on any cre-sdk-go module.
while IFS= read -r line; do
mod=$(echo "$line" | awk '{print $1}')
echo " parsed module: $mod"
version=$(echo "$line" | awk '{print $2}')
echo " parsed version: $version"
found=1
# Pseudo-versions have 3 parts separated by "-" and end with a 12-char hex commit hash.
# e.g. "v0.0.0-20260420204255-a3f3bdd56877" -> "a3f3bdd56877"
# Tagged versions like "v1.9.0-capdev.1" don't match this pattern.
suffix=${version##*-}
if [[ "$suffix" =~ ^[0-9a-f]{12}$ ]]; then
# Pseudo-version: use the commit hash directly.
commit="$suffix"
echo " parsed commit (pseudo-version): $commit"
else
# Tagged version: resolve the tag to a commit.
# The module path prefix (github.com/smartcontractkit/cre-sdk-go) maps to the
# repo root; any sub-module suffix becomes a tag prefix.
# e.g. module "github.com/smartcontractkit/cre-sdk-go/capabilities/blockchain/evm"
# with version "v1.0.0-beta.10-capdev.1" -> tag "capabilities/blockchain/evm/v1.0.0-beta.10-capdev.1"
subpath=${mod#github.com/smartcontractkit/cre-sdk-go}
subpath=${subpath#/}
if [[ -n "$subpath" ]]; then
tag="${subpath}/${version}"
else
tag="${version}"
fi
echo " resolved tag: $tag"
commit=$(git -C .cre-sdk-go rev-list -n1 "$tag" 2>/dev/null || true)
if [[ -z "$commit" ]]; then
echo "::error::$mod tag $tag not found in cre-sdk-go"
failed=1
continue
fi
echo " resolved commit: $commit"
fi
echo "Checking module=$mod version=$version commit=$commit"
# Verify the commit is reachable from capabilities-development.
if ! git -C .cre-sdk-go merge-base --is-ancestor "$commit" capabilities-development 2>/dev/null; then
echo "::error::$mod commit $commit is NOT on the capabilities-development branch of cre-sdk-go"
failed=1
else
echo "OK: $mod commit $commit is on capabilities-development"
fi
done < <(grep 'github.com/smartcontractkit/cre-sdk-go' go.mod | grep -v '^//')
if [[ "$found" -eq 0 ]]; then
echo "::error::No cre-sdk-go dependencies found in go.mod"
exit 1
fi
if [[ "$failed" -eq 1 ]]; then
echo ""
echo "One or more cre-sdk-go dependencies reference a commit not on capabilities-development."
exit 1
fi
echo ""
echo "All cre-sdk-go versions are from capabilities-development."