Skip to content

Commit

Permalink
Use cairo-toolchain-xtasks (#1845)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaput authored Dec 13, 2024
1 parent a219376 commit 328062c
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 359 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ jobs:
run: cargo build -p xtask

- name: Upgrade Cairo to latest main commit
run: cargo xtask set-dep-version cairo --rev $(git ls-remote --refs "https://github.com/starkware-libs/cairo" main | awk '{print $1}')
run: cargo xtask upgrade cairo --rev $(git ls-remote --refs "https://github.com/starkware-libs/cairo" main | awk '{print $1}')

- name: Upgrade CairoLS to latest main commit
run: cargo xtask set-dep-version cairols --rev $(git ls-remote --refs "https://github.com/software-mansion/cairols" main | awk '{print $1}')
run: cargo xtask upgrade cairols --rev $(git ls-remote --refs "https://github.com/software-mansion/cairols" main | awk '{print $1}')

- name: Rebuild xtasks after Cargo.toml changes
run: cargo build -p xtask
Expand All @@ -62,7 +62,7 @@ jobs:
echo "nightly_branch=$NIGHTLY_BRANCH" >> $GITHUB_OUTPUT
- name: Set Scarb version build metadata
run: cargo xtask set-scarb-version --build ${{ env.NIGHTLY_TAG }} --no-pre-release
run: cargo xtask sync-version --build ${{ env.NIGHTLY_TAG }} --no-pre-release

- name: Rebuild xtasks after Cargo.toml changes
run: cargo build -p xtask
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ We have a script that edits the `Cargo.toml` file to use a local checkout of the
To use this tool, run:

```shell
cargo xtask set-dep-version cairo --path ../path/to/cairo
cargo xtask upgrade cairo --path ../path/to/cairo
```

And then you can `cargo build` Scarb with your custom Cairo compiler changes.
Expand Down
15 changes: 14 additions & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ repository = "https://github.com/software-mansion/scarb"
# all tools *always* depend on some crates.io versions of Cairo crates and Scarb uses
# [patch.crates.io] table to set final git revision for everything.
#
# To keep our Cargo.toml following this contract, always use `cargo xtask set-dep-version`
# To keep our Cargo.toml following this contract, always use `cargo xtask upgrade`
# for manipulating these dependencies.
[workspace.dependencies]
anyhow = "1"
Expand Down
2 changes: 1 addition & 1 deletion xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ publish = false
# NOTE: Avoid adding new dependencies at all cost. The more complex building of this crate is, the much slower CI is.
[dependencies]
anyhow.workspace = true
cairo-toolchain-xtasks = "1"
clap.workspace = true
semver.workspace = true
serde_json.workspace = true
time.workspace = true
toml_edit.workspace = true
walkdir.workspace = true
xshell.workspace = true
12 changes: 8 additions & 4 deletions xtask/src/get_nightly_version.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use anyhow::Result;
use cairo_toolchain_xtasks::sync_version::expected_version;
use clap::Parser;
use semver::{BuildMetadata, Prerelease, Version};
use time::OffsetDateTime;

use crate::set_scarb_version::expected_scarb_version;

#[derive(Parser)]
pub struct Args {
#[arg(short, long)]
Expand All @@ -23,13 +22,18 @@ pub fn main(args: Args) -> Result<()> {
}

pub fn nightly_version() -> Result<Version> {
let mut version = expected_scarb_version()?;
let mut version = expected_version()?;
version.pre = Prerelease::EMPTY;
version.build = BuildMetadata::new(&nightly_tag()).unwrap();
Ok(version)
}

pub fn nightly_tag() -> String {
let dt = OffsetDateTime::now_utc();
format!("nightly-{}-{:0>2}-{:0>2}", dt.year(), u8::from(dt.month()), dt.day())
format!(
"nightly-{}-{:0>2}-{:0>2}",
dt.year(),
u8::from(dt.month()),
dt.day()
)
}
4 changes: 2 additions & 2 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ command!(Command(
get_nightly_version,
list_binaries,
nightly_release_notes,
set_dep_version,
set_scarb_version,
sync_version,
upgrade,
verify_archive,
));

Expand Down
Loading

0 comments on commit 328062c

Please sign in to comment.