|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# This scripts runs Renovate locally to validate renovate.json5 configuration file |
| 4 | +# It generates the folloing files: |
| 5 | +# - `renovate.out` With the raw debug output of the run. |
| 6 | +# - `update-proposals.json` with the list of proposed updates but INCLUDING DISABLED ones |
| 7 | +# - `final-updated-packages.txt` with the list of packages with updates in the resulting PRs (considering disabled/enabled). |
| 8 | +# |
| 9 | +# WARNING: If the script is terminated before restoring the extension source (step 2), make sure you revert |
| 10 | +# the changes to renovate.json5 manually. |
| 11 | + |
| 12 | +## (1) Check config syntax |
| 13 | +npx --yes --package renovate -- renovate-config-validator renovate.json5 || exit 1 |
| 14 | + |
| 15 | +## (2) Temporarily change the renovate.json5 to point to the local extension source |
| 16 | +sed -i 's/local>PeerDB-io/github>PeerDB-io/' renovate.json5 |
| 17 | + |
| 18 | +function cleanup { |
| 19 | + echo "Restoring renovate.json5 to point to the GitHub extension source" |
| 20 | + sed -i 's/github>PeerDB-io/local>PeerDB-io/' renovate.json5 |
| 21 | +} |
| 22 | +trap cleanup EXIT |
| 23 | + |
| 24 | +## (3) Run Renovate locally |
| 25 | +echo "Running Renovate locally..." |
| 26 | +LOG_LEVEL=debug npx renovate --platform=local --require-config=optional --repository-cache=reset > renovate.out |
| 27 | + |
| 28 | +## (4) Extract update proposals |
| 29 | +cat renovate.out | sed '1,/packageFiles with updates/d' | sed 's/"config": {/{/' | sed '/DEBUG/,$d' | jq '.gomod[].deps[]' > update-proposals.json |
| 30 | + |
| 31 | +## (5) Extract final updated packages |
| 32 | +cat renovate.out | grep 'flattened updates found' | tr ',' '\n' > final-updated-packages.txt |
| 33 | + |
| 34 | +echo "List of packages with proposed updates:" |
| 35 | +echo "----------------------------------------" |
| 36 | +cat final-updated-packages.txt |
0 commit comments