Skip to content

Commit f85a584

Browse files
committed
ci: Check consistency of generated files
This makes the .github/workflows/check-sourcecode more a "check-repo" than a "check-sourcecode".
1 parent eddb0d0 commit f85a584

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

.github/workflows/check-sourcecode.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,21 @@ jobs:
2222

2323
- name: "Check the sourcecode"
2424
run: ./tools/check-sourcecode
25+
26+
check-generated:
27+
name: "Check Generated Files"
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
32+
- uses: actions/checkout@v4
33+
34+
- name: Install prerequisites
35+
run: >-
36+
sudo apt-get update
37+
38+
sudo apt-get install -y
39+
asciidoctor
40+
41+
- name: "Verify elf2tag.1 consistency"
42+
run: ./src/update-elf2tag-manpage --verify

src/update-elf2tag-manpage

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,26 @@
44
#
55
# Usage:
66
# ./path/to/update-elf2tag-manpage
7+
# ./path/to/update-elf2tag-manpage --verify
78
#
8-
# Changes into the directory where update-elf2tag-manpage and
9-
# elf2tag.1.adoc are, runs asciidoctor to produce a man page elf2tag.1
10-
# from elf2tag.1.adoc, but only updates the elf2tag.1 file in the case
11-
# of actual changes.
9+
# Without a command line argument given, changes into the directory
10+
# where update-elf2tag-manpage and elf2tag.1.adoc are, runs
11+
# asciidoctor to produce a man page elf2tag.1 from elf2tag.1.adoc, but
12+
# only updates the elf2tag.1 file in the case of actual changes.
1213
#
1314
# Just the asciidoctor version or the current date being different
1415
# from the last asciidoctor run is not considered an actual change.
1516
#
17+
# With the --verify argument given, only verify that elf2tag.1 and
18+
# elf2tag.1.adoc are consistent with each other, i.e. elf2tag.1 would
19+
# not be changed.
20+
#
1621
# Requires asciidoctor to be installed.
1722
#
1823
# Environment variables used (if unset, uses the command from PATH):
1924
# ASCIIDOCTOR the asciidoctor command to run
2025
# CMP the cmp command to run (e.g. "busybox cmp")
26+
# DIFF the diff command to run with -u (used with --verify only)
2127
# SED the sed command to run (e.g. "busybox sed")
2228

2329
# This script uses the shell feature called "process substitution" which
@@ -33,6 +39,7 @@ if test "$#" -gt 1; then
3339
exit 2
3440
fi
3541

42+
verify=false
3643
if test "$#" -eq 1; then
3744
case "$1" in
3845
-h | --help )
@@ -42,6 +49,9 @@ if test "$#" -eq 1; then
4249
| ${SED-sed} 's|^#$||; s|^# ||'
4350
exit 0
4451
;;
52+
--verify )
53+
verify=:
54+
;;
4555
* )
4656
echo "$prog: Unhandled command line argument."
4757
exit 2
@@ -89,6 +99,11 @@ else
8999
fi
90100

91101
if ! test -e elf2tag.1; then
102+
if "$verify"; then
103+
echo "$prog: Cannot ensure consistency if there is no old elf2tag.1 file"
104+
rm -rf "$tmpdir"
105+
exit 1
106+
fi
92107
echo "$prog: Generate elf2tag.1"
93108
mv -f "$tmpdir/elf2tag.1" elf2tag.1
94109
rmdir "$tmpdir"
@@ -107,6 +122,16 @@ if ${CMP-cmp} "$tmpdir/elf2tag.1.norm-old" "$tmpdir/elf2tag.1.norm-new" > /dev/n
107122
exit 0
108123
fi
109124

125+
if "$verify"; then
126+
echo "$prog: Error: src/elf2tag.1 is inconsistent with src/elf2tag.1.adoc"
127+
${DIFF-diff} -u "$tmpdir/elf2tag.1.norm-old" "$tmpdir/elf2tag.1.norm-new" ||:
128+
rm -f "$tmpdir/elf2tag.1"
129+
rm -f "$tmpdir/elf2tag.1.norm-old"
130+
rm -f "$tmpdir/elf2tag.1.norm-new"
131+
rmdir "$tmpdir"
132+
exit 1
133+
fi
134+
110135
echo "Updating elf2tag.1"
111136
mv -f "$tmpdir/elf2tag.1" elf2tag.1
112137
rm -f "$tmpdir/elf2tag.1.norm-old"

0 commit comments

Comments
 (0)