[all] Use nu shell scripts (not just or fish) and add Github Actions to build & test on mac & linux
Closed this issue ยท 3 comments
Example of nu script
ansi_color
sub-folder (r3bl_ansi_color
crate): https://github.com/r3bl-org/r3bl_rs_utils/blob/main/ansi_color/run.nu- Template: https://github.com/r3bl-org/nu_script_template
More info on nu shell scripting itself: https://www.nushell.sh/book/scripts.html
Task
- Create
run.nu
for the main top level project folder (there are a lot of.fish
scripts here, eg:check-licenses.fish
,run.fish
, etc) - Create
run.nu
fortui
subfolder - Create
run.nu
fortuify
subfolder - Create
run.nu
foransi_color
subfolder
Short list of scripts in the top level folder (workspace)
run-release.fish
: This will simply run the examples w/ the release build (so it will be fast).
You can watch the logs by runninglog.fish
.run.fish
: This will simply run the examples. You can watch the logs by runninglog.fish
.test.fish
: Run all the tests (in all crates in the Rust workspace).build.fish
: build the code in all the crates in the Rust workspace.log.fish
: Run the logger to see log output.check-licenses.fish
: Usecargo-deny
to audit all licenses used in the Rust workspace.run-with-flamegraph-profiling.fish
: This will run the examples and generate a flamegraph at the
end so you can see profile the performance of the app.run-with-crash-reporting.fish
: This will run the examples and generate acrash_log.txt
file
(in thetui
folder) in case the app crashes. This is useful for debugging.- and more...
Background
The experiment w/ using just
has failed. It doesn't make any sense to use it. Here's what it does. Let's say you have a justfile
that looks like this:
list:
ls -l
And you run it by typing just list
. It just turns around and runs this sh -c "ls -l"
.
That's it. So on Windows, this doesn't work, because sh
isn't installed by default. So
you have to install cygwin or something like that. And then you have to install just
and
then you have to install sh
. Not a good experience.
- It simply turns around and executes each line using whatever shell program is
specified. On Windows it expectssh
to be installed. - And it resets the CWD between each line that it executes in a given recipe.
- The entire thing is very confusing. And it doesn't offer any value on top of the
underlying shell that is installed and makes requirements for certain shells to be
preinstalled.
Instead, it might be better to use nu
shell scripts to perform the equivalent tasks.
- Remove fish scripts (and justfile) and replace w/
nu
scripts.nu
shell is cross-platform (https://www.nushell.sh/book/programming_in_nu.html)
More info on github actions & rust
More information about nushell's gh action
From: #120 (comment)
We use this GitHub Action, created by one of our maintainers, to use nushell in our CI. https://github.com/marketplace/actions/setup-nu.
Just dropping by to say Hi! ๐๐ป from nushell.
Using unofficial actions-rs
This snippet allows the use of nu
in Github Actions environment.
name: Rust CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install Nu
run: cargo install nu
- name: Build
run: cargo build
Other actions
- https://alican.codes/rust-github-actions
- https://shift.click/blog/github-actions-rust/#quick-setup--overview
- https://dev.to/infinyon/github-actions-best-practices-for-rust-projects-1j9p
Related
Consider using cargo binstall to speed up builds in ci/cd
Tracking issue
Related issue
Once the fixes to r3bl_rs_utils_core
is made (for logging), update Cargo.toml
& use the
release version of this crate. Then publish to crates.io
.
We use this GitHub Action, created by one of our maintainers, to use nushell in our CI. https://github.com/marketplace/actions/setup-nu.
Just dropping by to say Hi! ๐๐ป from nushell.
@fdncred Thanks for the helpful link Darren ๐๐ฝ . nu
is awesome! I will take a look at the GitHub Action that you are using in nushell CI itself. I also plan to write a tutorial about this on developerlife.com as well when this is complete & share it on TWiR.
@Harshil-Jani Can you please reply to this comment so that I can assign this issue to you ๐๐ฝ
Also I sent you an invite via github.com; if you accept it then I will be able to assign you issues w/out you having to comment first ๐