r3bl-org/r3bl-open-core

[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

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 for tui subfolder
  • Create run.nu for tuify subfolder
  • Create run.nu for ansi_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 running log.fish.
  • run.fish: This will simply run the examples. You can watch the logs by running log.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: Use cargo-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 a crash_log.txt file
    (in the tui 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.

  1. It simply turns around and executes each line using whatever shell program is
    specified. On Windows it expects sh to be installed.
  2. And it resets the CWD between each line that it executes in a given recipe.
  3. 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.

  1. 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

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 ๐Ÿ˜„

image