chore: begin replacement of Make and ./scripts/gear.sh with Just#4862
chore: begin replacement of Make and ./scripts/gear.sh with Just#4862liferooter wants to merge 17 commits intomasterfrom
./scripts/gear.sh with Just#4862Conversation
Changed Files
|
|
|
||
| - name: "Check clippy" | ||
| run: ./scripts/gear.sh clippy gear --all-targets --all-features --locked | ||
| run: just clippy native |
There was a problem hiding this comment.
its more likely
just clippy :: { workspace ; examples } -> not the point that its wasms
but moreover these steps could be merged into one
| - name: "Install: Cargo extensions" | ||
| uses: ./.github/actions/install-cargo-extensions | ||
|
|
||
| - name: "Show: Versioning" |
There was a problem hiding this comment.
such simple commands could be nameless in CI
There was a problem hiding this comment.
Other such commands, like "Install: Rust toolchain" or "Install: Foundry" are not nameless.
There was a problem hiding this comment.
require() may simplify script
There was a problem hiding this comment.
My custom ensure-* repices are more powerful than Just's require function.
- It shows hint that describes how to install the program.
- It is recipe-specific, not global.
- It is custom enough to be able to check Cargo extensions.
| # Format code via `rustfmt` | ||
| [group('actions')] | ||
| fmt: | ||
| cargo fmt --all | ||
|
|
||
| # Check formatting with `rustfmt` | ||
| [group('checks')] | ||
| fmt-check: | ||
| cargo fmt --all --check |
There was a problem hiding this comment.
| # Format code via `rustfmt` | |
| [group('actions')] | |
| fmt: | |
| cargo fmt --all | |
| # Check formatting with `rustfmt` | |
| [group('checks')] | |
| fmt-check: | |
| cargo fmt --all --check | |
| # Format code via `rustfmt` | |
| [group('actions')] | |
| fmt *ARGS: | |
| cargo fmt --all {{ARGS}} |
There was a problem hiding this comment.
I think having a separate fmt-check recipe is better for some reasons:
- Accepting arguments by
fmtrecipe is not very useful because the only useful argument that can be passed to it is--check. - Recipes with arguments cannot be chained (e.g. we can't run
just fmt typos test-doc), so it makes sense to refrain from using recipes with arguments as much as possible. - Having a separate
fmt-checkrecipe improves autocompletion for this recipe. - Having a separate
fmt-checkrecipe allows to used it as a dependency (like forpre-commit) without causing an argument passing hell like what we have inMakefileandgear.shnow.
| [group('checks')] | ||
| test-doc: | ||
| # Running documentation tests | ||
| __GEAR_WASM_BUILDER_NO_BUILD=1 \ | ||
| SKIP_WASM_BUILD=1 \ | ||
| cargo test --doc --workspace --no-fail-fast |
There was a problem hiding this comment.
| [group('checks')] | |
| test-doc: | |
| # Running documentation tests | |
| __GEAR_WASM_BUILDER_NO_BUILD=1 \ | |
| SKIP_WASM_BUILD=1 \ | |
| cargo test --doc --workspace --no-fail-fast | |
| [group('checks')] | |
| test-doc $__GEAR_WASM_BUILDER_NO_BUILD="1" $SKIP_WASM_BUILD="1": | |
| cargo test --doc --workspace --no-fail-fast |
There was a problem hiding this comment.
It was done on purpose. Using long recipe-specific environment variables makes help messages very ugly and also confuses by being the only thing about running commands that is not printed during recipe execution.
| test: (ensure-cargo "hack") (ensure-cargo "nextest") | ||
| # Running workspace tests | ||
| cargo nextest run \ | ||
| --workspace \ | ||
| --no-fail-fast \ | ||
| --exclude gclient \ | ||
| --exclude gcli \ | ||
| --exclude gsdk \ | ||
| --exclude gear-authorship \ | ||
| --exclude pallet-gear-staking-rewards \ | ||
| --exclude gear-wasm-gen \ | ||
| --exclude demo-stack-allocations \ | ||
| --exclude gring \ | ||
| --exclude runtime-fuzzer \ | ||
| --exclude runtime-fuzzer-fuzz |
There was a problem hiding this comment.
| test: (ensure-cargo "hack") (ensure-cargo "nextest") | |
| # Running workspace tests | |
| cargo nextest run \ | |
| --workspace \ | |
| --no-fail-fast \ | |
| --exclude gclient \ | |
| --exclude gcli \ | |
| --exclude gsdk \ | |
| --exclude gear-authorship \ | |
| --exclude pallet-gear-staking-rewards \ | |
| --exclude gear-wasm-gen \ | |
| --exclude demo-stack-allocations \ | |
| --exclude gring \ | |
| --exclude runtime-fuzzer \ | |
| --exclude runtime-fuzzer-fuzz | |
| test *ARGS: (ensure-cargo "hack") (ensure-cargo "nextest") | |
| # Running workspace tests | |
| cargo nextest run --workspace --all-targets --all-features -E 'not package(/fuzz/)' {{ARGS}} |
There was a problem hiding this comment.
Simplification is done.
Argument passing is a bad idea I think.
- It is not very useful, because for running tests for specific crates or with specific options it's better to use
cargo nextestdirectly for better control and more explicitness. The point of the recipe is to give us a short command for a common non-trivial testing task, not to give us an universal script runner, for which always having all these options by default is not a good idea. - The same reasons as with
fmt-check. Recipes without arguments can be chained, generally cleaner and will never cause argument passing hell.
| # Check all WASM code | ||
| wasm: | ||
| # Checking all WASM code with Clippy | ||
| cargo metadata --no-deps --format-version=1 \ |
There was a problem hiding this comment.
Consider to use shebang scripts and paste lines directly from ./scripts/src/clippy.sh
This makes `pre-commit` recipe a check-only recipe, making it more consistent and also allowing it to be used after adding changes to Git index without need to manually recheck worktree for changes done by `cargo fmt`.
|
Consult with @breathx and decided to be closed |
justfileas an alternative to existingMakefileand./scripts/gear.sh../scripts/gear.shwith usage of Just in some parts of CI../scrpts/gear.shin CI where there's no need for abstraction into a script.