Skip to content

Commit

Permalink
doc/Makefile: restore CI check for schema changes.
Browse files Browse the repository at this point in the history
We now know the base reference, and we've rebased, so we can do a
simple diff.  Also, this means we can use a magic commit message
`No-schema-diff-check` to suppress false positives.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Jun 4, 2023
1 parent e0d2c39 commit 50a7681
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -227,22 +227,22 @@ doc/index.rst: $(MANPAGES:=.md)
python3 devtools/blockreplace.py doc/index.rst manpages --language=rst --indent " " \
)

# For CI to (very roughly!) check that we only deprecated fields, or labelled added ones
# When running on GitHub (CI=true), we need to fetch origin/master
# Overridden by GH CI if necessary.
BASE_REF=master
schema-added-check:
@if ! test -z $$CI; then git fetch origin master; fi; \
if git diff origin/master -- doc/schemas | grep -q '^+.*{' && ! git diff origin/master -- doc/schemas | grep -q '^+.*"added"'; then \
git diff origin/master -- doc/schemas; \
if git show --format=%B -s $(BASE_REF).. | grep -q '^No-schema-diff-check'; then echo $@ suppressed; exit 0; fi; \
if git diff $(BASE_REF) -- doc/schemas | grep -q '^+.*{' && ! git diff $(BASE_REF) -- doc/schemas | grep -q '^+.*"added"'; then \
git diff $(BASE_REF) -- doc/schemas; \
echo 'New schema fields must have "added": "vNEXTVERSION"' >&2; exit 1; \
fi

schema-removed-check:
@if ! test -z $$CI; then git fetch origin master; fi; \
if git diff origin/master -- doc/schemas | grep -q '^-.*{' && ! git diff origin/master -- doc/schemas | grep -q '^-.*"deprecated"' && ! git diff origin/master -- doc/schemas | grep -q '^-.*EXPERIMENTAL_FEATURES'; then \
git diff origin/master -- doc/schemas ; \
if git show --format=%B -s $(BASE_REF).. | grep -q '^No-schema-diff-check'; then echo $@ suppressed; exit 0; fi; \
if git diff $(BASE_REF) -- doc/schemas | grep -q '^-.*{' && ! git diff $(BASE_REF) -- doc/schemas | grep -q '^-.*"deprecated"' && ! git diff $(BASE_REF) -- doc/schemas | grep -q '^-.*EXPERIMENTAL_FEATURES'; then \
git diff $(BASE_REF) -- doc/schemas ; \
echo 'Schema fields must be "deprecated", with version, not removed' >&2; exit 1; \
fi

schema-diff-check: schema-added-check schema-removed-check

# This breaks current commit; will revert after.
#check-source: schema-diff-check
check-source: schema-diff-check

0 comments on commit 50a7681

Please sign in to comment.