mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-11-20 15:52:12 +01:00
ci: review fixes for the release job and set_version.sh
- set_version.sh: three of its four patterns only matched digits and dots, so FW_VERSION and index.js stayed at v4.0.0.beta and index.html at ?v=3.0.14d. They now match any version, and the script fails when a file doesn't end up with the new one. test/scripts/test_set_version.sh covers it and runs with the native tests. - Release job: each build's files are collected from its own folder, with 4 files each and no name in two builds, before they're signed. The version bump is made on the release's branch as it is now, not the tag, so a merge during the builds doesn't reject the push. - Scorecard reports to code scanning only: publishing from a fork isn't supported, so no badge. - New workflows renamed to .yaml like build.yaml. SECURITY.md: the routes open in Secured mode, and which jobs can write what. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5c57d1a2cd
commit
787cebdb18
9 changed files with 124 additions and 18 deletions
64
test/scripts/test_set_version.sh
Normal file
64
test/scripts/test_set_version.sh
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#!/usr/bin/env bash
|
||||
# Tests .github/set_version.sh on copies of the real files:
|
||||
# bash test/scripts/test_set_version.sh
|
||||
set -uo pipefail
|
||||
|
||||
REPO="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
FILES=(src/ConfigSettings.h data-src/appversion data-src/index.html data-src/index.js)
|
||||
failures=0
|
||||
|
||||
fail() { echo "FAIL: $1"; failures=$((failures + 1)); }
|
||||
|
||||
# A fresh copy of the four files in a temp dir, which becomes the cwd.
|
||||
fresh() {
|
||||
WORK="$(mktemp -d)"
|
||||
for f in "${FILES[@]}"; do
|
||||
mkdir -p "$WORK/$(dirname "$f")"
|
||||
cp "$REPO/$f" "$WORK/$f"
|
||||
done
|
||||
cd "$WORK"
|
||||
}
|
||||
|
||||
run() { bash "$REPO/.github/set_version.sh" "$1" >/dev/null 2>&1; }
|
||||
|
||||
has() { grep -qF -- "$2" "$1" || fail "$3: $1 lacks $2"; }
|
||||
|
||||
# Every version string in the sources today gets the new version.
|
||||
for tag in v4.0.2 v4.1.0.beta v5.0.0-rc1; do
|
||||
fresh
|
||||
v="${tag#v}"
|
||||
run "$tag" || fail "$tag: exited non-zero"
|
||||
has src/ConfigSettings.h "#define FW_VERSION \"v$v\"" "$tag"
|
||||
[[ "$(cat data-src/appversion)" == "$v" ]] || fail "$tag: appversion is $(cat data-src/appversion)"
|
||||
has data-src/index.html "?v=${v}c" "$tag"
|
||||
has data-src/index.js "appVersion = 'v$v'" "$tag"
|
||||
# No old version left behind in index.html's links.
|
||||
if grep -o '?v=[^"'"'"']*' data-src/index.html | grep -vqxF "?v=${v}c"; then
|
||||
fail "$tag: index.html keeps an old ?v="
|
||||
fi
|
||||
done
|
||||
|
||||
# Running it twice with the same tag still passes its own check.
|
||||
fresh
|
||||
run v4.0.2 && run v4.0.2 || fail "a second run with the same tag failed"
|
||||
|
||||
# Tags that aren't versions are rejected and nothing is written.
|
||||
for tag in "v1/2" "v4.0;rm" "v4.0&" "" "vx.y" "v4..0"; do
|
||||
fresh
|
||||
if run "$tag"; then fail "accepted '$tag'"; fi
|
||||
for f in "${FILES[@]}"; do
|
||||
cmp -s "$REPO/$f" "$f" || fail "'$tag' changed $f"
|
||||
done
|
||||
done
|
||||
|
||||
# A file whose version string changed shape fails loudly instead of
|
||||
# silently keeping the old version.
|
||||
fresh
|
||||
sed -i 's/#define FW_VERSION/#define FIRMWARE_VERSION/' src/ConfigSettings.h
|
||||
if run v4.0.2; then fail "passed with no FW_VERSION line"; fi
|
||||
|
||||
if ((failures)); then
|
||||
echo "$failures failure(s)"
|
||||
exit 1
|
||||
fi
|
||||
echo "set_version.sh: all passed"
|
||||
Loading…
Add table
Add a link
Reference in a new issue