Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dynamic supported fuel-core version #1190

Merged
merged 22 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
df9d51d
feat: add fuel-core-version script
Br1ght0ne Mar 25, 2024
78f7a42
ci: add fuel-core-version verify to CI
Br1ght0ne Mar 25, 2024
8b667df
chore(fuels): remove fuel-core dev-dependency
Br1ght0ne Mar 25, 2024
125f3ac
feat: use committed version.rs in check_version_compatibility
Br1ght0ne Mar 25, 2024
2a2d6c6
Merge branch 'master' into oleksii/dynamic-supported-core-version
segfault-magnet Mar 28, 2024
3f78bf5
ci: fix task
Br1ght0ne Apr 1, 2024
ab44125
fix: use fuel-core-types for fuel-core version
Br1ght0ne Apr 1, 2024
746c012
Merge branch 'master' into oleksii/dynamic-supported-core-version
Br1ght0ne Apr 1, 2024
b54dd9d
Merge branch 'master' into oleksii/dynamic-supported-core-version
Br1ght0ne Apr 8, 2024
b57a04c
Merge branch 'master' into oleksii/dynamic-supported-core-version
Br1ght0ne Apr 8, 2024
a8a337a
Merge branch 'master' into oleksii/dynamic-supported-core-version
Br1ght0ne May 2, 2024
5be8533
Merge branch 'master' into oleksii/dynamic-supported-core-version
Br1ght0ne May 3, 2024
e67330b
chore: update version.rs file
Br1ght0ne May 3, 2024
966172f
Revert "chore(fuels): remove fuel-core dev-dependency"
Br1ght0ne May 3, 2024
9b0bd72
Merge branch 'master' into oleksii/dynamic-supported-core-version
Br1ght0ne May 4, 2024
6143c31
Update version.rs
Br1ght0ne May 4, 2024
5515a0d
Merge branch 'master' into oleksii/dynamic-supported-core-version
Br1ght0ne May 8, 2024
e41abb0
Merge branch 'master' into oleksii/dynamic-supported-core-version
Br1ght0ne May 18, 2024
037d1dd
chore: confine deps to local Cargo.toml
Br1ght0ne May 21, 2024
108cba3
chore(Cargo.toml): use workspace for versions-replacer
Br1ght0ne May 21, 2024
1482c9d
fix: add versions-replacer to workspace Cargo.toml
Br1ght0ne May 21, 2024
0df926b
Merge branch 'master' into oleksii/dynamic-supported-core-version
Br1ght0ne May 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ jobs:
args: --skip-target-dir
- command: test_wasm
args:
- command: check_fuel_core_version
args:
- command: check_doc_anchors_valid
args:
- command: check_doc_unresolved_links
Expand Down Expand Up @@ -236,6 +238,10 @@ jobs:
cd wasm-tests
wasm-pack test --node

- name: Check that fuel_core version.rs file is up to date
if: ${{ matrix.command == 'check_fuel_core_version' }}
run: cargo run --bin fuel-core-version -- --manifest-path ./Cargo.toml verify

- name: Check for invalid documentation anchors
if: ${{ matrix.command == 'check_doc_anchors_valid' }}
run: cargo run --bin check-docs
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ members = [
"packages/fuels-programs",
"packages/fuels-test-helpers",
"scripts/check-docs",
"scripts/fuel-core-version",
"scripts/versions-replacer",
"wasm-tests",
]
Expand Down Expand Up @@ -100,3 +101,4 @@ fuels-core = { version = "0.62.0", path = "./packages/fuels-core", default-featu
fuels-macros = { version = "0.62.0", path = "./packages/fuels-macros", default-features = false }
fuels-programs = { version = "0.62.0", path = "./packages/fuels-programs", default-features = false }
fuels-test-helpers = { version = "0.62.0", path = "./packages/fuels-test-helpers", default-features = false }
versions-replacer = { version = "0.62.0", path = "./scripts/versions-replacer", default-features = false }
8 changes: 3 additions & 5 deletions packages/fuels-accounts/src/provider/supported_versions.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use semver::Version;

fn get_supported_fuel_core_version() -> Version {
"0.26.0".parse().expect("is valid version")
}
pub const SUPPORTED_FUEL_CORE_VERSION: Version =
include!("../../../../scripts/fuel-core-version/version.rs");

#[derive(Debug, PartialEq, Eq)]
pub(crate) struct VersionCompatibility {
Expand All @@ -13,8 +12,7 @@ pub(crate) struct VersionCompatibility {
}

pub(crate) fn compare_node_compatibility(network_version: Version) -> VersionCompatibility {
let supported_version = get_supported_fuel_core_version();
check_version_compatibility(network_version, supported_version)
check_version_compatibility(network_version, SUPPORTED_FUEL_CORE_VERSION)
}

fn check_version_compatibility(
Expand Down
16 changes: 16 additions & 0 deletions scripts/fuel-core-version/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "fuel-core-version"
version = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
publish = false
repository = { workspace = true }
rust-version = { workspace = true }

[dependencies]
clap = { version = "4.5.3", features = ["derive"] }
color-eyre = "0.6.2"
semver = { workspace = true }
versions-replacer = { workspace = true }
84 changes: 84 additions & 0 deletions scripts/fuel-core-version/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
use std::{
fs,
path::{Path, PathBuf},
};

use clap::{Parser, Subcommand};
use color_eyre::{
eyre::{bail, ContextCompat},
Result,
};
use semver::Version;
use versions_replacer::metadata::collect_versions_from_cargo_toml;

fn get_version_from_toml(manifest_path: impl AsRef<Path>) -> Result<Version> {
let versions = collect_versions_from_cargo_toml(manifest_path)?;
let version = versions["fuel-core-types"].parse::<Version>()?;
Ok(version)
}

fn write_version_to_file(version: Version, version_file_path: impl AsRef<Path>) -> Result<()> {
let Version {
major,
minor,
patch,
..
} = version;
let text = format!("Version::new({major}, {minor}, {patch})");
fs::write(version_file_path, text.as_bytes())?;
Ok(())
}

fn get_version_file_path(
manifest_path: impl AsRef<Path>,
) -> Result<PathBuf, color_eyre::eyre::Error> {
Ok(manifest_path
.as_ref()
.parent()
.wrap_err("Invalid manifest path")?
.join("scripts/fuel-core-version/version.rs"))
}

fn verify_version_from_file(version: Version) -> Result<()> {
let version_from_file: Version = include!("../version.rs");
if version != version_from_file {
bail!(
"fuel_core version in version.rs ({}) doesn't match one in Cargo.toml ({})",
version_from_file,
version
);
}
println!(
"fuel_core versions in versions.rs and Cargo.toml match ({})",
version
);
Ok(())
}

#[derive(Debug, Parser)]
struct App {
#[clap(subcommand)]
command: Command,
#[clap(long)]
manifest_path: PathBuf,
}

#[derive(Debug, Subcommand)]
enum Command {
Write,
Verify,
}

fn main() -> Result<()> {
let App {
command,
manifest_path,
} = App::parse();
let version = get_version_from_toml(&manifest_path)?;
let version_file_path = get_version_file_path(&manifest_path)?;
match command {
Command::Write => write_version_to_file(version, version_file_path)?,
Command::Verify => verify_version_from_file(version)?,
}
Ok(())
}
1 change: 1 addition & 0 deletions scripts/fuel-core-version/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Version::new(0, 26, 0)
Loading