Skip to content

Commit

Permalink
ci: adds git fetch before doing schema checks
Browse files Browse the repository at this point in the history
This fixes the CI errors when doing `make check-source`
steps 'schema-added-check' and 'schema-removed-check'.
These errors prevented CI from performing these steps correctly:

```
fatal: ambiguous argument 'main': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
```

I changed it so that CI does a `git fetch origin` at first and do
the `git diff` against 'origin/master' (which then exist).
Also fixed a bug in the script that was missing $$master in the same line.

Also I added that the script shows the actual diff before failing,
so the user quickly sees whats wrong.
  • Loading branch information
m-schmoock committed Jan 20, 2023
1 parent acfb63e commit b0eea9e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,19 @@ doc/index.rst: $(MANPAGES:=.md)
)

# For CI to (very roughly!) check that we only deprecated fields, or labelled added ones

# So GitHub renamed master to main. This is painful.
# When running on GitHub (CI=true), we need to fetch origin/master
schema-added-check:
@if ! git describe master >/dev/null 2>&1; then MASTER=main; else MASTER=master; fi; if git diff $$MASTER doc/schemas | grep -q '^+.*{' && ! git diff master doc/schemas | grep -q '^+.*"added"'; then echo 'New schema fields must have "added": "vNEXTVERSION"' >&2; exit 1; fi

# So GitHub renamed master to main. This is painful.
@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; \
echo 'New schema fields must have "added": "vNEXTVERSION"' >&2; exit 1; \
fi
schema-removed-check:
@if ! git describe master >/dev/null 2>&1; then MASTER=main; else MASTER=master; fi; if git diff $$MASTER doc/schemas | grep -q '^-.*{' && ! git diff master doc/schemas | grep -q '^-.*"deprecated": "'; then echo 'Schema fields must be deprecated, with version, not removed' >&2; exit 1; fi
@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"'; then \
git diff origin/master -- 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

Expand Down

0 comments on commit b0eea9e

Please sign in to comment.