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

Add initial nightly build and refactor existing CI workflow #168

Merged
merged 8 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
xtask = "run --quiet --package xtask --"
36 changes: 22 additions & 14 deletions .github/workflows/test.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
on: [push, pull_request]
name: CI

name: Test
on:
push:
branches:
- main
pull_request:
merge_group:

permissions:
contents: read

jobs:
checks:
name: Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable

- name: Run cargo fmt
run: rustup toolchain install nightly && rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt && cargo +nightly fmt -- --check
- name: Run cargo clippy
wawel37 marked this conversation as resolved.
Show resolved Hide resolved
run: cargo clippy -- -D warnings
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable

- name: Get corelib
run: git clone https://github.com/starkware-libs/cairo

- name: Install toolchain
run: rustup show

- uses: Swatinem/rust-cache@v2

- name: Run cargo clippy
run: cargo clippy -- -D warnings

- name: Run cargo test
run: CORELIB_PATH="$(pwd)/cairo/corelib/src" cargo test

- name: Run cargo fmt
run: rustup toolchain install nightly && rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt && cargo +nightly fmt -- --check
23 changes: 23 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Nightly

on:
schedule:
- cron: "0 0 * * *"

permissions:
contents: read

jobs:
build:
name: Build nightly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable

- name: Upgrade Cairo to latest main commit
run: cargo xtask upgrade cairo --rev $(git ls-remote --refs "https://github.com/starkware-libs/cairo" main | awk '{print $1}')
- name: Get corelib
run: git clone https://github.com/starkware-libs/cairo
- name: Run cargo test
run: CORELIB_PATH="$(pwd)/cairo/corelib/src" cargo test
36 changes: 29 additions & 7 deletions Cargo.lock

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

33 changes: 23 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"crates/cairo-lint-core",
"crates/cairo-lint-dev",
"crates/cairo-lint-test-utils",
"xtask"
]

[workspace.package]
Expand All @@ -14,16 +15,16 @@ repository = "https://github.com/keep-starknet-strange/cairo-lint"
license-file = "LICENSE"

[workspace.dependencies]
cairo-lang-compiler = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-semantic = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-filesystem = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-diagnostics = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-test-plugin = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-syntax = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-defs = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-test-utils = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-compiler = "*"
mkaput marked this conversation as resolved.
Show resolved Hide resolved
cairo-lang-utils = "*"
cairo-lang-semantic = "*"
cairo-lang-filesystem = "*"
cairo-lang-diagnostics = "*"
cairo-lang-test-plugin = "*"
cairo-lang-syntax = "*"
cairo-lang-defs = "*"
cairo-lang-starknet = "*"
cairo-lang-test-utils = "*"
test-case = "3.0"
pretty_assertions = "1.4.1"
ctor = "0.2.9"
Expand All @@ -36,3 +37,15 @@ smol_str = "0.2.2"
annotate-snippets = "0.11.5"
num-bigint = "0.4.6"
if_chain = "1.0.2"

[patch.crates-io]
wawel37 marked this conversation as resolved.
Show resolved Hide resolved
cairo-lang-compiler = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-semantic = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-filesystem = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-diagnostics = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-test-plugin = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-syntax = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-defs = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
cairo-lang-test-utils = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" }
10 changes: 10 additions & 0 deletions xtask/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "xtask"
version = "1.0.0"
edition.workspace = true
publish = false

[dependencies]
anyhow.workspace = true
clap.workspace = true
cairo-toolchain-xtasks = "1"
33 changes: 33 additions & 0 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use clap::Parser;

macro_rules! command {
($enum_name:ident ( $($module:ident,)+ )) => {
$(mod $module;)+

#[derive(::clap::Subcommand)]
#[allow(non_camel_case_types)]
enum $enum_name {
$($module(crate::$module::Args),)+
}

impl $enum_name {
fn main(self) -> ::anyhow::Result<()> {
match self {
$(Self::$module(args) => crate::$module::main(args),)+
}
}
}
}
}

command!(Command(upgrade,));

#[derive(Parser)]
struct Args {
#[command(subcommand)]
command: Command,
}

fn main() {
let _ = Args::parse().command.main();
}
1 change: 1 addition & 0 deletions xtask/src/upgrade.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub use cairo_toolchain_xtasks::upgrade::{main, Args};
Loading