Skip to content

Commit

Permalink
Add initial nightly build and refactor existing CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
wawel37 committed Dec 16, 2024
1 parent 0483da0 commit f441848
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 7 deletions.
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 --"
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
push:
branches:
- main
# temp
- ci-refactor
pull_request:
merge_group:

permissions:
contents: read

jobs:
checks:
name: Checks
runs-on: ubuntu-latest
steps:
- 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
run: cargo clippy -- -D warnings
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: dtolnay/rust-toolchain@stable
- 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
25 changes: 25 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Nightly

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

permissions:
contents: read

jobs:
build:
name: Build nightly
runs-on: ubuntu-latest
steps:
- 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}')
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: dtolnay/rust-toolchain@stable
- 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.

1 change: 1 addition & 0 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 Down
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};

0 comments on commit f441848

Please sign in to comment.