Skip to content

Commit

Permalink
Add CI test to ensure installation manifest is correct
Browse files Browse the repository at this point in the history
Fixes #617
  • Loading branch information
NWilson committed Dec 17, 2024
1 parent 0ed421c commit 60df655
Show file tree
Hide file tree
Showing 11 changed files with 2,016 additions and 4 deletions.
55 changes: 53 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ jobs:
- name: Test (pcre2posix program)
run: ./pcre2posix_test -v

- name: Install
run: |
make install "DESTDIR=`pwd`/install-dir"
maint/RunManifestTest install-dir maint/manifest-makeinstall-linux
alpine:
name: alpine
runs-on: ubuntu-latest
Expand Down Expand Up @@ -79,6 +84,11 @@ jobs:
- name: Test (pcre2posix program)
run: ./pcre2posix_test -v

- name: Install
run: |
make install "DESTDIR=`pwd`/install-dir"
maint/RunManifestTest install-dir maint/manifest-makeinstall-linux
macos:
name: macOS universal
runs-on: macos-latest
Expand All @@ -89,14 +99,20 @@ jobs:
submodules: true

- name: Configure
run: cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2_SUPPORT_LIBZ=ON -DPCRE2_SUPPORT_LIBBZ2=ON -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' -DCMAKE_C_FLAGS='-Wall -Wextra' -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -B build
run: cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2_SUPPORT_LIBZ=ON -DPCRE2_SUPPORT_LIBBZ2=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' -DCMAKE_C_FLAGS='-Wall -Wextra' -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -B build

- name: Build
run: cd build && make -j3

- name: Test
run: cd build && ctest -j3 --output-on-failure

- name: Install
run: |
cd build
cmake --install . --prefix install-dir
../maint/RunManifestTest install-dir ../maint/manifest-cmakeinstall-macos
windows:
name: Windows
runs-on: windows-latest
Expand All @@ -111,14 +127,20 @@ jobs:
submodules: true

- name: Configure
run: cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -B build -A ${{ matrix.arch }}
run: cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -B build -A ${{ matrix.arch }}

- name: Build
run: cmake --build build --config Release

- name: Test
run: cd build && ctest -C Release -j3 --output-on-failure

- name: Install
run: |
cd build
cmake --install . --config Release --prefix install-dir
../maint/RunManifestTest.ps1 install-dir ../maint/manifest-cmakeinstall-windows
freebsd:
name: FreeBSD
runs-on: ubuntu-latest
Expand All @@ -142,6 +164,9 @@ jobs:
make -j3 CPPFLAGS='-Wall -Wextra -Werror'
make check
make install "DESTDIR=`pwd`/install-dir"
maint/RunManifestTest install-dir maint/manifest-makeinstall-freebsd
solaris:
name: Solaris
runs-on: ubuntu-latest
Expand Down Expand Up @@ -192,6 +217,32 @@ jobs:
make CPPFLAGS='-Wall -Wextra -Werror'
make check
make install "DESTDIR=`pwd`/install-dir"
maint/RunManifestTest install-dir maint/manifest-makeinstall-linux
distcheck:
name: Build & verify distribution
runs-on: ubuntu-24.04 # TODO: Update to ubuntu-latest when that switches to 24.04
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true

- name: Prepare
run: ./autogen.sh

- name: Configure
run: ./configure

- name: Distcheck
run: make distcheck -j3

- name: Manifest
run: |
mkdir tarball-dir && tar -C tarball-dir -xzf pcre2-*.tar.gz
maint/RunManifestTest tarball-dir maint/manifest-tarball
coverage:
name: Code coverage
runs-on: ubuntu-latest
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,20 @@ jobs:
submodules: true

- name: Configure
run: cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2_DEBUG=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -B build
run: cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DPCRE2_DEBUG=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -B build

- name: Build
run: cd build && make -j3

- name: Test
run: cd build && ctest -j3 --output-on-failure

- name: Install
run: |
cd build
cmake --install . --prefix install-dir
../maint/RunManifestTest install-dir ../maint/manifest-cmakeinstall-linux
dodo:
# Tests with: Autconf on oldest supported Ubuntu (in non-extended support)
name: GCC -Os, old Autotools
Expand All @@ -125,6 +131,11 @@ jobs:
- name: Test
run: make check

- name: Install
run: |
make install "DESTDIR=`pwd`/install-dir"
maint/RunManifestTest install-dir maint/manifest-makeinstall-linux
wasp:
# Tests with: French locale; oldest supported CMake; no JIT; -Os; libreadline
name: GCC -Os, CMake+ninja, no JIT
Expand Down Expand Up @@ -157,14 +168,20 @@ jobs:
- name: Configure
run: |
cmake --version | grep "version ${CMAKE_VER}" || (echo "CMake version mismatch" && exit 1)
CC='clang' CFLAGS='-fsanitize=undefined,address,integer -fno-sanitize-recover=undefined,integer -fno-sanitize=unsigned-shift-base,function -pedantic -Wall -Wextra -Wpedantic -Wdeclaration-after-statement -Wshadow -Wno-overlength-strings -Werror -Wno-error=incompatible-pointer-types-discards-qualifiers' cmake -G Ninja -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2_DEBUG=ON -DPCRE2_SUPPORT_LIBREADLINE=ON -DCMAKE_BUILD_TYPE=MinSizeRel -B build
CC='clang' CFLAGS='-fsanitize=undefined,address,integer -fno-sanitize-recover=undefined,integer -fno-sanitize=unsigned-shift-base,function -pedantic -Wall -Wextra -Wpedantic -Wdeclaration-after-statement -Wshadow -Wno-overlength-strings -Werror -Wno-error=incompatible-pointer-types-discards-qualifiers' cmake -G Ninja -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DPCRE2_DEBUG=ON -DPCRE2_SUPPORT_LIBREADLINE=ON -DCMAKE_BUILD_TYPE=MinSizeRel -B build
- name: Build
run: ninja -C build

- name: Test
run: cd build && ctest -j3 --output-on-failure

- name: Install
run: |
cd build
cmake --install . --prefix install-dir
../maint/RunManifestTest install-dir ../maint/manifest-cmakeinstall-linux
bat:
# Tests with: MSVC 32-bit, and a variety of CMake options
name: Windows (Win32)
Expand Down
5 changes: 5 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ autoheader -f -W all

automake -a -c -f -W all,no-portability

# Workaround for incorrect filesystem permissions on /usr/share/aclocal, which
# causes the m4 macros to be copied with incorrect permissions.

chmod u=rw,go=r m4/*.m4

rm -rf autom4te.cache
exit 0

Expand Down
45 changes: 45 additions & 0 deletions maint/RunManifestTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#/bin/sh

# Script to test a directory listing. We use this to verify that the list of
# files installed by "make install" or "cmake --install" matches what we expect.

LANG=C # Ensure stable ordering of `ls` output
export LANG

if [ "$1" = "" -o "$2" = "" ] ; then
echo "Usage: $0 <dir> <manifest name>" >&2
exit 1
fi

input_dir="$1"
expected_manifest="$2"

base=`basename $expected_manifest`

sed=sed
grep=grep
# Helpers for Solaris
if [ -f /usr/bin/gsed ] ; then
sed=/usr/bin/gsed
fi
if [ -f /usr/bin/ggrep ] ; then
grep=/usr/bin/ggrep
fi

ls -R -l -n -A "$input_dir" | \
$grep -v '^total' | \
$sed -E -e 's/ {2,}/ /g' | \
cut -d' ' -f '1,9-' \
> "$base"

if ! diff -u "$expected_manifest" "$base"; then
echo "Installed files differ from expected" >&2

echo "===Actual==="
cat "$base"
echo "===End==="

exit 1
fi

echo "Installed files match expected"
37 changes: 37 additions & 0 deletions maint/RunManifestTest.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#/bin/sh

# Script to test a directory listing. We use this to verify that the list of
# files installed by "make install" or "cmake --install" matches what we expect.

param (
[Parameter(Mandatory=$true)]
[string]$inputDir,

[Parameter(Mandatory=$true)]
[string]$manifestName
)

if ((-not $inputDir) -or (-not $manifestName)) {
throw "Usage: .\RunManifestTest.ps1 <dir> <manifest name>"
}

$base = [System.IO.Path]::GetFileName($manifestName)

$installedFiles = Get-ChildItem -Recurse -Force -Path $inputDir |
Sort-Object {[System.BitConverter]::ToString([system.Text.Encoding]::UTF8.GetBytes($_.FullName))} |
ForEach-Object { $_.Mode.Substring(0,5) + " " + ($_.FullName | Resolve-Path -Relative) }

$null = New-Item -Force $base -Value ($installedFiles | Out-String)

$expectedFiles = Get-Content -Path $manifestName -Raw
$actualFiles = Get-Content -Path $base -Raw

if ($expectedFiles -ne $actualFiles) {
Write-Host "===Actual==="
Write-Host $actualFiles
Write-Host "===End==="

throw "Installed files differ from expected"
}

Write-Host "Installed files match expected"
Loading

0 comments on commit 60df655

Please sign in to comment.