rua icon indicating copy to clipboard operation
rua copied to clipboard

Fix CI by using a docker for testing

Open vn971 opened this issue 3 years ago • 11 comments

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 avatar Jan 30 '21 07:01 vn971

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.

vn971 avatar Jan 30 '21 07:01 vn971

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

refaelsh avatar Jan 30 '21 21:01 refaelsh

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

Morganamilo avatar Jan 30 '21 21:01 Morganamilo

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

refaelsh avatar Jan 30 '21 21:01 refaelsh

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

refaelsh avatar Jan 30 '21 22:01 refaelsh

@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 avatar Feb 04 '21 07:02 vn971

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

vn971 avatar Feb 04 '21 07:02 vn971

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 avatar Feb 04 '21 16:02 refaelsh

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 avatar Feb 04 '21 16:02 refaelsh

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? :-)

refaelsh avatar Feb 04 '21 16:02 refaelsh

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

Morganamilo avatar Feb 04 '21 16:02 Morganamilo