vn971 / rua

Build tool for Arch Linux providing control, review and jailed build options
GNU General Public License v3.0
424 stars 42 forks source link

Fix CI by using a docker for testing #151

Open vn971 opened 3 years ago

vn971 commented 3 years ago

Currently, CI only checks that the code compiles in Travis CI: https://github.com/vn971/rua/blob/236bc43a0a8405aa1a84a9b8c7fe84f244a6db18/.travis.yml#L16

The current reason for that is that Travis doesn't have an ArchLinux OS choice, and instead ubuntu is used at the moment. Ubuntu, however, does not have a pacman package on it, and cargo test fails at run-time.

One solution would be to use an Arch docker image in CI, and then change our tests from cargo check (compilation) to cargo test for proper testing.

vn971 commented 3 years ago

There is no known actual "bug" here, but I marked the issue as "bug" because it's important. Without proper CI, you could have bugs in the future that go undetected. The "bug" could therefore mean that we're not preventing this mistake from happening proactively.

refaelsh commented 3 years ago

I one would try and do it, theoretically, could one be please pointed to docker thingy creation documentation?

Morganamilo commented 3 years ago

Here's an example: https://github.com/Morganamilo/alpm.rs/blob/master/.github/workflows/alpm.yml

refaelsh commented 3 years ago

This line: image: archlinux. This is interesting. I would have thought it should be like this: image: url/to/docker/image.

refaelsh commented 3 years ago

Also, why use Travis CI when we have Gitlab CI?

vn971 commented 3 years ago

@refaelsh I guess GitLab CI could be used as well. I think I historically started with github - most of the PR's happen here as well ATM.

@Morganamilo-s repo seem to even use github's built-in CI, which is a third approach.

vn971 commented 3 years ago

WRT image in alpm.rs, I think it runs docker inside ubuntu-latest, so you specify both the host (one of few OS-es supported), and then what guest docker image to run in the host OS. I could be wrong though, that was just my impression. "archlinux" is probably just this: https://hub.docker.com/_/archlinux

refaelsh commented 3 years ago

Also, why use Travis CI when we have Gitlab CI?

I am terribly sorry, please disregard this question. This is GitHub and not GitLab. I always get them mixed up in my head.

refaelsh commented 3 years ago

WRT image in alpm.rs, I think it runs docker inside ubuntu-latest, so you specify both the host (one of few OS-es supported), and then what guest docker image to run in the host OS. I could be wrong though, that was just my impression. "archlinux" is probably just this: https://hub.docker.com/_/archlinux

Ok. I still have much to learn about this "Docker" thingy, but it does points me in the right direction. Thank you.

refaelsh commented 3 years ago

cargo test fails at run-time.

I dont understand why? Unit tests use mocks and cargo test runs unit test. This should not fail since mocks are fake, they dont need Arch or pacman.

P.S. I am aware that cargo test will also run integration tests from the test folder (if it detects one), but, integration test are always come after unit tests. I suggest we first focus on the unit tests --> this issue can be postponed, and a new issue needs to be opened that would add cargo test to CI/CD. A penny for your thoughts? :-)

Morganamilo commented 3 years ago

The issue is the tests need to link to libalpm.so to run.