mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 04:39:24 +00:00
Add processor Docker tests
Adds tests/docker for code common to Docker-based tests.
This commit is contained in:
14
tests/docker/Cargo.toml
Normal file
14
tests/docker/Cargo.toml
Normal file
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "serai-docker-tests"
|
||||
version = "0.1.0"
|
||||
description = "Docker-based testing infrastructure for Serai"
|
||||
license = "AGPL-3.0-only"
|
||||
repository = "https://github.com/serai-dex/serai/tree/develop/tests/docker"
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = []
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
15
tests/docker/LICENSE
Normal file
15
tests/docker/LICENSE
Normal file
@@ -0,0 +1,15 @@
|
||||
AGPL-3.0-only license
|
||||
|
||||
Copyright (c) 2023 Luke Parker
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License Version 3 as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
45
tests/docker/src/lib.rs
Normal file
45
tests/docker/src/lib.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
use std::{
|
||||
sync::{Mutex, OnceLock},
|
||||
collections::HashMap,
|
||||
env,
|
||||
};
|
||||
|
||||
static BUILT: OnceLock<Mutex<HashMap<String, bool>>> = OnceLock::new();
|
||||
pub fn build(name: String) {
|
||||
let built = BUILT.get_or_init(|| Mutex::new(HashMap::new()));
|
||||
// Only one call to build will acquire this lock
|
||||
let mut built_lock = built.lock().unwrap();
|
||||
if built_lock.contains_key(&name) {
|
||||
// If it was built, return
|
||||
return;
|
||||
}
|
||||
|
||||
// Else, hold the lock while we build
|
||||
let mut path = env::current_exe().unwrap();
|
||||
path.pop();
|
||||
assert!(path.as_path().ends_with("deps"));
|
||||
path.pop();
|
||||
assert!(path.as_path().ends_with("debug"));
|
||||
path.pop();
|
||||
assert!(path.as_path().ends_with("target"));
|
||||
path.pop();
|
||||
path.push("deploy");
|
||||
|
||||
println!("Building {}...", &name);
|
||||
|
||||
assert!(std::process::Command::new("docker")
|
||||
.current_dir(path)
|
||||
.arg("compose")
|
||||
.arg("build")
|
||||
.arg(&name)
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait()
|
||||
.unwrap()
|
||||
.success());
|
||||
|
||||
println!("Built!");
|
||||
|
||||
// Set built
|
||||
built_lock.insert(name, true);
|
||||
}
|
||||
Reference in New Issue
Block a user