[CI/CD] A more robust logic to regenerate components.json.gz.

We shouldn't rely on `git diff`. Even when the underlying source code
hasn't changed, and the cache is dumped with `sort_keys=True`, some of
the generated snippets of docstrings may change, leading the CI/CD
pipeline to get stuck in a push loop.

We should instead look for changes to the plugins, backends, events and
schemas folders before and after the CI/CD trigger to infer if we need
to regenerate the file.
This commit is contained in:
Fabio Manganiello 2024-01-06 23:42:59 +01:00
parent e803807b8d
commit 1ff8cfd240
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -278,7 +278,17 @@ steps:
- |
[ -f "$SKIPCI" ] && exit 0
- apk add --update --no-cache $(cat platypush/install/requirements/alpine.txt)
# Only regenerate the components cache if either the plugins, backends,
# events or schemas folders have some changes (excluding the webapp files).
- apk add --update --no-cache git
- |
if [ -z "$(git log --pretty=oneline $DRONE_COMMIT_AFTER...$DRONE_COMMIT_BEFORE -- platypush/backend platypush/plugins platypush/schemas platypush/message/event ':(exclude)platypush/backend/http/webapp')" ]; then
echo 'No changes to the components file'
exit 0
fi
- echo 'Updating components cache'
- apk add --update --no-cache bash gnupg openssh $(cat platypush/install/requirements/alpine.txt)
- pip install . --break-system-packages
- |
python - <<EOF
@ -287,13 +297,6 @@ steps:
get_plugin('inspect').refresh_cache(force=True)
EOF
- apk add --update --no-cache git
- |
if [ -z "$(git status "$CACHEFILE" --porcelain)" ]; then
echo 'No changes to the components file'
exit 0
fi
# Backup the original git configuration before changing attributes
- export GIT_CONF=$PWD/.git/config
- export TMP_GIT_CONF=/tmp/git.config.orig
@ -304,7 +307,6 @@ steps:
# (we're going to do another push anyway, so another pipeline will be triggered)
- touch "$SKIPCI"
- apk add --update --no-cache bash gnupg openssh
- mkdir -p ~/.ssh
- |
cat <<EOF | gpg --import --armor