Use Vagrant for integration tests
This commit is contained in:
parent
753deed96e
commit
4d848f60cb
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
/.vagrant
|
||||||
/target
|
/target
|
||||||
|
|
||||||
.env
|
.env
|
||||||
|
|
10
Justfile
10
Justfile
|
@ -4,12 +4,18 @@ export OBS_HOST := if os() == "macos" { "host.docker.internal" } else { "127.0.0
|
||||||
default:
|
default:
|
||||||
@just --list
|
@just --list
|
||||||
|
|
||||||
# run integration tests with coverage
|
# run integration tests with coverage (using Docker)
|
||||||
coverage:
|
coverage:
|
||||||
docker run --rm -it --security-opt seccomp=unconfined --network host -v $PWD:/volume -v $HOME/.cargo/registry:/usr/local/cargo/registry xd009642/tarpaulin cargo tarpaulin --out Html --out Lcov --all-features
|
docker run --rm -it --security-opt seccomp=unconfined --network host -v $PWD:/volume -v $HOME/.cargo/registry:/usr/local/cargo/registry xd009642/tarpaulin cargo tarpaulin --out Html --out Lcov --all-features
|
||||||
|
|
||||||
|
# run integration tests with coverage (using Vagrant)
|
||||||
|
coverage-vagrant:
|
||||||
|
vagrant up
|
||||||
|
vagrant ssh -c 'cd /vagrant; false; while [ "$?" -eq 1 ]; do cargo tarpaulin --all-features --no-run; done'
|
||||||
|
vagrant ssh -c 'cd /vagrant && cargo tarpaulin --out Html --out Lcov --all-features'
|
||||||
|
|
||||||
# upload coverage to https://codecov.io
|
# upload coverage to https://codecov.io
|
||||||
upload-coverage:
|
upload-coverage:
|
||||||
@# {{env_var("CODECOV_TOKEN")}}
|
@# {{env_var("CODECOV_TOKEN")}}
|
||||||
just coverage
|
just coverage-vagrant
|
||||||
bash -c "bash <(curl -s https://codecov.io/bash)"
|
bash -c "bash <(curl -s https://codecov.io/bash)"
|
||||||
|
|
17
Vagrantfile
vendored
Normal file
17
Vagrantfile
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.box = "ubuntu/focal64"
|
||||||
|
|
||||||
|
config.vm.network "private_network", ip: "192.168.10.20"
|
||||||
|
|
||||||
|
config.vm.provision "shell", inline: <<-SHELL
|
||||||
|
apt-get update
|
||||||
|
apt-get dist-upgrade -y
|
||||||
|
apt-get install -y build-essential libssl-dev pkg-config
|
||||||
|
SHELL
|
||||||
|
|
||||||
|
config.vm.provision "shell", privileged: false, inline: <<-SHELL
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||||
|
source $HOME/.cargo/env
|
||||||
|
cargo install cargo-tarpaulin --version 0.18.0-alpha1
|
||||||
|
SHELL
|
||||||
|
end
|
|
@ -48,6 +48,10 @@ static INIT: Once = Once::new();
|
||||||
|
|
||||||
pub async fn new_client() -> Result<Client> {
|
pub async fn new_client() -> Result<Client> {
|
||||||
INIT.call_once(|| {
|
INIT.call_once(|| {
|
||||||
|
if matches!(env::var("USER").as_deref(), Ok("vagrant")) {
|
||||||
|
env::set_var("OBS_HOST", "192.168.10.1");
|
||||||
|
}
|
||||||
|
|
||||||
dotenv::dotenv().ok();
|
dotenv::dotenv().ok();
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue