diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 330f7b7..33cdadf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,9 +3,14 @@ on: push: branches: - main + workflow_dispatch: name: continuous-integration +defaults: + run: + shell: bash + jobs: tests: strategy: @@ -18,13 +23,51 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup Rust toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1.5.0 - with: - rustflags: "" + - name: Set platform-specific variables + run: | + if [ "${{ runner.os }}" = "Linux" ]; then + echo "ARCH=x86_64-linux-gnu-full" >> $GITHUB_ENV + echo "EXT=tar.gz" >> $GITHUB_ENV + echo "NU_BIN=nu" >> $GITHUB_ENV + echo "CWD=$PWD" >> $GITHUB_ENV + elif [ "${{ runner.os }}" = "Windows" ]; then + echo "ARCH=x86_64-pc-windows-msvc" >> $GITHUB_ENV + echo "EXT=zip" >> $GITHUB_ENV + echo "NU_BIN=nu.exe" >> $GITHUB_ENV + # NOTE: for some reason, `$PWD` gives an incorrect path on Windows, e.g. it looks like + # `/d/a/nupm/nupm` where it should really be `d:\a\nupm\nupm`: this commands changes the + # `/` into `\` and replaces the first part of the path with "x:\" + echo "CWD=$(echo $PWD | tr '/' '\\' | sed 's/^\\\(.\)\\/\1:\\/')" >> $GITHUB_ENV + elif [ "${{ runner.os }}" = "macOS" ]; then + echo "ARCH=x86_64-apple-darwin" >> $GITHUB_ENV + echo "EXT=tar.gz" >> $GITHUB_ENV + echo "NU_BIN=nu" >> $GITHUB_ENV + echo "CWD=$PWD" >> $GITHUB_ENV + fi + + - name: Install Nushell from Nightly + run: | + tarball=$(\ + curl -L https://api.github.com/repos/nushell/nightly/releases \ + | jq 'sort_by(.published_at) | reverse | .[0].assets'\ + | jq '.[] | select(.name | test("${{ env.ARCH }}.${{ env.EXT }}")) | {name, browser_download_url}'\ + ) + name=$(echo $tarball | jq '.name' | tr -d '"' | sed 's/.${{ env.EXT }}$//') + url=$(echo $tarball | jq '.browser_download_url' | tr -d '"') + + curl -fLo $name $url + + if [ "${{ env.EXT }}" = "tar.gz" ]; then + tar xvf $name --directory /tmp + elif [ "${{ env.EXT }}" = "zip" ]; then + unzip $name -d "/tmp/$name" + fi + cp "/tmp/$name/${{ env.NU_BIN }}" "$HOME/${{ env.NU_BIN }}" - - name: Install Nushell - run: cargo install --locked --git https://github.com/nushell/nushell.git nu + - name: Show Nushell Version + run: | + "$HOME/${{ env.NU_BIN }}" --commands "version" - name: Run the tests - run: nu --commands "use $PWD/nupm/; nupm test" + run: | + "$HOME/${{ env.NU_BIN }}" --commands "use ${{ env.CWD }}/nupm/; nupm test" diff --git a/nupm/install.nu b/nupm/install.nu index 799a9ee..684bceb 100644 --- a/nupm/install.nu +++ b/nupm/install.nu @@ -128,7 +128,7 @@ def install-path [ do { cd $tmp_dir - nu $build_file ($pkg_dir | path join 'package.nuon') + ^$nu.current-exe $build_file ($pkg_dir | path join 'package.nuon') } rm -rf $tmp_dir diff --git a/nupm/test.nu b/nupm/test.nu index b797033..ca29a94 100644 --- a/nupm/test.nu +++ b/nupm/test.nu @@ -18,7 +18,7 @@ export def main [ print $'Testing package ($pkg_root)' cd $pkg_root - let tests = nu [ + let tests = ^$nu.current-exe [ --no-config-file --commands 'use tests/ @@ -34,7 +34,7 @@ export def main [ | where ($filter in $it) | par-each {|test| let res = do { - nu [ + ^$nu.current-exe [ --no-config-file --commands $'use tests/; ($test)'