Skip to content
This repository was archived by the owner on Jul 5, 2024. It is now read-only.

Commit c56dca8

Browse files
authored
chore(integration-tests): change build.rs to pull submodules (#1723)
### Description Change integration-tests/build.rs to fetch OZ submodule automatically. ### Type of change - [X] Bug fix (non-breaking change which fixes an issue) ### Rationale I propose to change [integration-tests/build.rs](https://github.com/privacy-scaling-explorations/zkevm-circuits/blob/main/integration-tests/build.rs) to automatically fetch OZ contracts submodule, so that initial rust-analyzer indexation works without errors. Right now it's necessary to fetch the submodule manually or by running [integration-tests/run.sh](https://github.com/privacy-scaling-explorations/zkevm-circuits/blob/main/integration-tests/run.sh). ### How Has This Been Tested? This feature is hard to test neither with unit-tests nor with integration-tests, so it was tested locally, on a new & clean repo and worked without any errors. ### Open question A completed spawned process returns its `exit-status`/code, so possibly it's a good tone to check if it's successful (exit code = 0); though the command is clear and straightforward - that's why I decided not to do that. <hr> ### PR code explanation This PR contains: - Adding new error kind to `BuildError` enum: ```rust /// Failed to pull OZ submodule from github #[error("FailedToPullSubmodule({0:})")] FailedToPullSubmodule(String), ``` - Process spawn to fetch submodule (the same as in [integration-tests/run.sh](https://github.com/privacy-scaling-explorations/zkevm-circuits/blob/main/integration-tests/run.sh#L94): ```rust std::process::Command::new("git") .args([ "submodule", "update", "--init", "--recursive", "--checkout", "contracts/vendor", ]) .spawn() .and_then(|mut child| child.wait()) .map_err(|err| BuildError::FailedToPullSubmodule(err.to_string()))?; ```
1 parent 4f448f6 commit c56dca8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: integration-tests/build.rs

+16
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ pub struct CompiledContract {
2727

2828
#[derive(Error, Debug)]
2929
enum BuildError {
30+
/// Failed to pull OZ submodule from github
31+
#[error("FailedToPullSubmodule({0:})")]
32+
FailedToPullSubmodule(String),
3033
/// Failed to detect solidity compiler or compiler version.
3134
#[error("FailedToGetSolidity({0:})")]
3235
FailedToGetSolidity(String),
@@ -100,6 +103,19 @@ const BINDINGS_DR: &str = "src";
100103
fn main() -> Result<(), BuildError> {
101104
println!("cargo:rerun-if-changed=build.rs");
102105

106+
std::process::Command::new("git")
107+
.args([
108+
"submodule",
109+
"update",
110+
"--init",
111+
"--recursive",
112+
"--checkout",
113+
"contracts/vendor",
114+
])
115+
.spawn()
116+
.and_then(|mut child| child.wait())
117+
.map_err(|err| BuildError::FailedToPullSubmodule(err.to_string()))?;
118+
103119
let solc: Solc = Solc::default();
104120
let _solc_version = solc
105121
.version()

0 commit comments

Comments
 (0)