Skip to content

Commit

Permalink
feat: Install noir-profiler and noir-inspector (#46)
Browse files Browse the repository at this point in the history
Co-authored-by: Tom French <[email protected]>
  • Loading branch information
vezenovm and TomAFrench authored Feb 20, 2025
1 parent ff9905a commit cf71599
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 10 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,32 @@ jobs:
run: noirup ${{steps.parse.outputs.toolchain}}
- name: Check nargo installation
run: nargo --version
- name: Check noir-inspector installation
run: |
# Fetch the version from `nargo` as to also check the `stable` and `nightly` toolchains
VERSION=$(nargo --version | awk -F' = ' '/nargo version/ {print $2}')
MIN_VERSION="1.0.0-beta.3"
version_gte() {
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]
}
if version_gte "$VERSION" "$MIN_VERSION"; then
noir-inspector --version
fi
- name: Check noir-profiler installation
run: |
# Fetch the version from `nargo` as to also check the `stable` and `nightly` toolchains
VERSION=$(nargo --version | awk -F' = ' '/nargo version/ {print $2}')
MIN_VERSION="1.0.0-beta.3"
version_gte() {
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]
}
if version_gte "$VERSION" "$MIN_VERSION"; then
noir-profiler --version
fi
install-source:
name: Noir ${{matrix.version}} (from source) on ${{matrix.os == 'ubuntu' && 'Linux' || matrix.os == 'macos' && 'macOS' || matrix.os == 'windows' && 'Windows' || '???'}}
Expand Down Expand Up @@ -116,6 +142,32 @@ jobs:
toolchain: -b tags/${{matrix.version}}
- name: Check nargo installation
run: nargo --version
- name: Check noir-inspector installation
run: |
# Fetch the version from `nargo` as to also check the `stable` and `nightly` toolchains
VERSION=$(nargo --version | awk -F' = ' '/nargo version/ {print $2}')
MIN_VERSION="1.0.0-beta.3"
version_gte() {
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]
}
if version_gte "$VERSION" "$MIN_VERSION"; then
noir-inspector --version
fi
- name: Check noir-profiler installation
run: |
# Minimum version which began releasing binaries for the `noir-profiler`
# Account for the extra `v` that prefixes "${{matrix.version}}"
MIN_VERSION="v1.0.0-beta.3"
version_gte() {
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]
}
if version_gte ${{matrix.version}} "$MIN_VERSION"; then
noir-profiler --version
fi
install-action:
name: Noir ${{matrix.toolchain}} (GH action) on ${{matrix.os == 'ubuntu' && 'Linux' || matrix.os == 'macos' && 'macOS' || matrix.os == 'windows' && 'Windows' || '???'}}
Expand Down Expand Up @@ -151,3 +203,30 @@ jobs:
working-directory: ./project
- run: nargo test
working-directory: ./project
- name: Check noir-inspector installation
run: |
# Fetch the version from `nargo` as to also check the `stable` and `nightly` toolchains
VERSION=$(nargo --version | awk -F' = ' '/nargo version/ {print $2}')
MIN_VERSION="1.0.0-beta.3"
version_gte() {
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]
}
if version_gte "$VERSION" "$MIN_VERSION"; then
noir-inspector --version
fi
- name: Check noir-profiler installation
working-directory: ./project
run: |
VERSION=$(nargo --version | awk -F' = ' '/nargo version/ {print $2}')
MIN_VERSION="1.0.0-beta.3"
version_gte() {
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]
}
if version_gte "$VERSION" "$MIN_VERSION"; then
noir-profiler --version
noir-profiler opcodes -a ./target/project.json -o ./target
fi
49 changes: 39 additions & 10 deletions noirup
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -e
NARGO_HOME=${NARGO_HOME-"$HOME/.nargo"}
NARGO_BIN_DIR="$NARGO_HOME/bin"

BINARIES=("nargo" "noir-profiler" "noir-inspector")

main() {
need_cmd git
need_cmd curl
Expand Down Expand Up @@ -62,10 +64,19 @@ main() {
RUSTFLAGS="-C target-cpu=native" ensure cargo build --release $FEATURES # need 4 speed

# Remove prior installations if they exist
rm -f "$NARGO_BIN_DIR/nargo"
for bin in "${BINARIES[@]}"; do
rm -f "$NARGO_BIN_DIR/$bin"
done

# Move the binary into the `nargo/bin` directory
ensure mv "$PWD/target/release/nargo" "$NARGO_BIN_DIR/nargo"
# Move binaries into the `.nargo/bin` directory
for bin in "${BINARIES[@]}"; do
# Move the binary only if it exists.
# This ensures compatibility with older versions of Noir,
# which may not include all binaries listed.
if [ -f "$PWD/target/release/$bin" ]; then
ensure mv "$PWD/target/release/$bin" "$NARGO_BIN_DIR/$bin"
fi
done

say "done"
exit 0
Expand Down Expand Up @@ -121,14 +132,22 @@ main() {
NOIRUP_TAG="${NOIRUP_VERSION}"
fi

say "installing nargo (version ${NOIRUP_VERSION} with tag ${NOIRUP_TAG})"
say "installing Noir binaries (version ${NOIRUP_VERSION} with tag ${NOIRUP_TAG})"

RELEASE_URL="https://github.com/${NOIRUP_REPO}/releases/download/${NOIRUP_TAG}"
fi
BIN_TARBALL_URL="${RELEASE_URL}/nargo-${ARCHITECTURE}-${PLATFORM}.tar.gz"
# Current name for the binary tarball created by Noir.
BIN_TARBALL_URL="${RELEASE_URL}/noir-${ARCHITECTURE}-${PLATFORM}.tar.gz"

# Legacy naming uses the `nargo-` for when noir-lang/noir used to only release a single nargo binary
# Use the legacy naming if `noir-` does not exist
# Force curl to follow redirects with `-L`
if ! curl -L --head --fail --silent "$BIN_TARBALL_URL" >/dev/null 2>&1; then
BIN_TARBALL_URL="${RELEASE_URL}/nargo-${ARCHITECTURE}-${PLATFORM}.tar.gz"
fi

# Download the binaries tarball and unpack it into the .nargo bin directory.
say "downloading latest nargo to '$NARGO_BIN_DIR'"
say "downloading latest Noir binaries to '$NARGO_BIN_DIR'"
ensure curl -# -L $BIN_TARBALL_URL | tar -xzC $NARGO_BIN_DIR

# Prior to v0.3.0, Nargo and the std lib were distributed separated.
Expand Down Expand Up @@ -163,12 +182,22 @@ main() {

RUSTFLAGS="-C target-cpu=native" ensure cargo build --release $FEATURES

# Remove prior installations if they exist
rm -f "$NARGO_BIN_DIR/nargo"

# Move the binary into the `nargo/bin` directory
ensure mv "$PWD/target/release/nargo" "$NARGO_BIN_DIR/nargo"
# Remove prior installations if they exist
for bin in "${BINARIES[@]}"; do
rm -f "$NARGO_BIN_DIR/$bin"
done

# Move binaries into the `.nargo/bin` directory
for bin in "${BINARIES[@]}"; do
# Move the binary only if it exists.
# This ensures compatibility with older versions of Noir,
# which may not include all binaries listed.
if [ -f "$PWD/target/release/$bin" ]; then
ensure mv "$PWD/target/release/$bin" "$NARGO_BIN_DIR/$bin"
fi
done

fi

if [[ $(which nargo) =~ "cargo" ]]; then
Expand Down

0 comments on commit cf71599

Please sign in to comment.