Files
uc2/.github/workflows/build.yml
T

227 lines
10 KiB
YAML

name: Build
on:
push:
branches: [main, 'work/compression-integrations-*']
pull_request:
branches: [main]
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, name: Linux }
- { os: macos-latest, name: macOS }
- { os: windows-latest, name: Windows (MSVC) }
runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
steps:
- uses: actions/checkout@v4
- name: Lint -- forbid assert(side-effect)
if: runner.os == 'Linux'
run: python3 tests/scripts/check_assert_side_effects.py
- name: Configure
run: cmake -B build -DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build --config Release
- name: Smoke test (Unix)
if: runner.os != 'Windows'
run: ./build/cli/uc2 -h
- name: Smoke test (Windows)
if: runner.os == 'Windows'
run: .\build\cli\Release\uc2.exe -h
- name: Test
run: ctest --test-dir build --output-on-failure -C Release
libarchive:
runs-on: ubuntu-latest
name: libarchive plugin
env:
LIBARCHIVE_VERSION: 3.8.11
LIBARCHIVE_SHA256: a3dc0872b1b39da34dc18ef1b944f0f11ffd37425d70ae04be679279f1cf43d2
steps:
- uses: actions/checkout@v4
- name: Fetch libarchive source
run: |
curl -fsSLO "https://github.com/libarchive/libarchive/releases/download/v${LIBARCHIVE_VERSION}/libarchive-${LIBARCHIVE_VERSION}.tar.xz"
echo "${LIBARCHIVE_SHA256} libarchive-${LIBARCHIVE_VERSION}.tar.xz" | sha256sum -c -
tar xf "libarchive-${LIBARCHIVE_VERSION}.tar.xz"
- name: Build libarchive static (dependency-free)
run: |
cmake -S "libarchive-${LIBARCHIVE_VERSION}" -B larch-build \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DBUILD_SHARED_LIBS=OFF -DENABLE_TEST=OFF -DENABLE_TAR=OFF \
-DENABLE_CPIO=OFF -DENABLE_CAT=OFF -DENABLE_UNZIP=OFF \
-DENABLE_WERROR=OFF -DENABLE_ZLIB=OFF -DENABLE_BZip2=OFF \
-DENABLE_LZMA=OFF -DENABLE_ZSTD=OFF -DENABLE_LZ4=OFF \
-DENABLE_LIBXML2=OFF -DENABLE_EXPAT=OFF -DENABLE_OPENSSL=OFF \
-DENABLE_LIBB2=OFF -DENABLE_ICONV=OFF -DENABLE_ACL=OFF \
-DENABLE_XATTR=OFF -DENABLE_CNG=OFF -DENABLE_MBEDTLS=OFF \
-DENABLE_NETTLE=OFF -DENABLE_PCREPOSIX=OFF -DENABLE_PCRE2POSIX=OFF
cmake --build larch-build --target archive_static -j
- name: Configure UC2 with libarchive plugin
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release \
-DUC2_BUILD_LIBARCHIVE_PLUGIN=ON \
-DLIBARCHIVE_SOURCE_DIR="$PWD/libarchive-${LIBARCHIVE_VERSION}" \
-DLIBARCHIVE_LIBRARY="$PWD/larch-build/libarchive/libarchive.a"
- name: Build
run: cmake --build build -j
- name: Round-trip test
run: ctest --test-dir build --output-on-failure -R libarchive_roundtrip
- name: Build actual bsdtar with UC2 support
run: python3 contrib/libarchive/build_bsdtar.py --source "libarchive-${LIBARCHIVE_VERSION}" --build build-bsdtar
- name: Test actual bsdtar, pipes and bounded payload RAM
run: python3 tests/scripts/check_bsdtar.py build/cli/uc2 build-bsdtar/build/bin/bsdtar
- name: Verify format resource limits
run: python3 tests/scripts/check_bsdtar_limits.py build/cli/uc2 build-bsdtar/build/bin/bsdtar
libarchive-review:
runs-on: ubuntu-latest
name: Optional LGPL reader and libarchive proposal
steps:
- uses: actions/checkout@v6
- name: Fetch pinned libarchive source
run: |
curl -fsSLO https://github.com/libarchive/libarchive/releases/download/v3.8.11/libarchive-3.8.11.tar.xz
echo 'a3dc0872b1b39da34dc18ef1b944f0f11ffd37425d70ae04be679279f1cf43d2 libarchive-3.8.11.tar.xz' | sha256sum -c -
tar xf libarchive-3.8.11.tar.xz
- name: Build legacy shared reader and fixture generator
run: |
cmake -S contrib/libuc2read -B build-reader -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$PWD/reader-prefix"
cmake --build build-reader -j 4
cmake --install build-reader
cmake -B build -DCMAKE_BUILD_TYPE=Release -DUC2_BUILD_TESTS=OFF
cmake --build build -j 4
- name: Prepare and apply-check the contribution
run: |
python3 contrib/libarchive/prepare_upstream.py --source libarchive-3.8.11 --uc2 build/cli/uc2 --output review
patch --dry-run -p1 -d libarchive-3.8.11 -i "$PWD/review/libarchive-3.8.11-uc2-review.patch"
cmp review/libarchive-3.8.11-uc2-review.patch contrib/libarchive/upstream/libarchive-3.8.11-uc2-review.patch
- name: Build and test enabled proposal
run: |
cmake -S review/libarchive -B review/build -DCMAKE_BUILD_TYPE=Release -DENABLE_WERROR=OFF -DENABLE_TEST=ON -DENABLE_UC2READ=ON -DCMAKE_PREFIX_PATH="$PWD/reader-prefix"
cmake --build review/build --target bsdtar libarchive_test -j 4
review/build/bin/libarchive_test -r "$PWD/review/libarchive/libarchive/test" test_read_format_uc2
python3 tests/scripts/check_bsdtar.py build/cli/uc2 review/build/bin/bsdtar --legacy-only --seekable-only
- name: Verify optional-reader resource limits
run: python3 tests/scripts/check_bsdtar_limits.py build/cli/uc2 review/build/bin/bsdtar --seekable-only
- name: Verify the default build has no reader dependency
run: |
cmake -S review/libarchive -B review/build -DENABLE_UC2READ=OFF
cmake --build review/build --target libarchive_test -j 4
review/build/bin/libarchive_test -r "$PWD/review/libarchive/libarchive/test" test_read_format_uc2
totalcommander:
runs-on: windows-latest
name: Total Commander WCX (64-bit)
steps:
- uses: actions/checkout@v4
- name: Fetch pinned official SDK header
shell: pwsh
run: |
New-Item -ItemType Directory wcx-sdk
Invoke-WebRequest https://raw.githubusercontent.com/ghisler/WCX-SDK/13b5af8f4265733becf423e61bf000276dc528f8/src/wcxhead.h -OutFile wcx-sdk/wcxhead.h
- name: Configure and build
run: |
cmake -B build-wcx -A x64 -DUC2_BUILD_TESTS=OFF -DUC2_BUILD_WCX=ON -DUC2_WCX_SDK_DIR="${{ github.workspace }}/wcx-sdk"
cmake --build build-wcx --config Release --target uc2-cli uc2_wcx test_wcx
- name: Test DLL through WCX ABI
run: python tests/wcx/run_fixture.py --uc2 build-wcx/cli/Release/uc2.exe --plugin build-wcx/contrib/totalcommander/Release/uc2.wcx64 --host build-wcx/contrib/totalcommander/Release/test_wcx.exe --work build-wcx-fixture
djgpp:
runs-on: ubuntu-latest
name: DOS (DJGPP)
env:
DJGPP_URL: https://github.com/andrewwutw/build-djgpp/releases/download/v3.4/djgpp-linux64-gcc1220.tar.bz2
DJGPP_SHA256: 8464f17017d6ab1b2bb2df4ed82357b5bf692e6e2b7fee37e315638f3d505f00
# Keep host include dirs out of the cross-compiler's search path in
# every step (the toolchain file also forces -nostdinc, but a stray
# CPATH on the runner would otherwise leak glibc headers).
CPATH: ''
CPLUS_INCLUDE_PATH: ''
steps:
- uses: actions/checkout@v4
- name: Install DJGPP cross-toolchain
run: |
# The prebuilt DJGPP binutils (ar, ld) are linked against the
# flex runtime; install it so they load on a clean runner.
sudo apt-get update
sudo apt-get install -y libfl2
curl -fsSL -o djgpp.tar.bz2 "$DJGPP_URL"
echo "${DJGPP_SHA256} djgpp.tar.bz2" | sha256sum -c -
sudo tar xjf djgpp.tar.bz2 -C /opt # -> /opt/djgpp
- name: Configure (DJGPP toolchain)
run: |
cmake -B build-dos \
-DCMAKE_TOOLCHAIN_FILE=cmake/djgpp.cmake \
-DDJGPP_ROOT=/opt/djgpp -DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build-dos -j
- name: Verify DOS executable
run: |
file build-dos/cli/uc2.exe
file build-dos/cli/uc2.exe | grep -Eq "DJGPP go32( v[^ ]+)? DOS extender" \
|| { echo "uc2.exe is not a DJGPP DOS executable"; exit 1; }
fuzz:
runs-on: ubuntu-latest
name: Fuzz (libFuzzer + ASan)
env:
# Bounded wall-clock per harness; libFuzzer exits non-zero on any
# crash, OOM, or input slower than -timeout, failing the job.
FUZZ_SECONDS: 90
steps:
- uses: actions/checkout@v4
- name: Configure + build (generates super_data.S, uc2_version.h)
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --target uc2 -j
- name: Build fuzz harnesses
run: |
for h in fuzz_extract fuzz_roundtrip fuzz_sea fuzz_chunks; do
clang -DNDEBUG -fsanitize=fuzzer,address -O1 -g \
-Ilib/include -Ilib/src -Ibuild/lib \
tests/fuzz/$h.c lib/src/*.c build/lib/super_data.S \
-lm -o $h
done
- name: Replay committed regression artifacts
run: |
./fuzz_extract tests/fuzz/regressions/* tests/fuzz/seeds/*
- name: Fuzz read path
run: |
mkdir -p corpus_extract
cp tests/fuzz/seeds/* tests/fuzz/regressions/* corpus_extract/ || true
./fuzz_extract -max_len=65536 -timeout=20 -rss_limit_mb=2048 \
-max_total_time=$FUZZ_SECONDS corpus_extract/
- name: Fuzz shared chunk recipes and payloads
run: |
mkdir -p corpus_chunks
cp tests/fuzz/seeds/chunk-* corpus_chunks/
./fuzz_chunks -max_len=65536 -timeout=20 -rss_limit_mb=2048 \
-max_total_time=$FUZZ_SECONDS corpus_chunks/
- name: Fuzz standalone SEA decoder
run: |
mkdir -p corpus_sea
python3 -c 'from pathlib import Path; d=Path("tests/archives/sea/MORE.EXE").read_bytes(); p=d.index(b"UC2SFX Header"); Path("corpus_sea/more").write_bytes(d[int.from_bytes(d[p+15:p+19], "little"):])'
./fuzz_sea -max_len=65536 -timeout=20 -rss_limit_mb=2048 \
-max_total_time=$FUZZ_SECONDS corpus_sea/
- name: Fuzz compress / round-trip path
run: |
mkdir -p corpus_rt
./fuzz_roundtrip -max_len=16384 -timeout=20 -rss_limit_mb=2048 \
-max_total_time=$FUZZ_SECONDS corpus_rt/
- name: Upload crash artifacts on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: fuzz-artifacts
path: |
crash-*
timeout-*
oom-*
if-no-files-found: ignore