Skip to content

Commit

Permalink
Merge pull request planetbeing#13 from vasi/docker
Browse files Browse the repository at this point in the history
Run Linux tests in Docker
  • Loading branch information
bhearsum authored Sep 17, 2024
2 parents c631a40 + 9881e24 commit 07b8451
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 19 deletions.
35 changes: 16 additions & 19 deletions .github/workflows/cram-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM ubuntu:noble AS base

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
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 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
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"]
3 changes: 3 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`
4 changes: 4 additions & 0 deletions test/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -ex
docker buildx build --progress=plain --tag libdmg-hfsplus "$(dirname "$0")/.."
docker run libdmg-hfsplus

0 comments on commit 07b8451

Please # to comment.