mirror of
https://github.com/swc-project/swc.git
synced 2024-10-04 04:07:18 +03:00
test(plugin/runner): Share target
directory (#7544)
**Description:** This will reduce CI time greatly.
This commit is contained in:
parent
2f2a15f3df
commit
aa82e5fff3
43
Cargo.lock
generated
43
Cargo.lock
generated
@ -354,6 +354,38 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "camino"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cargo-platform"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cargo_metadata"
|
||||
version = "0.15.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a"
|
||||
dependencies = [
|
||||
"camino",
|
||||
"cargo-platform",
|
||||
"semver 1.0.17",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cast"
|
||||
version = "0.2.7"
|
||||
@ -2506,7 +2538,7 @@ dependencies = [
|
||||
"dashmap",
|
||||
"from_variant",
|
||||
"once_cell",
|
||||
"semver 1.0.4",
|
||||
"semver 1.0.17",
|
||||
"serde",
|
||||
"st-map",
|
||||
"tracing",
|
||||
@ -2873,7 +2905,7 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
|
||||
dependencies = [
|
||||
"semver 1.0.4",
|
||||
"semver 1.0.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2985,9 +3017,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.4"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012"
|
||||
checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
@ -4023,7 +4055,7 @@ dependencies = [
|
||||
"once_cell",
|
||||
"preset_env_base",
|
||||
"pretty_assertions",
|
||||
"semver 1.0.4",
|
||||
"semver 1.0.17",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"st-map",
|
||||
@ -4704,6 +4736,7 @@ name = "swc_plugin_runner"
|
||||
version = "0.97.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cargo_metadata",
|
||||
"criterion",
|
||||
"enumset",
|
||||
"once_cell",
|
||||
|
@ -20,8 +20,6 @@ plugin_transform_host_js = [
|
||||
]
|
||||
plugin_transform_host_native = [
|
||||
"wasmer/default",
|
||||
# wasmer-wasix/default except networking, to avoid unexpected openssl-sys build failure on certain platforms.
|
||||
# [TODO]: revert to /default once issue is resolved"wasmer-wasix/sys",
|
||||
"wasmer-wasix/sys",
|
||||
"wasmer-wasix/logging",
|
||||
"wasmer-wasix/host-fs",
|
||||
@ -73,7 +71,8 @@ wasmer-cache = { version = "3.3.0", optional = true }
|
||||
wasmer-compiler-cranelift = { version = "3.3.0", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3"
|
||||
cargo_metadata = "0.15.4"
|
||||
criterion = "0.3"
|
||||
|
||||
swc_atoms = { version = "0.5.6", path = '../swc_atoms' }
|
||||
swc_css_ast = { version = "0.137.12", path = "../swc_css_ast", features = [
|
||||
|
@ -16,10 +16,21 @@ use swc_common::{
|
||||
};
|
||||
use tracing::info;
|
||||
|
||||
static TARGET_DIR: Lazy<PathBuf> = Lazy::new(|| {
|
||||
cargo_metadata::MetadataCommand::new()
|
||||
.no_deps()
|
||||
.exec()
|
||||
.unwrap()
|
||||
.target_directory
|
||||
.into()
|
||||
});
|
||||
|
||||
/// Returns the path to the built plugin
|
||||
fn build_plugin(dir: &Path) -> Result<PathBuf, Error> {
|
||||
{
|
||||
let mut cmd = Command::new("cargo");
|
||||
cmd.env("CARGO_TARGET_DIR", &*TARGET_DIR);
|
||||
|
||||
cmd.current_dir(dir);
|
||||
cmd.args(["build", "--target=wasm32-wasi", "--release"])
|
||||
.stderr(Stdio::inherit());
|
||||
@ -34,7 +45,7 @@ fn build_plugin(dir: &Path) -> Result<PathBuf, Error> {
|
||||
}
|
||||
}
|
||||
|
||||
for entry in fs::read_dir(&dir.join("target").join("wasm32-wasi").join("release"))? {
|
||||
for entry in fs::read_dir(&TARGET_DIR.join("wasm32-wasi").join("release"))? {
|
||||
let entry = entry?;
|
||||
|
||||
let s = entry.file_name().to_string_lossy().into_owned();
|
||||
|
@ -19,10 +19,20 @@ use swc_ecma_ast::{CallExpr, Callee, EsVersion, Expr, Lit, MemberExpr, Program,
|
||||
use swc_ecma_parser::{parse_file_as_program, Syntax};
|
||||
use swc_ecma_visit::{Visit, VisitWith};
|
||||
|
||||
static TARGET_DIR: Lazy<PathBuf> = Lazy::new(|| {
|
||||
cargo_metadata::MetadataCommand::new()
|
||||
.no_deps()
|
||||
.exec()
|
||||
.unwrap()
|
||||
.target_directory
|
||||
.into()
|
||||
});
|
||||
|
||||
/// Returns the path to the built plugin
|
||||
fn build_plugin(dir: &Path) -> Result<PathBuf, Error> {
|
||||
{
|
||||
let mut cmd = Command::new("cargo");
|
||||
cmd.env("CARGO_TARGET_DIR", &*TARGET_DIR);
|
||||
cmd.current_dir(dir);
|
||||
cmd.args(["build", "--target=wasm32-wasi"])
|
||||
.stderr(Stdio::inherit());
|
||||
@ -37,7 +47,7 @@ fn build_plugin(dir: &Path) -> Result<PathBuf, Error> {
|
||||
}
|
||||
}
|
||||
|
||||
for entry in fs::read_dir(&dir.join("target").join("wasm32-wasi").join("debug"))? {
|
||||
for entry in fs::read_dir(&TARGET_DIR.join("wasm32-wasi").join("debug"))? {
|
||||
let entry = entry?;
|
||||
|
||||
let s = entry.file_name().to_string_lossy().into_owned();
|
||||
|
@ -18,10 +18,20 @@ use swc_ecma_ast::{EsVersion, Program};
|
||||
use swc_ecma_parser::{parse_file_as_program, Syntax, TsConfig};
|
||||
use tracing::info;
|
||||
|
||||
static TARGET_DIR: Lazy<PathBuf> = Lazy::new(|| {
|
||||
cargo_metadata::MetadataCommand::new()
|
||||
.no_deps()
|
||||
.exec()
|
||||
.unwrap()
|
||||
.target_directory
|
||||
.into()
|
||||
});
|
||||
|
||||
/// Returns the path to the built plugin
|
||||
fn build_plugin(dir: &Path) -> Result<PathBuf, Error> {
|
||||
{
|
||||
let mut cmd = Command::new("cargo");
|
||||
cmd.env("CARGO_TARGET_DIR", &*TARGET_DIR);
|
||||
cmd.current_dir(dir);
|
||||
cmd.args(["build", "--target=wasm32-wasi", "--release"])
|
||||
.stderr(Stdio::inherit());
|
||||
@ -36,7 +46,7 @@ fn build_plugin(dir: &Path) -> Result<PathBuf, Error> {
|
||||
}
|
||||
}
|
||||
|
||||
for entry in fs::read_dir(&dir.join("target").join("wasm32-wasi").join("release"))? {
|
||||
for entry in fs::read_dir(&TARGET_DIR.join("wasm32-wasi").join("release"))? {
|
||||
let entry = entry?;
|
||||
|
||||
let s = entry.file_name().to_string_lossy().into_owned();
|
||||
|
@ -8,6 +8,7 @@ use std::{
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Error};
|
||||
use once_cell::sync::Lazy;
|
||||
use serde_json::json;
|
||||
#[cfg(feature = "__rkyv")]
|
||||
use swc_common::plugin::serialized::PluginSerializedBytes;
|
||||
@ -16,10 +17,20 @@ use swc_ecma_ast::{CallExpr, Callee, EsVersion, Expr, Lit, MemberExpr, Program,
|
||||
use swc_ecma_parser::{parse_file_as_program, Syntax};
|
||||
use swc_ecma_visit::Visit;
|
||||
|
||||
static TARGET_DIR: Lazy<PathBuf> = Lazy::new(|| {
|
||||
cargo_metadata::MetadataCommand::new()
|
||||
.no_deps()
|
||||
.exec()
|
||||
.unwrap()
|
||||
.target_directory
|
||||
.into()
|
||||
});
|
||||
|
||||
/// Returns the path to the built plugin
|
||||
fn build_plugin(dir: &Path, crate_name: &str) -> Result<PathBuf, Error> {
|
||||
{
|
||||
let mut cmd = Command::new("cargo");
|
||||
cmd.env("CARGO_TARGET_DIR", &*TARGET_DIR);
|
||||
cmd.current_dir(dir);
|
||||
cmd.args(["build", "--release", "--target=wasm32-wasi"])
|
||||
.stderr(Stdio::inherit());
|
||||
@ -34,7 +45,7 @@ fn build_plugin(dir: &Path, crate_name: &str) -> Result<PathBuf, Error> {
|
||||
}
|
||||
}
|
||||
|
||||
for entry in fs::read_dir(&dir.join("target").join("wasm32-wasi").join("release"))? {
|
||||
for entry in fs::read_dir(&TARGET_DIR.join("wasm32-wasi").join("release"))? {
|
||||
let entry = entry?;
|
||||
|
||||
let s = entry.file_name().to_string_lossy().into_owned();
|
||||
|
Loading…
Reference in New Issue
Block a user