Skip to content

Commit

Permalink
CI: install Nushell from latest nightly build (nushell#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
amtoine committed Oct 15, 2023
1 parent a772e1b commit a4a1ca9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 10 deletions.
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/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"
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 @@ -31,7 +31,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 @@ -47,7 +47,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

0 comments on commit a4a1ca9

Please sign in to comment.