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

CI: install Nushell from latest nightly build #30

Merged
merged 9 commits into from
Oct 15, 2023
Merged
57 changes: 50 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ on:
push:
branches:
- main
workflow_dispatch:

name: continuous-integration

defaults:
run:
shell: bash

jobs:
tests:
strategy:
Expand All @@ -18,13 +23,51 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup Rust toolchain
uses: actions-rust-lang/[email protected]
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"
2 changes: 1 addition & 1 deletion nupm/install.nu
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions nupm/test.nu
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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)'
Expand Down