From 49063858af46c4e50a3af19e92d9b6edbc035d60 Mon Sep 17 00:00:00 2001 From: Juozas Vainauskas <71255955+JuozasVainauskas@users.noreply.github.com> Date: Sat, 11 Nov 2023 23:30:22 +0200 Subject: [PATCH] ci: run tests --- .github/workflows/run-tests.yaml | 17 +++++++++++++++++ Dockerfile | 3 +++ Dockerfile.test | 21 +++++++++++++++++++++ README.md | 14 ++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 .github/workflows/run-tests.yaml create mode 100644 Dockerfile.test diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml new file mode 100644 index 0000000..a9f7d8b --- /dev/null +++ b/.github/workflows/run-tests.yaml @@ -0,0 +1,17 @@ +name: Run tests +run-name: Run tests +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + run-tests: + runs-on: ubuntu-22.04 + steps: + - name: Check out source Repo + uses: actions/checkout@v3 + + - name: Run tests in container image + run: docker run --rm -i $(docker build -q -f Dockerfile.test .) ls -a diff --git a/Dockerfile b/Dockerfile index fca0812..cb75c89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,10 @@ COPY ./Cargo.toml . COPY ./Cargo.lock . COPY ./rust-toolchain.toml . COPY ./x86_64-os.json . +COPY ./tests ./tests +RUN apt-get update && \ + apt-get install qemu-system -y RUN cargo install bootimage && \ rustup component add rust-src --toolchain nightly-aarch64-unknown-linux-gnu && \ rustup component add llvm-tools-preview diff --git a/Dockerfile.test b/Dockerfile.test new file mode 100644 index 0000000..4d7c961 --- /dev/null +++ b/Dockerfile.test @@ -0,0 +1,21 @@ +FROM rust:1.73-slim-bullseye + +WORKDIR /builder + +COPY ./.cargo ./.cargo +COPY ./src ./src +COPY ./Cargo.toml . +COPY ./Cargo.lock . +COPY ./rust-toolchain.toml . +COPY ./x86_64-os.json . +COPY ./tests ./tests + +RUN apt-get update && \ + apt-get install qemu-system -y +RUN cargo install bootimage && \ + rustup target add aarch64-unknown-linux-gnu && \ + rustup toolchain install nightly-aarch64-unknown-linux-gnu && \ + rustup component add rust-src --toolchain nightly-aarch64-unknown-linux-gnu && \ + rustup component add llvm-tools-preview + +CMD ["cargo","test"] diff --git a/README.md b/README.md index 2b244d7..44a5e3f 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,17 @@ Hobby OS implementation in Rust ```bash qemu-system-x86_64 -drive format=raw,file=target/x86_64-os/debug/bootimage-os.bin ``` + +## Tests + +Run tests in Docker: + +```bash +docker run --rm -it $(docker build -q -f Dockerfile.test .) +``` + +Run tests on host system: + +```bash +cargo test +```