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

Dev builds #2089

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 23 additions & 5 deletions .github/workflows/_build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ on:
ref:
required: false
type: string
full-verify:
required: false
type: boolean
default: false
include-cairols:
description: "Include CairoLS in build"
type: boolean
default: true
include-stwo:
description: "Include Stwo in build"
type: boolean
default: true
include-lint:
description: "Include CairoLint in build"
type: boolean
default: true

env:
# TODO(#1915): Use stable toolchain once stwo is stable.
Expand Down Expand Up @@ -76,27 +92,29 @@ jobs:
run: echo "CARGO=cross" >> $GITHUB_ENV

- name: Build
run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }} --workspace --exclude scarb-prove --exclude scarb-verify
run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }} --workspace --exclude scarb-prove --exclude scarb-verify ${{ !inputs.include-cairols && '--exclude scarb-cairo-language-server' || ''}} --no-default-features ${{ inputs.include-lint && '--features scarb/scarb-lint' || ''}}

- uses: dtolnay/rust-toolchain@master
if: inputs.include-stwo
with:
target: ${{ matrix.target }}
toolchain: ${{ env.RUST_NIGHTLY_TOOLCHAIN }}

- name: Install cross
if: matrix.cross
if: matrix.cross && inputs.include-stwo
uses: taiki-e/install-action@cross

- name: Enable cross-compilation
if: matrix.cross
if: matrix.cross && inputs.include-stwo
shell: bash
run: echo "CARGO=cross" >> $GITHUB_ENV

- name: Build nightly crates
if: inputs.include-stwo
run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }} -p scarb-prove -p scarb-verify

- name: Create archive
run: cargo xtask create-archive
run: cargo xtask create-archive ${{ !inputs.include-cairols && '--skip-cairols' || '' }} ${{ !inputs.include-stwo && '--skip-stwo' || '' }}
env:
STAGING: scarb-${{ inputs.scarb-tag }}-${{ matrix.target }}
TARGET: ${{ matrix.target }}
Expand Down Expand Up @@ -148,7 +166,7 @@ jobs:
shell: bash
run: |
archive=$(find target/verify -name 'scarb-*.zip' -o -name 'scarb-*.tar.gz')
cargo xtask verify-archive --archive "$archive"
cargo xtask verify-archive --archive "$archive" ${{ inputs.full-verify && '--full' || ''}}
env:
EXPECTED_VERSION: ${{ inputs.scarb-tag }}

Expand Down
47 changes: 44 additions & 3 deletions .github/workflows/build-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,50 @@ name: Dev Build

on:
workflow_dispatch:
inputs:
dry_run:
description: "Dry run"
type: boolean
default: true
upgrade-cairo:
description: "Upgrade Cairo"
type: boolean
default: false
upgrade-cairols:
description: "Upgrade CairoLS"
type: boolean
default: false
upgrade-cairolint:
description: "Upgrade CairoLint"
type: boolean
default: false
# upgrade-stwo:
# description: "Upgrade Stwo"
# type: boolean
# default: false
include-cairols:
description: "Include CairoLS in build"
type: boolean
default: true
include-stwo:
description: "Include Stwo in build"
type: boolean
default: true
include-lint:
description: "Include CairoLint in build"
type: boolean
default: true

jobs:
dev-build:
runs-on: ubuntu-latest
steps:
- run: echo "Hello world!"
uses: ./.github/workflows/nightly.yml
with:
dry_run: ${{ inputs.dry_run }}
upgrade-cairo: ${{ inputs.upgrade-cairo }}
upgrade-cairols: ${{ inputs.upgrade-cairols }}
upgrade-cairolint: ${{ inputs.upgrade-cairolint }}
#upgrade-stwo: ${{ inputs.upgrade-stwo }}
include-cairols: ${{ inputs.include-cairols }}
include-stwo: ${{ inputs.include-stwo }}
include-lint: ${{ inputs.include-lint }}
is_dev: true
67 changes: 66 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,65 @@ on:
description: "Dry run"
type: boolean
default: true
upgrade-cairo:
description: "Upgrade Cairo"
type: boolean
default: true
upgrade-cairols:
description: "Upgrade CairoLS"
type: boolean
default: true
upgrade-cairolint:
description: "Upgrade CairoLint"
type: boolean
default: true
# upgrade-stwo:
# description: "Upgrade Stwo"
# type: boolean
# default: true
workflow_call:
inputs:
dry_run:
description: "Dry run"
type: boolean
default: true
upgrade-cairo:
description: "Upgrade Cairo"
type: boolean
default: true
upgrade-cairols:
description: "Upgrade CairoLS"
type: boolean
default: true
upgrade-cairolint:
description: "Upgrade CairoLint"
type: boolean
default: true
# upgrade-stwo:
# description: "Upgrade Stwo"
# type: boolean
# default: true
include-cairols:
description: "Include CairoLS in build"
type: boolean
default: true
include-stwo:
description: "Include Stwo in build"
type: boolean
default: true
include-lint:
description: "Include CairoLint in build"
type: boolean
default: true
is_dev:
description: "Is this a dev build"
type: boolean
default: false
schedule:
- cron: '0 0 * * 3,6'

concurrency:
group: ${{ github.workflow }}
group: ${{ github.workflow }}-${{ !!inputs.is_dev }}
cancel-in-progress: true

permissions:
Expand All @@ -37,15 +91,19 @@ jobs:
run: cargo build -p xtask

- name: Upgrade Cairo to latest main commit
if: ${{ !contains(inputs.upgrade-cairo, 'false') }}
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
if: ${{ !contains(inputs.upgrade-cairols, 'false') }}
run: cargo xtask upgrade cairols --rev $(git ls-remote --refs "https://github.com/software-mansion/cairols" main | awk '{print $1}')

- name: Upgrade Cairo-lint to latest main commit
if: ${{ !contains(inputs.upgrade-cairolint, 'false') }}
run: cargo xtask upgrade cairolint --rev $(git ls-remote --refs "https://github.com/software-mansion/cairo-lint" main | awk '{print $1}')

# - name: Upgrade stwo-cairo to latest main commit
# if: ${{ !contains(inputs.upgrade-stwo, 'false') }}
# run: cargo xtask upgrade stwo-cairo --rev $(git ls-remote --refs "https://github.com/starkware-libs/stwo-cairo" main | awk '{print $1}')

- name: Rebuild xtasks after Cargo.toml changes
Expand All @@ -54,6 +112,8 @@ jobs:
- name: Determine nightly version
id: version
shell: bash
env:
IS_SCARB_DEV: ${{ !!inputs.is_dev }}
run: |
NIGHTLY_TAG=$(cargo xtask get-nightly-version --tag)
NIGHTLY_VERSION=$(cargo xtask get-nightly-version)
Expand All @@ -74,6 +134,8 @@ jobs:
run: cargo build -p xtask

- name: Compose release notes
env:
IS_SCARB_DEV: ${{ !!inputs.is_dev }}
run: cargo xtask nightly-release-notes > NIGHTLY_RELEASE_NOTES.md

- name: Commit patches
Expand All @@ -99,6 +161,9 @@ jobs:
with:
scarb-tag: v${{ needs.prepare.outputs.nightly_version }}
ref: ${{ needs.prepare.outputs.nightly_branch }}
include-cairols: ${{ !!inputs.include-cairols }}
include-stwo: ${{ !!inputs.include-stwo }}
include-lint: ${{ !!inputs.include-lint }}

upload:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
uses: ./.github/workflows/_build-release.yml
with:
scarb-tag: ${{ github.ref_name }}
full-verify: true

draft:
name: draft release
Expand Down
6 changes: 5 additions & 1 deletion scarb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cairo-lang-starknet.workspace = true
cairo-lang-syntax.workspace = true
cairo-lang-test-plugin.workspace = true
cairo-lang-utils.workspace = true
cairo-lint-core.workspace = true
cairo-lint-core = {workspace = true, optional = true }
camino.workspace = true
clap.workspace = true
convert_case.workspace = true
Expand Down Expand Up @@ -125,3 +125,7 @@ fs_extra.workspace = true
scarb-build-metadata = { path = "../utils/scarb-build-metadata" }
toml.workspace = true
zip.workspace = true

[features]
default = ["scarb-lint"]
scarb-lint = ["dep:cairo-lint-core"]
15 changes: 12 additions & 3 deletions scarb/src/bin/scarb/commands/lint.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
use scarb::ops::{self, LintOptions};

use crate::args::LintArgs;
use anyhow::Result;
use scarb::core::Config;

#[tracing::instrument(skip_all, level = "info")]
pub fn run(args: LintArgs, config: &Config) -> Result<()> {
do_lint(args, config)
}

#[cfg(feature = "scarb-lint")]
fn do_lint(args: LintArgs, config: &Config) -> Result<()> {
use scarb::ops::{self, LintOptions};

let ws = ops::read_workspace(config.manifest_path(), config)?;
let packages = args
.packages_filter
.match_many(&ws)?
.into_iter()
.collect::<Vec<_>>();

ops::lint(
LintOptions {
packages,
Expand All @@ -23,3 +27,8 @@ pub fn run(args: LintArgs, config: &Config) -> Result<()> {
&ws,
)
}

#[cfg(not(feature = "scarb-lint"))]
fn do_lint(_args: LintArgs, _config: &Config) -> Result<()> {
panic!("scarb was not compiled with the `lint` command enabled")
}
14 changes: 9 additions & 5 deletions scarb/src/compiler/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use cairo_lang_filesystem::ids::CrateLongId;
use cairo_lang_semantic::db::PluginSuiteInput;
use cairo_lang_semantic::plugin::PluginSuite;
use cairo_lang_utils::ordered_hash_map::OrderedHashMap;
use cairo_lint_core::plugin::CairoLintAllow;
use smol_str::SmolStr;
use std::collections::HashMap;
use std::path::PathBuf;
Expand All @@ -47,10 +46,7 @@ pub(crate) fn build_scarb_root_database(
proc_macros,
} = PluginsForComponents::collect(ws, unit)?;

plugins
.get_mut(&unit.main_component().id)
.unwrap()
.add_analyzer_plugin::<CairoLintAllow>();
append_lint_plugin(plugins.get_mut(&unit.main_component().id).unwrap());

let main_component_suite = plugins
.get_mut(&unit.main_component().id)
Expand All @@ -72,6 +68,14 @@ pub(crate) fn build_scarb_root_database(
Ok(ScarbDatabase { db, proc_macros })
}

#[cfg(feature = "scarb-lint")]
fn append_lint_plugin(suite: &mut PluginSuite) {
suite.add_analyzer_plugin::<cairo_lint_core::plugin::CairoLintAllow>();
}

#[cfg(not(feature = "scarb-lint"))]
fn append_lint_plugin(_suite: &mut PluginSuite) {}

/// Sets the plugin suites for crates related to the library components
/// according to the `plugins_for_components` mapping.
fn apply_plugins(
Expand Down
7 changes: 5 additions & 2 deletions scarb/src/ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub use clean::*;
pub use compile::*;
pub use expand::*;
pub use fmt::*;
pub use lint::*;
pub use manifest::*;
pub use metadata::*;
pub use new::*;
Expand All @@ -24,7 +23,6 @@ mod clean;
mod compile;
mod expand;
mod fmt;
mod lint;
mod lockfile;
mod manifest;
mod metadata;
Expand All @@ -36,3 +34,8 @@ mod resolve;
mod scripts;
mod subcommands;
mod workspace;

#[cfg(feature = "scarb-lint")]
mod lint;
#[cfg(feature = "scarb-lint")]
pub use lint::*;
2 changes: 1 addition & 1 deletion utils/scarb-test-support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dunce.workspace = true
hyper = "0.14"
indoc.workspace = true
itertools.workspace = true
scarb = { path = "../../scarb" }
scarb = { path = "../../scarb", default-features = false }
scarb-build-metadata = { path = "../scarb-build-metadata" }
scarb-proc-macro-server-types = { path = "../scarb-proc-macro-server-types" }
scarb-ui = { path = "../scarb-ui" }
Expand Down
12 changes: 11 additions & 1 deletion xtask/src/create_archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::path::PathBuf;

use anyhow::Result;
use clap::Parser;
use xshell::{cmd, Shell};
use xshell::{Shell, cmd};

use crate::list_binaries::list_binaries;

Expand All @@ -12,6 +12,10 @@ pub struct Args {
target: Option<String>,
#[arg(short, long, env = "STAGING")]
staging: PathBuf,
#[arg(long)]
skip_cairols: bool,
#[arg(long)]
skip_stwo: bool,
}

pub fn main(args: Args) -> Result<()> {
Expand All @@ -38,6 +42,12 @@ pub fn main(args: Args) -> Result<()> {
}

for bin in list_binaries()? {
if args.skip_cairols && bin == "scarb-cairo-language-server" {
continue;
}
if args.skip_stwo && (bin == "scarb-prove" || bin == "scarb-verify") {
continue;
}
let file_name = format!("{bin}{bin_ext}");
sh.copy_file(
target_dir.join("release").join(&file_name),
Expand Down
Loading