From b3a9fde04e6ce83dcc42a2e422c45d7eadc0b513 Mon Sep 17 00:00:00 2001 From: Dave Vasilevsky Date: Wed, 11 Sep 2024 23:52:45 -0400 Subject: [PATCH 1/3] run tests in docker --- Dockerfile | 27 +++++++++++++++++++++++++++ test/run_tests.sh | 4 ++++ 2 files changed, 31 insertions(+) create mode 100644 Dockerfile create mode 100755 test/run_tests.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2ab0a4a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM ubuntu:noble AS apt +RUN apt-get update + +FROM apt AS build +RUN apt-get install -y g++ cmake make libbz2-dev libz-dev +RUN mkdir -p /source +COPY CMakeLists.txt /source +COPY common /source/common +COPY includes /source/includes +COPY hdutil /source/hdutil +COPY dmg /source/dmg +COPY hfs /source/hfs +RUN cmake -B /build /source +RUN make -C /build -j$(nproc) + +FROM apt AS test +RUN apt-get install -y pipx perl xxd +# We never want to actually make anything +RUN ln -s /bin/true /bin/make +RUN pipx install cram +ENV PATH="/usr/bin:/root/.local/bin" +RUN mkdir -p /test/build/dmg /test/build/hfs +COPY --from=build /build/dmg/dmg /test/build/dmg/dmg +COPY --from=build /build/hfs/hfsplus /test/build/hfs/hfsplus +COPY test /test/test +WORKDIR /test +CMD ["/bin/sh", "-c", "cram test/*.t"] diff --git a/test/run_tests.sh b/test/run_tests.sh new file mode 100755 index 0000000..289e72a --- /dev/null +++ b/test/run_tests.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -ex +docker buildx build --progress=plain --tag libdmg-hfsplus "$(dirname "$0")/.." +docker run libdmg-hfsplus From a74a5f6622476c1695100de182df31e506010e71 Mon Sep 17 00:00:00 2001 From: Dave Vasilevsky Date: Thu, 12 Sep 2024 00:10:27 -0400 Subject: [PATCH 2/3] run docker in CI --- .github/workflows/cram-tests.yml | 35 +++++++++++++++----------------- Dockerfile | 11 +++++----- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/.github/workflows/cram-tests.yml b/.github/workflows/cram-tests.yml index 287afd5..9e78885 100644 --- a/.github/workflows/cram-tests.yml +++ b/.github/workflows/cram-tests.yml @@ -7,24 +7,8 @@ on: branches: ["mozilla"] jobs: - test: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-22.04, macos-14] - pattern: ["test/*.t", "test/reference/*.t"] - include: - - os: ubuntu-22.04 - pattern: "test/*.t" - - os: macos-14 - pattern: "test/reference/*.t" - exclude: - - os: ubuntu-22.04 - pattern: "test/reference/*.t" - - os: macos-14 - pattern: "test/*.t" - + mac: + runs-on: macos-14 steps: - uses: actions/checkout@v4 - name: configure @@ -34,4 +18,17 @@ jobs: - name: test run: | pip install cram - cram ${{ matrix.pattern }} + cram test/reference/*.t + docker: + runs-on: ubuntu-latest + steps: + - uses: docker/setup-buildx-action@v3 + - name: docker build + uses: docker/build-push-action@v6 + with: + load: true + tags: libdmg-hfsplus:test + cache-from: type=gha + cache-to: type=gha,mode=max + - name: test + run: docker run --rm libdmg-hfsplus:test diff --git a/Dockerfile b/Dockerfile index 2ab0a4a..c297902 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,7 @@ -FROM ubuntu:noble AS apt -RUN apt-get update +FROM ubuntu:noble AS base -FROM apt AS build -RUN apt-get install -y g++ cmake make libbz2-dev libz-dev +FROM base AS build +RUN apt-get update && apt-get install -y g++ cmake make libbz2-dev libz-dev RUN mkdir -p /source COPY CMakeLists.txt /source COPY common /source/common @@ -13,8 +12,8 @@ COPY hfs /source/hfs RUN cmake -B /build /source RUN make -C /build -j$(nproc) -FROM apt AS test -RUN apt-get install -y pipx perl xxd +FROM base AS test +RUN apt-get update && apt-get install -y pipx perl xxd # We never want to actually make anything RUN ln -s /bin/true /bin/make RUN pipx install cram From 9881e24cc0c9650409219c7de781961d6d2179a1 Mon Sep 17 00:00:00 2001 From: Dave Vasilevsky Date: Tue, 17 Sep 2024 11:49:55 -0400 Subject: [PATCH 3/3] add docs --- README.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.markdown b/README.markdown index 362ec69..4ed9af1 100644 --- a/README.markdown +++ b/README.markdown @@ -77,6 +77,9 @@ The makefile in the root folder will make all utilities. TESTING ------- +To run tests automatically, ensure you have Docker and docker-buildx installed. Then run `./test/run_tests.sh`. + +Or to run tests manually: * Configure in 'build': `cmake -B build` * Install cram: `pipx install cram` * Run tests: `cram test/*.t`