chore(deps): update dependency renovate to v39.70.0 #251
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: validate renovate | |
on: | |
pull_request: | |
paths: | |
- 'renovate.json' | |
- '.github/workflows/validate-renovate.yml' | |
permissions: | |
contents: read | |
pull-requests: write | |
jobs: | |
lint: | |
name: run renovate-config-validator | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: run lint and report | |
env: | |
URL: ${{ github.event.pull_request.html_url }} | |
GH_TOKEN: ${{ github.token }} | |
# renovate: npm:renovate | |
RENOVATE_VERSION: '39.70.0' | |
run: | | |
# pinned on exact version | |
package="renovate@=$RENOVATE_VERSION" | |
echo "npx: $(npx --version)" | |
echo "installing: $package..." | |
export H="$(mktemp)" | |
se="$(mktemp)" | |
echo '{' >> "$H" | |
js_output_temp="$(mktemp)" | |
npx --yes --package "$package" -- renovate-config-validator --strict >"$js_output_temp" || true | |
if grep -e "^ERROR: Found errors in configuration" "$js_output_temp"; then | |
# hard error | |
# TODO: collect this as JSON, and display it in more structured way | |
lf=$'\n' | |
{ | |
echo '```' | |
echo "Error(s) has been occurred: ${lf}$(cat "$js_output_temp")" | |
echo '```' | |
} | gh pr comment -F - "${URL}" | |
exit 1 | |
fi | |
# let's do main part, but avoid pipefail for soft-error about migration | |
ruby -e 'File.open(ENV[?H], ?a) {|r| while gets; puts $_; $> = r if $_.strip == "WARN: Config migration necessary" ;end; }' <"$js_output_temp" | |
echo '}' >> "$H" | |
# exit early if migration is not required | |
if [ "$(stat -c %s "$H")" -le 4 ]; then | |
echo 'Migration is unnecessary, exiting (early)' | |
exit 0 | |
fi | |
echo "---" | |
echo "Collected output: $H" | |
cat "$H" | |
echo "---" | |
# init and extract | |
OLD="$(mktemp)" | |
mv "$OLD" "${OLD}.old.txt" | |
NEW="$(mktemp)" | |
mv "$NEW" "${NEW}.new.txt" | |
echo "extracting fields" | |
jq -r '.oldConfig' < "$H" > "${OLD}.old.txt" | |
jq -r '.newConfig' < "$H" > "${NEW}.new.txt" | |
DIFF_TO_BE_REPORTED="$(mktemp)" | |
mv "$DIFF_TO_BE_REPORTED" "${DIFF_TO_BE_REPORTED}.diff" | |
echo "computing diff" | |
# fold into $?=0 even if they are different: | |
# > This form implies --exit-code | |
GIT_TRACE=1 git diff --no-index "$OLD.old.txt" "$NEW.new.txt" >> "${DIFF_TO_BE_REPORTED}.diff" || true | |
diff_size="$(stat -c %s "${DIFF_TO_BE_REPORTED}.diff")" | |
echo "Diff size: $diff_size" | |
if [ "$diff_size" -eq 0 ]; then | |
echo 'Migration is unnecessary, exiting (late)' | |
exit 0 | |
fi | |
COMMENT_BUFFER="$(mktemp)" | |
sep='EOS_SOMEWHAT_DUMMY_LINES' | |
{ | |
echo 'I am sorry, but this config should be migrated. Please apply following command in repository root directory to proceed:' | |
# header | |
echo '```sh' | |
echo '#!/bin/sh' | |
# make temporary | |
# shellcheck disable=SC1078 | |
echo 'd="$(mktemp)"' | |
# patch body to temporary file: | |
# cat << $sep | |
# ${DIFF_TO_BE_REPORTED}.diff | |
# $sep > "$d" | |
printf 'cat > "%s"' '$d' | |
printf ' <<' | |
printf '%s\n' "$sep" | |
cat "${DIFF_TO_BE_REPORTED}.diff" | |
printf "$sep" | |
printf '\n' | |
# apply patch | |
echo 'patch -p1 renovate.json < "$d"' | |
# close code-block | |
echo '```' | |
echo | |
echo '<details>' | |
echo | |
echo '<summary>Patch</summary>' | |
echo | |
echo '```patch' | |
cat "${DIFF_TO_BE_REPORTED}.diff" | |
echo '```' | |
echo | |
echo '</details>' | |
} >> "$COMMENT_BUFFER" | |
echo '--- [DEBUG] REPORTER ---' | |
cat "$COMMENT_BUFFER" | |
echo '------------------------' | |
gh pr comment -F "$COMMENT_BUFFER" "${URL}" | |
exit 1 |