Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[all] Use nu shell scripts (not just or fish) and add Github Actions to build & test on mac & linux #120

Closed
1 of 4 tasks
nazmulidris opened this issue Sep 10, 2023 · 3 comments · Fixed by #149
Closed
1 of 4 tasks
Assignees
Labels
good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed

Comments

@nazmulidris
Copy link
Member

nazmulidris commented Sep 10, 2023

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.

@nazmulidris nazmulidris added help wanted Extra attention is needed good first issue Good for newcomers labels Sep 10, 2023
@nazmulidris nazmulidris changed the title Use nu shell scripts (not just or fish) and add Github Actions to build & test on mac & linux [all] Use nu shell scripts (not just or fish) and add Github Actions to build & test on mac & linux Sep 12, 2023
@fdncred
Copy link

fdncred commented Sep 18, 2023

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.

@nazmulidris
Copy link
Member Author

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

@nazmulidris
Copy link
Member Author

nazmulidris commented Oct 1, 2023

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants