Skip to content
Snippets Groups Projects
Commit 4962757c authored by STEVAN Antoine's avatar STEVAN Antoine 🦀
Browse files

use `gitlab.isae-supaero.fr:a.stevan/nob.rs` to build (!202)

that's an attempt at using Rust to build itself.

this is using [`gitlab.isae-supaero.fr:a.stevan/nob.rs@e4b03cdd`](a.stevan/nob.rs@e4b03cdd).

> 💡 **Note**
>
> to be honest, this is not a 100% replacement of the `Makefile`...
>
> `make.rs` does a lot more and provides a full CLI with easy-to-use options, e.g. instead of `make fmt` and `make fmt-check`, we now have `./make.rs fmt` and `./make.rs fmt --check`
>
> (see the API below)

## the API
```
Usage: make [OPTIONS] [COMMAND]

Commands:
  fmt      Formats the code
  check    Checks the code
  clippy   Runs Clippy
  test     Runs the tests
  version  Shows the version of all the tools used,
  doc      Builds the documentation
  help     Print this message or the help of the given subcommand(s)

Options:
  -h, --help      Print help
  -V, --version   Print version
```
```
Usage: make fmt [OPTIONS]

Options:
  -c, --check  Only checks instead of really formatting
```
```
Usage: make check
```
```
Usage: make clippy
```
```
Usage: make test [OPTIONS]

Options:
  -v, --verbose   Be extra verbose with the output of the tests
  -e, --examples  Run the examples instead of regular tests
```
```
Usage: make version
```
```
Usage: make doc [OPTIONS]

Options:
  -o, --open      Open the documentation in the browser
  -p, --private   Document private items
  -f, --features  Document all features
```

## running the pipeline in the GitHub mirror
```bash
const GH_API_OPTIONS = [
    -H "Accept: application/vnd.github+json"
    -H "X-GitHub-Api-Version: 2022-11-28"
]
let res = gh api ...$GH_API_OPTIONS /repos/dragoon-rs/komodo/actions/runs | from json
```
```bash
let runs = $res.workflow_runs
    | where head_branch == "use-nob-to-build"
    | select id head_sha status conclusion run_started_at
    | into datetime run_started_at
    | sort-by run_started_at
```
```bash
$runs
    | update id { $"[`($in)`]\(https://github.com/($GITHUB_MIRROR)/actions/runs/($in)\)" }
    | update run_started_at { format date "%Y-%m-%dT%H:%M:%S" }
    | to md --pretty
```
| id                                                                             | head_sha                                 | status    | conclusion | run_started_at      |
| ------------------------------------------------------------------------------ | ---------------------------------------- | --------- | ---------- | ------------------- |
| [`14237650542`](https://github.com/dragoon-rs/komodo/actions/runs/14237650542) | d67f1cfd | completed | success    | 2025-04-03T07:44:14 |
| [`14237741570`](https://github.com/dragoon-rs/komodo/actions/runs/14237741570) | 9ef598a1 | completed | success    | 2025-04-03T07:49:40 |
| [`14238086977`](https://github.com/dragoon-rs/komodo/actions/runs/14238086977) | 0a79edf3 | completed | success    | 2025-04-03T08:09:13 |
| [`14238175174`](https://github.com/dragoon-rs/komodo/actions/runs/14238175174) | a84b2b12 | completed | success    | 2025-04-03T08:13:52 |
| [`14239395984`](https://github.com/dragoon-rs/komodo/actions/runs/14239395984) | 8594c9bf | completed | success    | 2025-04-03T09:16:00 |
parent 1519af49
No related branches found
No related tags found
1 merge request!202use `gitlab.isae-supaero.fr:a.stevan/nob.rs` to build
Pipeline #8294 passed
...@@ -17,8 +17,12 @@ jobs: ...@@ -17,8 +17,12 @@ jobs:
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
toolchain: stable toolchain: stable
- name: Install dependencies
run: |
cargo install cargo-script
- name: Run fmt check - name: Run fmt check
run: make fmt-check run: |
./make.rs fmt --check
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
...@@ -31,8 +35,12 @@ jobs: ...@@ -31,8 +35,12 @@ jobs:
sudo apt update --yes sudo apt update --yes
sudo apt upgrade --yes sudo apt upgrade --yes
sudo apt install protobuf-compiler --yes sudo apt install protobuf-compiler --yes
cargo install cargo-script
- name: Show configuration - name: Show configuration
run: make show run: |
./make.rs version
- name: Run tests - name: Run tests
run: | run: |
make check clippy test ./make.rs check
./make.rs clippy
./make.rs test
...@@ -16,9 +16,10 @@ workflow: ...@@ -16,9 +16,10 @@ workflow:
fmt: fmt:
stage: fmt stage: fmt
before_script:
- cargo install cargo-script
script: script:
- make fmt-check - ./make.rs fmt --check
test: test:
stage: test stage: test
...@@ -28,7 +29,10 @@ test: ...@@ -28,7 +29,10 @@ test:
- apt update --yes - apt update --yes
- apt upgrade --yes - apt upgrade --yes
- apt install protobuf-compiler --yes - apt install protobuf-compiler --yes
- make show - cargo install cargo-script
- ./make.rs version
script: script:
- make check clippy test - ./make.rs check
- ./make.rs clippy
- ./make.rs test
DEFAULT_GOAL: fmt-check check clippy test
.PHONY: fmt-check
fmt-check:
cargo fmt --all -- --check
.PHONY: fmt
fmt:
cargo fmt --all
.PHONY: check
check:
cargo check --workspace --all-targets
cargo check --workspace --all-targets --features kzg
cargo check --workspace --all-targets --features aplonk
cargo check --workspace --all-targets --all-features
.PHONY: clippy
clippy:
cargo clippy --workspace --all-targets --all-features -- -D warnings
.PHONY: test
test:
cargo test --workspace --verbose --all-features
cargo test --examples --verbose
.PHONY: show
show:
@rustup --version 2> /dev/null
@rustup show active-toolchain
@rustc --version
@cargo --version
@cargo clippy --version
.PHONY: doc
doc:
RUSTDOCFLAGS="--html-in-header katex.html" cargo doc --no-deps --open
.PHONY: build-examples
build-examples:
cargo build --examples --release
print-%:
@echo $($*)
...@@ -11,11 +11,9 @@ see `cargo doc` or [the library itself](src/) ...@@ -11,11 +11,9 @@ see `cargo doc` or [the library itself](src/)
## the tests ## the tests
```shell ```shell
make ./make.rs check
``` ./make.rs clippy
or ./make.rs test
```shell
make check clippy test
``` ```
Other examples that showcase the Komodo API are available in [`examples/`](examples/). Other examples that showcase the Komodo API are available in [`examples/`](examples/).
......
make.rs 0 → 100755
#!/usr/bin/env run-cargo-script
//! ```cargo
//! [package]
//! name = "komodo-make"
//! version = "1.0.0"
//! edition = "2021"
//!
//! [dependencies]
//! nob = { git = "https://gitlab.isae-supaero.fr/a.stevan/nob.rs", rev = "e4b03cdd4f1ba9daf3095930911b12fb28b6a248" }
//! clap = { version = "4.5.17", features = ["derive"] }
//! ```
extern crate clap;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(version, about, long_about = None)]
struct Cli {
#[command(subcommand)]
command: Option<Commands>,
}
#[derive(Subcommand)]
enum Commands {
/// Formats the code.
Fmt {
/// Only checks instead of really formatting.
#[arg(short, long)]
check: bool,
},
/// Checks the code.
Check,
/// Runs Clippy.
Clippy,
/// Runs the tests.
Test {
/// Be extra verbose with the output of the tests.
#[arg(short, long)]
verbose: bool,
/// Run the examples instead of regular tests.
#[arg(short, long)]
examples: bool,
},
/// Shows the version of all the tools used,
Version,
/// Builds the documentation
Doc {
/// Open the documentation in the browser.
#[arg(short, long)]
open: bool,
/// Document private items.
#[arg(short, long)]
private: bool,
/// Document all features.
#[arg(short, long)]
features: bool,
},
}
#[rustfmt::skip]
fn main() {
let cli = Cli::parse();
match &cli.command {
Some(Commands::Fmt { check }) => {
if *check {
nob::run_cmd_and_fail!("cargo", "fmt", "--all", "--", "--check");
} else {
nob::run_cmd_and_fail!("cargo", "fmt", "--all");
}
}
Some(Commands::Check) => {
nob::run_cmd_and_fail!("cargo", "check", "--workspace", "--all-targets");
nob::run_cmd_and_fail!("cargo", "check", "--workspace", "--all-targets", "--features", "kzg");
nob::run_cmd_and_fail!("cargo", "check", "--workspace", "--all-targets", "--features", "aplonk");
nob::run_cmd_and_fail!("cargo", "check", "--workspace", "--all-targets", "--all-features");
}
Some(Commands::Clippy) => {
nob::run_cmd_and_fail!(
"cargo",
"clippy",
"--workspace",
"--all-targets",
"--all-features",
"--",
"-D",
"warnings"
)
}
Some(Commands::Test { verbose, examples }) => {
let mut cmd = vec!["cargo", "test"];
if *verbose { cmd.push("--verbose") }
if *examples {
cmd.push("--examples");
} else {
cmd.push("--workspace");
cmd.push("--all-features");
}
nob::run_cmd_as_vec_and_fail!(cmd);
}
Some(Commands::Version) => {
nob::run_cmd_and_fail!(@"rustup", "--version", "2>", "/dev/null");
nob::run_cmd_and_fail!(@"rustup", "show", "active-toolchain");
nob::run_cmd_and_fail!(@"rustc", "--version");
nob::run_cmd_and_fail!(@"cargo", "--version");
nob::run_cmd_and_fail!(@"cargo", "clippy", "--version");
}
Some(Commands::Doc {
open,
private,
features,
}) => {
let mut cmd = vec!["cargo", "doc", "--no-deps"];
if *open { cmd.push("--open") }
if *private { cmd.push("--document-private-items") }
if *features { cmd.push("--all-features") }
nob::run_cmd_as_vec_and_fail!(cmd ; "RUSTDOCFLAGS" => "--html-in-header katex.html");
},
None => {}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment