Skip to content

Commit 63fa1d5

Browse files
authored
feat: migrate forc-node from sway to forc monorepo (#819)
Update fuelup to source forc-node from FuelLabs/forc starting with version 0.71.0, with version-based routing to maintain backward compatibility for older versions from the sway repository.
1 parent 4db72fe commit 63fa1d5

3 files changed

Lines changed: 103 additions & 3 deletions

File tree

ci/build-channel/src/main.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,4 +451,29 @@ mod tests {
451451
("forc", "forc-crypto-0.71.0", "forc-crypto")
452452
);
453453
}
454+
455+
#[test]
456+
fn test_forc_node_url_generation() {
457+
let forc_node = Component::from_name("forc-node").unwrap();
458+
459+
// Legacy version (< 0.71.0) should use sway repo with forc-binaries tarball
460+
let legacy = Version::new(0, 70, 1);
461+
let repo = forc_node.repository_for_version(&legacy);
462+
let tag = forc_node.tag_for_version(&legacy);
463+
let prefix = forc_node.tarball_prefix_for_version(&legacy);
464+
assert_eq!(
465+
(repo, tag.as_str(), prefix),
466+
("sway", "v0.70.1", "forc-binaries")
467+
);
468+
469+
// Migrated version (>= 0.71.0) should use forc repo with forc-node tarball
470+
let migrated = Version::new(0, 71, 0);
471+
let repo = forc_node.repository_for_version(&migrated);
472+
let tag = forc_node.tag_for_version(&migrated);
473+
let prefix = forc_node.tarball_prefix_for_version(&migrated);
474+
assert_eq!(
475+
(repo, tag.as_str(), prefix),
476+
("forc", "forc-node-0.71.0", "forc-node")
477+
);
478+
}
454479
}

component/src/lib.rs

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl Component {
118118
pub fn tag_for_version(&self, version: &Version) -> String {
119119
let repo = self.repository_for_version(version);
120120
match (self.name.as_str(), repo) {
121-
("forc-wallet", "forc") | ("forc-crypto", "forc") => {
121+
("forc-wallet", "forc") | ("forc-crypto", "forc") | ("forc-node", "forc") => {
122122
format!("{}-{}", self.name, version)
123123
}
124124
_ => format!("v{}", version),
@@ -563,6 +563,77 @@ mod tests {
563563
);
564564
}
565565

566+
#[test]
567+
fn test_repository_for_version_forc_node_migration() {
568+
let components = Components::collect().unwrap();
569+
let forc_node = components
570+
.component
571+
.get("forc-node")
572+
.expect("forc-node component must exist");
573+
574+
let legacy = Version::new(0, 70, 1);
575+
let migrated = Version::new(0, 71, 0);
576+
577+
assert_eq!(
578+
forc_node.repository_for_version(&legacy),
579+
"sway",
580+
"pre-0.71.0 forc-node versions should use the sway repository"
581+
);
582+
assert_eq!(
583+
forc_node.repository_for_version(&migrated),
584+
"forc",
585+
"0.71.0+ forc-node versions should use the forc monorepo"
586+
);
587+
}
588+
589+
#[test]
590+
fn test_tarball_prefix_for_version_forc_node_migration() {
591+
let components = Components::collect().unwrap();
592+
let forc_node = components
593+
.component
594+
.get("forc-node")
595+
.expect("forc-node component must exist");
596+
597+
let legacy = Version::new(0, 70, 1);
598+
let migrated = Version::new(0, 71, 0);
599+
600+
assert_eq!(
601+
forc_node.tarball_prefix_for_version(&legacy),
602+
"forc-binaries",
603+
"pre-0.71.0 forc-node was bundled in forc-binaries"
604+
);
605+
assert_eq!(
606+
forc_node.tarball_prefix_for_version(&migrated),
607+
"forc-node",
608+
"0.71.0+ forc-node has its own tarball"
609+
);
610+
}
611+
612+
#[test]
613+
fn test_tag_for_version_forc_node_migration() {
614+
let components = Components::collect().unwrap();
615+
let forc_node = components
616+
.component
617+
.get("forc-node")
618+
.expect("forc-node component must exist");
619+
620+
// Legacy versions (< 0.71.0) should use standard v-prefixed tags
621+
let legacy = Version::new(0, 70, 1);
622+
assert_eq!(
623+
forc_node.tag_for_version(&legacy),
624+
"v0.70.1",
625+
"Legacy forc-node versions should use v-prefixed tags"
626+
);
627+
628+
// New versions (>= 0.71.0) in forc repo should use forc-node-prefixed tags
629+
let migrated = Version::new(0, 71, 0);
630+
assert_eq!(
631+
forc_node.tag_for_version(&migrated),
632+
"forc-node-0.71.0",
633+
"Migrated forc-node versions should use forc-node-prefixed tags"
634+
);
635+
}
636+
566637
#[test]
567638
fn test_tag_for_version_standard_components() {
568639
let components = Components::collect().unwrap();

components.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,15 @@ targets = ["linux_amd64", "linux_arm64", "darwin_amd64", "darwin_arm64"]
7777

7878
[component.forc-node]
7979
name = "forc-node"
80-
tarball_prefix = "forc-binaries"
80+
tarball_prefix = "forc-node"
8181
is_plugin = true
8282
executables = ["forc-node"]
83-
repository_name = "sway"
83+
repository_name = "forc"
84+
legacy_repository_name = "sway"
85+
legacy_before = "0.71.0"
86+
legacy_tarball_prefix = "forc-binaries"
8487
targets = ["linux_amd64", "linux_arm64", "darwin_amd64", "darwin_arm64"]
88+
publish = true
8589

8690
[component.forc-publish]
8791
name = "forc-publish"

0 commit comments

Comments
 (0)