From 76be3e7d02bb24acbbf51bd53f5f4cb69bd6ee22 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 14 Dec 2023 17:28:52 +0100 Subject: [PATCH] CI/verify-titles: verify that page tiles match what SUMMARY says The web version renders using the SUMMARY title and ignores the file title. The PDF and ePUB versions use the file titles. They ought to be the same. --- .github/scripts/verify-titles.pl | 37 +++++++++++++++++++++++++++++ .github/workflows/verify-titles.yml | 24 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100755 .github/scripts/verify-titles.pl create mode 100644 .github/workflows/verify-titles.yml diff --git a/.github/scripts/verify-titles.pl b/.github/scripts/verify-titles.pl new file mode 100755 index 0000000000..07b9bdb900 --- /dev/null +++ b/.github/scripts/verify-titles.pl @@ -0,0 +1,37 @@ +#!/usr/bin/perl + +my $sum = shift @ARGV; + +# Figure out all files in right order +open(F, "<$sum"); +while() { + if($_ =~ /\[(.*)\]\(([^\)]*)\)/) { + my ($title, $file) = ($1, $2); + push @files, $file; + $title{$file} = $title; + } +} +close(F); + +sub check { + my ($f) = @_; + open(F, "<$f"); + while() { + if(/^# (.*)/) { + # verify + if($1 ne $title{$f}) { + printf STDERR "$f says '%s', not '%s' like SUMMARY.md\n", + $1, $title{$f}; + $errors++; + } + last; + } + } + close(F); +}; + +for my $f (@files) { + check($f); +} + +exit $errors; diff --git a/.github/workflows/verify-titles.yml b/.github/workflows/verify-titles.yml new file mode 100644 index 0000000000..c9d173b083 --- /dev/null +++ b/.github/workflows/verify-titles.yml @@ -0,0 +1,24 @@ +# Copyright (C) Daniel Stenberg, , et al. + +name: verify-titles +on: + push: + branches: + - master + paths: + - '**.md' + pull_request: + branches: + - master + +permissions: {} + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: build pdf + run: .github/scripts/verify-titles.pl SUMMARY.md +