@@ -165,6 +165,30 @@ $(BUILD)/go_mod_check: go.mod internal/tools/go.mod
165165 $Q ./scripts/check-gomod-version.sh go.uber.org/thriftrw $(if $(verbose ) ,-v)
166166 $Q touch $@
167167
168+ # checks that the idl submodule points to a commit on master, and that it matches the go module (which must be a pseudo version).
169+ # this is only used in an explicit CI step, because it's expected to fail when developing.
170+ #
171+ # `git ls-tree HEAD idls` is selected because this only cares about the committed/checked-out target,
172+ # not whatever the current status is, because only the committed value will exist for others.
173+ #
174+ # and last but not least: this avoids using `go` to make this check take only a couple seconds in CI,
175+ # so the whole docker container doesn't have to be prepared.
176+ .idl-status :
177+ $(Q ) cd idls && \
178+ SUBMODULE_COMMIT=$$(git rev-parse HEAD ) && \
179+ BRANCH_INFO=$$(git branch -r --contains "$$SUBMODULE_COMMIT" | head -n1 ) && \
180+ if ! git branch -r --contains " $$ SUBMODULE_COMMIT" | grep -q " origin/master" ; then \
181+ echo " Error: Submodule commit $$ SUBMODULE_COMMIT belongs to $$ BRANCH_INFO, not to master branch" && \
182+ exit 1; \
183+ fi
184+ $(Q ) idlsha=$$(git ls-tree HEAD idls | awk '{print substr($$3,0,12 ) }' ) && \
185+ gosha=$$(grep github.com/uber/cadence-idl go.mod | tr '-' '\n' | tail -n1 ) && \
186+ if [[ " $$ idlsha" != " $$ gosha" ]]; then \
187+ echo " IDL submodule sha ($$ idlsha) does not match go module sha ($$ gosha)." >&2 && \
188+ echo " Make sure the IDL PR has been merged, and this PR is updated, before merging here." >&2 && \
189+ exit 1; \
190+ fi
191+
168192# ====================================
169193# Codegen targets
170194# ====================================
0 commit comments