Skip to content
Snippets Groups Projects
Commit 5511404f authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

refactor CI and Makefile for Nushell installation (!192)

the idea is to make the installation of Nushell easier to maintain, especially regarding versions, currently pinned to `0.95.0`

> successful run on GitHub: [13032726635](https://github.com/dragoon-rs/komodo/actions/runs/13032726635)

this is also to allow easier testing locally with the same Nushell version as in the CI, e.g.
```bash
# install in `~/.local/bin/` and have multiple versions
make install-nu

hash=$(/tmp/nu --no-config-file --commands 'version | get commit_hash')
nu_bin=$"$HOME/.local/bin/nu-$hash"
cp /tmp/nu $nu_bin

make NU=$nu_bin show test
```
or
```bash
# install in the repo and overwrite each time
make NU_DEST=. install-nu
make NU=./nu show test
```

# changelog
- Makefile
  - split the global `.PHONY` rule into _atomic_ rules next to each _phony_ rule
  - define `NU` and `NU_FLAGS` to allow changing which and how Nushell runs
  - define `NU_ARCH`, `NU_VERSION`, `NU_BUILD` and `NU_DEST` for Nushell installation
  - tweak the output of `make show` a bit
  - add `print-%` rules to print `Makefile` variables, e.g. `make print-NU_FLAGS` would print `--no-config-file`
  - add `make install-nu` to replace the ones from the CIs
- GitLab CI
  - use `make install-nu`
  - export `PATH` with `make print-NU_DEST`
- GitHub CI 
  - use `make install-nu` instead of [github.com:hustcer/setup-nu](https://github.com/hustcer/setup-nu)
  - export `PATH` with `make print-NU_DEST` and `GITHUB_ENV`
parent cc412625
No related branches found
No related tags found
No related merge requests found
...@@ -31,11 +31,13 @@ jobs: ...@@ -31,11 +31,13 @@ jobs:
sudo apt update --yes sudo apt update --yes
sudo apt upgrade --yes sudo apt upgrade --yes
sudo apt install protobuf-compiler --yes sudo apt install protobuf-compiler --yes
- uses: hustcer/setup-nu@v3 - name: Install Nushell
with: run: |
version: "0.95" # looks like the following PATH export does not work and `NU` still needs to be set for some reason to invoke `make`...
echo "PATH=\"$(make print-NU_DEST):$PATH\"" >> $GITHUB_ENV
make install-nu
- name: Show configuration - name: Show configuration
run: make show run: make NU="$(make print-NU_DEST)/nu" show
- name: Run tests - name: Run tests
run: | run: |
make check clippy test example make NU="$(make print-NU_DEST)/nu" check clippy test example
...@@ -4,10 +4,6 @@ stages: ...@@ -4,10 +4,6 @@ stages:
- fmt - fmt
- test - test
variables:
NUSHELL_ARCH: "x86_64-unknown-linux-musl"
NUSHELL_VERSION: "0.95.0"
workflow: workflow:
rules: rules:
- if: $CI_COMMIT_MESSAGE =~ /^(draft|no-ci):/ - if: $CI_COMMIT_MESSAGE =~ /^(draft|no-ci):/
...@@ -31,15 +27,8 @@ test: ...@@ -31,15 +27,8 @@ test:
- apt update --yes - apt update --yes
- apt upgrade --yes - apt upgrade --yes
- apt install protobuf-compiler --yes - apt install protobuf-compiler --yes
- export PATH="$(make print-NU_DEST):$PATH"
- export NUSHELL_BUILD="nu-$NUSHELL_VERSION-$NUSHELL_ARCH" - make install-nu
- export PATH="/tmp/:$PATH"
# install Nushell
- curl -fLo /tmp/nu.tar.gz "https://github.com/nushell/nushell/releases/download/$NUSHELL_VERSION/$NUSHELL_BUILD.tar.gz"
- tar xvf /tmp/nu.tar.gz --directory /tmp
- cp "/tmp/$NUSHELL_BUILD/nu" /tmp/nu
- make show - make show
script: script:
......
.PHONY: fmt fmt-check check clippy test-rs test-nu test example show doc build-examples NU="nu"
NU_FLAGS="--no-config-file"
NU_ARCH="x86_64-unknown-linux-musl"
NU_VERSION="0.95.0"
NU_BUILD="nu-${NU_VERSION}-${NU_ARCH}"
NU_DEST="/tmp/"
DEFAULT_GOAL: fmt-check check clippy test-rs DEFAULT_GOAL: fmt-check check clippy test-rs
.PHONY: fmt-check
fmt-check: fmt-check:
cargo fmt --all -- --check cargo fmt --all -- --check
.PHONY: fmt
fmt: fmt:
cargo fmt --all cargo fmt --all
.PHONY: install-nu
install-nu:
mkdir -p "${NU_DEST}"
curl -fLo "${NU_DEST}/nu.tar.gz" "https://github.com/nushell/nushell/releases/download/${NU_VERSION}/${NU_BUILD}.tar.gz"
tar xvf "${NU_DEST}/nu.tar.gz" --directory "${NU_DEST}"
cp "${NU_DEST}/${NU_BUILD}/nu" "${NU_DEST}/nu"
.PHONY: check
check: check:
nu scripts/check-nushell-files.nu ${NU} ${NU_FLAGS} scripts/check-nushell-files.nu
cargo check --workspace --all-targets cargo check --workspace --all-targets
cargo check --workspace --all-targets --features kzg cargo check --workspace --all-targets --features kzg
cargo check --workspace --all-targets --features aplonk cargo check --workspace --all-targets --features aplonk
cargo check --workspace --all-targets --all-features cargo check --workspace --all-targets --all-features
.PHONY: clippy
clippy: clippy:
cargo clippy --workspace --all-targets --all-features -- -D warnings cargo clippy --workspace --all-targets --all-features -- -D warnings
.PHONY: test-rs
test-rs: test-rs:
cargo test --workspace --verbose --all-features cargo test --workspace --verbose --all-features
cargo test --examples --verbose cargo test --examples --verbose
.PHONY: test-nu
test-nu: test-nu:
nu bins/saclin/tests/cli.nu ${NU} ${NU_FLAGS} bins/saclin/tests/cli.nu
nu bins/saclin/tests/binary.nu ${NU} ${NU_FLAGS} bins/saclin/tests/binary.nu
.PHONY: test
test: test-rs test-nu test: test-rs test-nu
.PHONY: example
example: example:
nu bins/saclin/examples/cli.nu ${NU} ${NU_FLAGS} bins/saclin/examples/cli.nu
.PHONY: show
show: show:
rustup --version @rustup --version 2> /dev/null
rustup show --verbose @rustup show active-toolchain
rustc --version @rustc --version
cargo --version @cargo --version
cargo clippy --version @cargo clippy --version
nu --version @${NU} ${NU_FLAGS} --commands "version"
.PHONY: doc
doc: doc:
cargo doc --document-private-items --no-deps --open cargo doc --document-private-items --no-deps --open
.PHONY: build-examples
build-examples: build-examples:
cargo build --examples --release cargo build --examples --release
print-%:
@echo $($*)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment