Skip to content

Commit

Permalink
ci: Check consistency of generated files
Browse files Browse the repository at this point in the history
This makes the .github/workflows/check-sourcecode
more a "check-repo" than a "check-sourcecode".
  • Loading branch information
ndim committed Nov 23, 2024
1 parent 5e261cf commit 85ffd50
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/check-sourcecode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,21 @@ jobs:

- name: "Check the sourcecode"
run: ./tools/check-sourcecode

check-generated:
name: "Check Generated Files"
runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v4

- name: Install prerequisites
run: >-
sudo apt-get update
sudo apt-get install -y
asciidoctor
- name: "Verify elf2tag.1 consistency"
run: ./src/update-elf2tag-manpage --ensure-consistency
14 changes: 14 additions & 0 deletions src/update-elf2tag-manpage
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

set -e

ensure_consistency=false
case "$1" in
-h | --help )
${SED-sed} -n '/^#\( .*\)$/,$p' "$0" \
Expand All @@ -32,6 +33,9 @@ case "$1" in
| ${SED-sed} 's|^#$||; s|^# ||'
exit 0
;;
--ensure-consistency )
ensure_consistency=:
;;
esac

cd "$(dirname "$0")"
Expand All @@ -56,6 +60,10 @@ if ! ${ASCIIDOCTOR-asciidoctor} -b manpage -D "$tmpdir" elf2tag.1.adoc; then
fi

if ! test -e elf2tag.1; then
if "$ensure_consistency"; then
echo "Cannot ensure consistency if there is no old elf2tag.1 file"
exit 1
fi
echo "Generate elf2tag.1"
mv -f "$tmpdir/elf2tag.1" elf2tag.1
rmdir "$tmpdir"
Expand All @@ -74,6 +82,12 @@ if ${CMP-cmp} "$tmpdir/elf2tag.1.old" "$tmpdir/elf2tag.1.new" > /dev/null; then
exit 0
fi

if "$ensure_consistency"; then
echo "Error: src/elf2tag.1 is inconsistent with src/elf2tag.1.adoc"
diff -u "$tmpdir/elf2tag.1.old" "$tmpdir/elf2tag.1.new"
exit 1
fi

echo "Updating elf2tag.1"
mv -f "$tmpdir/elf2tag.1" elf2tag.1
rm -f "$tmpdir/elf2tag.1.old"
Expand Down

0 comments on commit 85ffd50

Please sign in to comment.