|
name: test |
|
|
|
on: |
|
push: |
|
pull_request: |
|
|
|
jobs: |
|
shellcheck: |
|
runs-on: ubuntu-latest |
|
steps: |
|
- uses: actions/checkout@v4 |
|
- name: Install shellcheck |
|
run: sudo apt-get update && sudo apt-get install -y shellcheck |
|
- name: Lint |
|
run: | |
|
shellcheck bin/jenny \ |
|
share/jenny/lib/*.sh \ |
|
share/jenny/layout/*.sh \ |
|
test/*.sh test/lib/*.bash |
|
|
|
test-linux: |
|
runs-on: ubuntu-latest |
|
steps: |
|
- uses: actions/checkout@v4 |
|
- name: Install xmllint |
|
run: sudo apt-get update && sudo apt-get install -y libxml2-utils |
|
- name: Run the suite |
|
run: test/run.sh |
|
|
|
# mawk is stricter than gawk about dynamic regexes -- the P0-1 crash only |
|
# reproduces here -- so the parser is exercised against both. |
|
test-mawk: |
|
runs-on: ubuntu-latest |
|
steps: |
|
- uses: actions/checkout@v4 |
|
- name: Install mawk and xmllint |
|
run: sudo apt-get update && sudo apt-get install -y mawk libxml2-utils |
|
- name: Run the suite with mawk as awk |
|
run: | |
|
sudo update-alternatives --set awk /usr/bin/mawk |
|
awk -W version 2>&1 | head -1 || true |
|
test/run.sh |
|
|
|
# The whole point of the $SED/$AWK/$DATE indirection. Nothing verified it |
|
# before this workflow existed. |
|
test-macos: |
|
runs-on: macos-latest |
|
steps: |
|
- uses: actions/checkout@v4 |
|
- name: Install GNU utils |
|
run: brew install gawk gnu-sed grep coreutils |
|
- name: Run the suite |
|
run: | |
|
export PATH="$(brew --prefix)/bin:$PATH" |
|
test/run.sh |
|
|
|
# macOS ships bash 3.2, so the suite must not rely on bash 4+ syntax. |
|
bash32: |
|
runs-on: macos-latest |
|
steps: |
|
- uses: actions/checkout@v4 |
|
- name: Report the system bash version |
|
run: /bin/bash --version | head -1 |
|
- name: Syntax-check every script under bash 3.2 |
|
run: | |
|
for f in bin/jenny share/jenny/lib/*.sh share/jenny/layout/*.sh \ |
|
test/*.sh test/lib/*.bash; do |
|
/bin/bash -n "$f" || exit 1 |
|
done |
|
- name: Run the suite under the system bash |
|
run: | |
|
brew install gawk gnu-sed grep coreutils |
|
export PATH="$(brew --prefix)/bin:$PATH" |
|
/bin/bash test/run.sh |
|
|
|
# Exercises the custom-layout and migration paths, which the other legs do |
|
# not: they build with the shipped layouts and the vendored parser. |
|
# |
|
# The fixture is committed rather than cloned from a real blog, so this job |
|
# cannot break because somebody else pushed. Its .layout/ holds the actual |
|
# pre-fix shipped layouts (from 6242518) forked the way a user would, and |
|
# its .blogrc deliberately sets neither BLOG_HOST nor BLOG_TITLE. |
|
legacy-layouts: |
|
runs-on: ubuntu-latest |
|
steps: |
|
- uses: actions/checkout@v4 |
|
- name: Install xmllint |
|
run: sudo apt-get update && sudo apt-get install -y libxml2-utils |
|
|
|
- name: Install jenny as a dev symlink |
|
run: | |
|
sudo mkdir -p /usr/local/bin |
|
make sym-install PREFIX=/usr/local |
|
jenny --version |
|
|
|
- name: A legacy layout is refused, not silently mis-rendered |
|
run: | |
|
cp -r test/fixtures/legacy-blog "$RUNNER_TEMP/blog" |
|
cd "$RUNNER_TEMP/blog" |
|
if jenny >/dev/null 2>"$RUNNER_TEMP/err"; then |
|
echo "expected jenny to refuse the legacy layout"; exit 1 |
|
fi |
|
grep -q 'old eval-based LIST format' "$RUNNER_TEMP/err" |
|
grep -q 'migrate-layout' "$RUNNER_TEMP/err" |
|
|
|
- name: Migrate the layouts and build |
|
run: | |
|
cd "$RUNNER_TEMP/blog" |
|
jenny migrate-layout .layout |
|
jenny >/dev/null 2>"$RUNNER_TEMP/build.err" |
|
if [ -s "$RUNNER_TEMP/build.err" ]; then |
|
echo "build wrote to stderr:"; cat "$RUNNER_TEMP/build.err"; exit 1 |
|
fi |
|
|
|
- name: The user's own markup survives migration |
|
run: | |
|
cd "$RUNNER_TEMP/blog" |
|
grep -q 'in-next' .layout/index.sh |
|
grep -q 'Under page' .layout/index.sh |
|
grep -q 'custom-marker' .layout/index.sh |
|
grep -q 'Posted on' .layout/rss2.sh |
|
test -f .layout/index.sh.pre-records.bak |
|
test -f .layout/rss2.sh.pre-records.bak |
|
|
|
- name: The custom markup reaches the output |
|
run: | |
|
cd "$RUNNER_TEMP/blog" |
|
grep -q 'Under page' .dist/index.html |
|
grep -q 'Posted on ' .dist/feed.xml |
|
|
|
- name: A migrated feed is well-formed despite an unescaped legacy layout |
|
run: | |
|
cd "$RUNNER_TEMP/blog" |
|
grep -q 'a Title & <thing>' .dist/index.html |
|
xmllint --noout .dist/feed.xml |
|
|
|
- name: Building twice is idempotent and re-migration is a no-op |
|
run: | |
|
cd "$RUNNER_TEMP/blog" |
|
jenny migrate-layout .layout | grep -q 'already current' |
|
jenny >/dev/null 2>"$RUNNER_TEMP/again.err" |
|
[ -s "$RUNNER_TEMP/again.err" ] && { cat "$RUNNER_TEMP/again.err"; exit 1; } |
|
echo "ok" |
|
|
|
- name: Every post rendered with a non-empty body |
|
run: | |
|
cd "$RUNNER_TEMP/blog" |
|
empty=0 |
|
for f in .dist/post/*.html; do [ -s "$f" ] || empty=$((empty + 1)); done |
|
echo "posts: $(ls .dist/post/*.html | wc -l), empty: $empty" |
|
[ "$empty" -eq 0 ] |