Skip to content

Commit aea5c92

Browse files
Share intermediate build artifacts across all contract builds in e2e tests (#2531)
* Disable metadata generation for e2e contract builds * Shared target directory for all e2e contract builds * Update changelog * Update `Cargo.lock` * ci: disable cache for `examples-contract-build-riscv`
1 parent 641f057 commit aea5c92

File tree

4 files changed

+27
-29
lines changed

4 files changed

+27
-29
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -726,9 +726,12 @@ jobs:
726726
- name: Initialize runner
727727
uses: ./.github/init
728728
with:
729-
cache: true
730-
cache-directories: ${{ github.workspace }}/${{ env.CARGO_TARGET_DIR }}
731-
cache-on-failure: true
729+
# FIXME: (@davidsemakula) This job runs into "No space left" issue while saving cache,
730+
# So cache is disable for now.
731+
# See https://github.com/use-ink/ink/actions/runs/15879206960/job/44775329120?pr=2531#step:11:54
732+
cache: false
733+
#cache-directories: ${{ github.workspace }}/${{ env.CARGO_TARGET_DIR }}
734+
#cache-on-failure: true
732735

733736
- name: Extract branch name
734737
shell: bash

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
### Changed
1414
- Use marker trait for finding ink! storage `struct` during code analysis - [2499](https://github.com/use-ink/ink/pull/2499)
1515
- Solidity ABI compatibility metadata improvements - [#2511](https://github.com/use-ink/ink/pull/2511)
16+
- Share intermediate build artifacts across all contract builds in e2e tests - [#2531](https://github.com/use-ink/ink/pull/2531)
1617

1718
### Fixed
1819
- Update metadata version to version 6 ‒ [#2507](https://github.com/use-ink/ink/pull/2507)

Cargo.lock

Lines changed: 5 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/e2e/src/contract_build.rs

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn build_root_and_contract_dependencies(features: Vec<String>) -> Vec<PathBu
6464
env::set_var("INK_RUSTC_WRAPPER", rustc_wrapper);
6565
}
6666
}
67-
build_contracts(&contract_manifests, features)
67+
build_contracts(&contract_manifests, features, contract_project.target_dir)
6868
}
6969

7070
/// Access manifest paths of contracts which are part of the project in which the E2E
@@ -80,7 +80,7 @@ impl ContractProject {
8080
fn new() -> Self {
8181
let mut cmd = cargo_metadata::MetadataCommand::new();
8282
let env_target_dir = env::var_os("CARGO_TARGET_DIR")
83-
.map(|target_dir| PathBuf::from(target_dir))
83+
.map(PathBuf::from)
8484
.filter(|target_dir| target_dir.is_absolute());
8585
if let Some(target_dir) = env_target_dir.as_ref() {
8686
cmd.env("CARGO_TARGET_DIR", target_dir);
@@ -126,7 +126,7 @@ impl ContractProject {
126126

127127
let package_abi = metadata
128128
.root_package()
129-
.and_then(|package| package_abi(package))
129+
.and_then(package_abi)
130130
.and_then(Result::ok);
131131
log_info(&format!("found root package abi: {:?}", package_abi));
132132

@@ -170,6 +170,7 @@ impl ContractProject {
170170
fn build_contracts(
171171
contract_manifests: &[PathBuf],
172172
features: Vec<String>,
173+
target_dir: PathBuf,
173174
) -> Vec<PathBuf> {
174175
static CONTRACT_BUILD_JOBS: OnceLock<Mutex<HashMap<PathBuf, PathBuf>>> =
175176
OnceLock::new();
@@ -183,7 +184,8 @@ fn build_contracts(
183184
let contract_binary_path = match contract_build_jobs.entry(manifest.clone()) {
184185
Entry::Occupied(entry) => entry.get().clone(),
185186
Entry::Vacant(entry) => {
186-
let contract_binary_path = build_contract(manifest, features.clone());
187+
let contract_binary_path =
188+
build_contract(manifest, features.clone(), target_dir.clone());
187189
entry.insert(contract_binary_path.clone());
188190
contract_binary_path
189191
}
@@ -196,31 +198,27 @@ fn build_contracts(
196198
/// Builds the contract at `manifest_path`, returns the path to the contract
197199
/// PolkaVM build artifact.
198200
fn build_contract(
199-
path_to_cargo_toml: &Path,
200-
additional_features: Vec<String>,
201+
cargo_toml: &Path,
202+
features: Vec<String>,
203+
target_dir: PathBuf,
201204
) -> PathBuf {
202-
let manifest_path = ManifestPath::new(path_to_cargo_toml).unwrap_or_else(|err| {
203-
panic!(
204-
"Invalid manifest path {}: {err}",
205-
path_to_cargo_toml.display()
206-
)
205+
let manifest_path = ManifestPath::new(cargo_toml).unwrap_or_else(|err| {
206+
panic!("Invalid manifest path {}: {err}", cargo_toml.display())
207207
});
208-
// todo add method in Features to just construct with new(features)
209-
let mut features = Features::default();
210-
additional_features.iter().for_each(|f| features.push(f));
211208
let args = ExecuteArgs {
212209
manifest_path,
213210
verbosity: Verbosity::Default,
214211
build_mode: BuildMode::Debug,
215-
features,
212+
features: Features::from(features),
216213
network: Network::Online,
217-
build_artifact: BuildArtifacts::All,
214+
build_artifact: BuildArtifacts::CodeOnly,
218215
unstable_flags: UnstableFlags::default(),
219216
keep_debug_symbols: false,
220217
extra_lints: false,
221218
output_type: OutputType::HumanReadable,
222219
image: ImageVariant::Default,
223220
metadata_spec: None,
221+
target_dir: Some(target_dir),
224222
};
225223

226224
match contract_build::execute(args) {
@@ -232,10 +230,7 @@ fn build_contract(
232230
.expect("Invalid dest bundle path")
233231
}
234232
Err(err) => {
235-
panic!(
236-
"contract build for {} failed: {err}",
237-
path_to_cargo_toml.display()
238-
)
233+
panic!("contract build for {} failed: {err}", cargo_toml.display())
239234
}
240235
}
241236
}

0 commit comments

Comments
 (0)