diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23eb542d40c17330f12bc192e7ccb807c165fdb9..3299c95440f30ff9e94d7f0efa38904a2734dab9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,11 +31,13 @@ jobs: sudo apt update --yes sudo apt upgrade --yes sudo apt install protobuf-compiler --yes - - uses: hustcer/setup-nu@v3 - with: - version: "0.95" + - name: Install Nushell + run: | + # 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 - run: make show + run: make NU="$(make print-NU_DEST)/nu" show - name: Run tests run: | - make check clippy test example + make NU="$(make print-NU_DEST)/nu" check clippy test example diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8377911e31caf2cc936b2696cdfd356e29383ce7..625f83b22667fb3039ccc8981dea9b1b54a9b7d3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,10 +4,6 @@ stages: - fmt - test -variables: - NUSHELL_ARCH: "x86_64-unknown-linux-musl" - NUSHELL_VERSION: "0.95.0" - workflow: rules: - if: $CI_COMMIT_MESSAGE =~ /^(draft|no-ci):/ @@ -31,15 +27,8 @@ test: - apt update --yes - apt upgrade --yes - apt install protobuf-compiler --yes - - - export NUSHELL_BUILD="nu-$NUSHELL_VERSION-$NUSHELL_ARCH" - - 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 - + - export PATH="$(make print-NU_DEST):$PATH" + - make install-nu - make show script: diff --git a/Makefile b/Makefile index 79b06bb65324bb2d792ecfb2fb5cdb24ef32fa23..2a89ea42d71d05eb6513a816e43c9e65a6abb81a 100644 --- a/Makefile +++ b/Makefile @@ -1,46 +1,73 @@ -.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 +.PHONY: fmt-check fmt-check: cargo fmt --all -- --check +.PHONY: fmt fmt: 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: - nu scripts/check-nushell-files.nu + ${NU} ${NU_FLAGS} scripts/check-nushell-files.nu cargo check --workspace --all-targets cargo check --workspace --all-targets --features kzg cargo check --workspace --all-targets --features aplonk cargo check --workspace --all-targets --all-features +.PHONY: clippy clippy: cargo clippy --workspace --all-targets --all-features -- -D warnings +.PHONY: test-rs test-rs: cargo test --workspace --verbose --all-features cargo test --examples --verbose +.PHONY: test-nu test-nu: - nu bins/saclin/tests/cli.nu - nu bins/saclin/tests/binary.nu + ${NU} ${NU_FLAGS} bins/saclin/tests/cli.nu + ${NU} ${NU_FLAGS} bins/saclin/tests/binary.nu +.PHONY: test test: test-rs test-nu +.PHONY: example example: - nu bins/saclin/examples/cli.nu + ${NU} ${NU_FLAGS} bins/saclin/examples/cli.nu +.PHONY: show show: - rustup --version - rustup show --verbose - rustc --version - cargo --version - cargo clippy --version - nu --version + @rustup --version 2> /dev/null + @rustup show active-toolchain + @rustc --version + @cargo --version + @cargo clippy --version + @${NU} ${NU_FLAGS} --commands "version" +.PHONY: doc doc: cargo doc --document-private-items --no-deps --open +.PHONY: build-examples build-examples: cargo build --examples --release + +print-%: + @echo $($*)