Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: run tests #5

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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: Build test container image
run: docker build -t test_image .
- name: Run tests in container image
run: docker run --rm -i test_image cargo test
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@ FROM rust:1.73-slim-bullseye

WORKDIR /builder

RUN apt-get update && \
apt-get install -y --no-install-recommends qemu-system=1:5.2+dfsg-11+deb11u3 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

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 cargo install bootimage && \
rustup toolchain install nightly-aarch64-unknown-linux-gnu && \
rustup toolchain install nightly-x86_64-unknown-linux-gnu && \
rustup component add rust-src --toolchain nightly-aarch64-unknown-linux-gnu && \
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu && \
rustup component add llvm-tools-preview

CMD ["cargo","bootimage"]
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 .) cargo test
```

Run tests on host system:

```bash
cargo test
```