Skip to content

Commit

Permalink
Merge branch 'master' into docs/add-core-library-intro
Browse files Browse the repository at this point in the history
  • Loading branch information
calldelegation authored Jul 3, 2024
2 parents 88ce400 + edff10d commit 1644ace
Show file tree
Hide file tree
Showing 21 changed files with 574 additions and 313 deletions.
21 changes: 20 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,25 @@ jobs:
mv fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu/fuel-core /usr/local/bin/fuel-core
- name: Run tests
run: cargo test --locked --release -p forc-debug
cargo-test-forc-client:
runs-on: ubuntu-latest
needs: get-fuel-core-version
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
targets: "x86_64-unknown-linux-gnu, wasm32-unknown-unknown"
- uses: Swatinem/rust-cache@v2
- name: Install fuel-core for tests
run: |
curl -sSLf https://github.com/FuelLabs/fuel-core/releases/download/v${{ needs.get-fuel-core-version.outputs.fuel_core_version }}/fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu.tar.gz -L -o fuel-core.tar.gz
tar -xvf fuel-core.tar.gz
chmod +x fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu/fuel-core
mv fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu/fuel-core /usr/local/bin/fuel-core
- name: Run tests
run: cargo test --locked --release -p forc-client
cargo-test-sway-lsp:
runs-on: ubuntu-latest
steps:
Expand All @@ -538,7 +557,7 @@ jobs:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test --locked --release --workspace --exclude forc-debug --exclude sway-lsp
run: cargo test --locked --release --workspace --exclude forc-debug --exclude sway-lsp --exclude forc-client
cargo-unused-deps-check:
runs-on: ubuntu-latest
steps:
Expand Down
27 changes: 26 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions forc-pkg/src/lock.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{pkg, source, DepKind, Edge};
use anyhow::{anyhow, Result};
use forc_tracing::{println_action_green, println_action_red};
use petgraph::{visit::EdgeRef, Direction};
use serde::{Deserialize, Serialize};
use std::{
Expand Down Expand Up @@ -351,10 +352,9 @@ where
true => format!(" {}", pkg.source),
false => String::new(),
};
tracing::info!(
" {} {}{src}",
ansi_term::Colour::Red.bold().paint("Removing"),
ansi_term::Style::new().bold().paint(&pkg.name)
println_action_red(
"Removing",
&format!("{}{src}", ansi_term::Style::new().bold().paint(&pkg.name)),
);
}
}
Expand All @@ -370,10 +370,9 @@ where
true => format!(" {}", pkg.source),
false => "".to_string(),
};
tracing::info!(
" {} {}{src}",
ansi_term::Colour::Green.bold().paint("Adding"),
ansi_term::Style::new().bold().paint(&pkg.name)
println_action_green(
"Adding",
&format!("{}{src}", ansi_term::Style::new().bold().paint(&pkg.name)),
);
}
}
Expand Down
27 changes: 17 additions & 10 deletions forc-pkg/src/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
BuildProfile,
};
use anyhow::{anyhow, bail, Context, Error, Result};
use forc_tracing::println_warning;
use forc_tracing::{println_action_green, println_warning};
use forc_util::{
default_output_directory, find_file_name, kebab_to_snake_case, print_compiling,
print_on_failure, print_warnings,
Expand Down Expand Up @@ -497,7 +497,7 @@ impl BuiltPackage {
let json_abi_path = output_dir.join(program_abi_stem).with_extension("json");
self.write_json_abi(&json_abi_path, minify)?;

info!(" Bytecode size: {} bytes", self.bytecode.bytes.len());
debug!(" Bytecode size: {} bytes", self.bytecode.bytes.len());
// Additional ops required depending on the program type
match self.tree_type {
TreeType::Contract => {
Expand Down Expand Up @@ -531,7 +531,7 @@ impl BuiltPackage {
let hash_file_name = format!("{}{}", &pkg_name, SWAY_BIN_HASH_SUFFIX);
let hash_path = output_dir.join(hash_file_name);
fs::write(hash_path, &bytecode_hash)?;
info!(" Bytecode hash: {}", bytecode_hash);
debug!(" Bytecode hash: {}", bytecode_hash);
}
_ => (),
}
Expand Down Expand Up @@ -713,7 +713,10 @@ impl BuildPlan {
cause,
);
}
info!(" Creating a new `Forc.lock` file. (Cause: {})", cause);
println_action_green(
"Creating",
&format!("a new `Forc.lock` file. (Cause: {})", cause),
);
let member_names = manifests
.iter()
.map(|(_, manifest)| manifest.project.name.to_string())
Expand All @@ -723,7 +726,7 @@ impl BuildPlan {
.map_err(|e| anyhow!("failed to serialize lock file: {}", e))?;
fs::write(lock_path, string)
.map_err(|e| anyhow!("failed to write lock file: {}", e))?;
info!(" Created new lock file at {}", lock_path.display());
debug!(" Created new lock file at {}", lock_path.display());
}

Ok(plan)
Expand Down Expand Up @@ -2171,11 +2174,13 @@ pub fn build_with_options(build_options: &BuildOpts) -> Result<Built> {
)?;
let output_dir = pkg.output_directory.as_ref().map(PathBuf::from);

let finished = ansi_term::Colour::Green.bold().paint("Finished");
info!(
" {finished} {} in {:.2}s",
profile_target_string(&build_profile.name, build_target),
build_start.elapsed().as_secs_f32()
println_action_green(
"Finished",
&format!(
"{} in {:.2}s",
profile_target_string(&build_profile.name, build_target),
build_start.elapsed().as_secs_f32()
),
);
for (node_ix, built_package) in built_packages {
print_pkg_summary_header(&built_package);
Expand Down Expand Up @@ -2299,6 +2304,8 @@ pub fn build(
let manifest = &plan.manifest_map()[&pkg.id()];
let program_ty = manifest.program_type().ok();

// TODO: Only print "Compiling" when the dependency is not already compiled.
// https://github.com/FuelLabs/sway/issues/6209
print_compiling(
program_ty.as_ref(),
&pkg.name,
Expand Down
14 changes: 8 additions & 6 deletions forc-pkg/src/source/git/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
source,
};
use anyhow::{anyhow, bail, Context, Result};
use forc_tracing::println_action_green;
use forc_util::git_checkouts_directory;
use serde::{Deserialize, Serialize};
use std::fmt::Display;
Expand All @@ -15,7 +16,6 @@ use std::{
path::{Path, PathBuf},
str::FromStr,
};
use tracing::info;

#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)]
pub struct Url {
Expand Down Expand Up @@ -204,11 +204,13 @@ impl source::Fetch for Pinned {
{
let _guard = lock.write()?;
if !repo_path.exists() {
info!(
" {} {} {}",
ansi_term::Color::Green.bold().paint("Fetching"),
ansi_term::Style::new().bold().paint(ctx.name),
self
println_action_green(
"Fetching",
&format!(
"{} {}",
ansi_term::Style::new().bold().paint(ctx.name),
self
),
);
fetch(ctx.fetch_id(), ctx.name(), self)?;
}
Expand Down
29 changes: 15 additions & 14 deletions forc-pkg/src/source/ipfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::{
source,
};
use anyhow::Result;
use forc_tracing::println_action_green;
use futures::TryStreamExt;
use ipfs_api::IpfsApi;
use ipfs_api_backend_hyper as ipfs_api;
Expand All @@ -14,7 +15,6 @@ use std::{
str::FromStr,
};
use tar::Archive;
use tracing::info;

#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Cid(cid::Cid);
Expand Down Expand Up @@ -67,29 +67,30 @@ impl source::Fetch for Pinned {
{
let _guard = lock.write()?;
if !repo_path.exists() {
info!(
" {} {} {}",
ansi_term::Color::Green.bold().paint("Fetching"),
ansi_term::Style::new().bold().paint(ctx.name),
self
println_action_green(
"Fetching",
&format!(
"{} {}",
ansi_term::Style::new().bold().paint(ctx.name),
self
),
);
let cid = &self.0;
let ipfs_client = ipfs_client();
let dest = cache_dir();
futures::executor::block_on(async {
match ctx.ipfs_node() {
source::IPFSNode::Local => {
info!(
" {} with local IPFS node",
ansi_term::Color::Green.bold().paint("Fetching")
);
println_action_green("Fetching", "with local IPFS node");
cid.fetch_with_client(&ipfs_client, &dest).await
}
source::IPFSNode::WithUrl(ipfs_node_gateway_url) => {
info!(
" {} from {}. Note: This can take several minutes.",
ansi_term::Color::Green.bold().paint("Fetching"),
ipfs_node_gateway_url
println_action_green(
"Fetching",
&format!(
"from {}. Note: This can take several minutes.",
ipfs_node_gateway_url
),
);
cid.fetch_with_gateway_url(ipfs_node_gateway_url, &dest)
.await
Expand Down
5 changes: 5 additions & 0 deletions forc-plugins/forc-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ sway-utils = { version = "0.61.1", path = "../../sway-utils" }
tokio = { version = "1.8", features = ["macros", "rt-multi-thread", "process"] }
tracing = "0.1"

[dev-dependencies]
portpicker = "0.1.1"
tempfile = "3"
toml_edit = "0.21.1"

[[bin]]
name = "forc-deploy"
path = "src/bin/deploy.rs"
Expand Down
5 changes: 5 additions & 0 deletions forc-plugins/forc-client/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ pub const DEVNET_FAUCET_URL: &str = "https://faucet-devnet.fuel.network";
pub const DEVNET_ENDPOINT_URL: &str = "https://devnet.fuel.network";
pub const TESTNET_FAUCET_URL: &str = "https://faucet-testnet.fuel.network";
pub const TESTNET_ENDPOINT_URL: &str = "https://testnet.fuel.network";
/// Default PrivateKey to sign transactions submitted to local node.
pub const DEFAULT_PRIVATE_KEY: &str =
"0xde97d8624a438121b86a1956544bd72ed68cd69f2c99555b08b1e8c51ffd511c";
/// The maximum time to wait for a transaction to be included in a block by the node
pub const TX_SUBMIT_TIMEOUT_MS: u64 = 30_000u64;
Loading

0 comments on commit 1644ace

Please sign in to comment.