Merge pull request #13 from vasi/docker

Run Linux tests in Docker
This commit is contained in:
Ben Hearsum (he/him) 2024-09-17 12:58:51 -04:00 коммит произвёл GitHub
Родитель c631a40090 9881e24cc0
Коммит 07b845168e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 49 добавлений и 19 удалений

35
.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

26
Dockerfile Normal file
Просмотреть файл

@ -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"]

Просмотреть файл

@ -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
test/run_tests.sh Executable file
Просмотреть файл

@ -0,0 +1,4 @@
#!/bin/sh
set -ex
docker buildx build --progress=plain --tag libdmg-hfsplus "$(dirname "$0")/.."
docker run libdmg-hfsplus