Skip to content

Commit cf71599

Browse files
vezenovmTomAFrench
andauthored
feat: Install noir-profiler and noir-inspector (#46)
Co-authored-by: Tom French <[email protected]>
1 parent ff9905a commit cf71599

File tree

2 files changed

+118
-10
lines changed

2 files changed

+118
-10
lines changed

.github/workflows/ci.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,32 @@ jobs:
7979
run: noirup ${{steps.parse.outputs.toolchain}}
8080
- name: Check nargo installation
8181
run: nargo --version
82+
- name: Check noir-inspector installation
83+
run: |
84+
# Fetch the version from `nargo` as to also check the `stable` and `nightly` toolchains
85+
VERSION=$(nargo --version | awk -F' = ' '/nargo version/ {print $2}')
86+
MIN_VERSION="1.0.0-beta.3"
87+
88+
version_gte() {
89+
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]
90+
}
91+
92+
if version_gte "$VERSION" "$MIN_VERSION"; then
93+
noir-inspector --version
94+
fi
95+
- name: Check noir-profiler installation
96+
run: |
97+
# Fetch the version from `nargo` as to also check the `stable` and `nightly` toolchains
98+
VERSION=$(nargo --version | awk -F' = ' '/nargo version/ {print $2}')
99+
MIN_VERSION="1.0.0-beta.3"
100+
101+
version_gte() {
102+
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]
103+
}
104+
105+
if version_gte "$VERSION" "$MIN_VERSION"; then
106+
noir-profiler --version
107+
fi
82108
83109
install-source:
84110
name: Noir ${{matrix.version}} (from source) on ${{matrix.os == 'ubuntu' && 'Linux' || matrix.os == 'macos' && 'macOS' || matrix.os == 'windows' && 'Windows' || '???'}}
@@ -116,6 +142,32 @@ jobs:
116142
toolchain: -b tags/${{matrix.version}}
117143
- name: Check nargo installation
118144
run: nargo --version
145+
- name: Check noir-inspector installation
146+
run: |
147+
# Fetch the version from `nargo` as to also check the `stable` and `nightly` toolchains
148+
VERSION=$(nargo --version | awk -F' = ' '/nargo version/ {print $2}')
149+
MIN_VERSION="1.0.0-beta.3"
150+
151+
version_gte() {
152+
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]
153+
}
154+
155+
if version_gte "$VERSION" "$MIN_VERSION"; then
156+
noir-inspector --version
157+
fi
158+
- name: Check noir-profiler installation
159+
run: |
160+
# Minimum version which began releasing binaries for the `noir-profiler`
161+
# Account for the extra `v` that prefixes "${{matrix.version}}"
162+
MIN_VERSION="v1.0.0-beta.3"
163+
164+
version_gte() {
165+
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]
166+
}
167+
168+
if version_gte ${{matrix.version}} "$MIN_VERSION"; then
169+
noir-profiler --version
170+
fi
119171
120172
install-action:
121173
name: Noir ${{matrix.toolchain}} (GH action) on ${{matrix.os == 'ubuntu' && 'Linux' || matrix.os == 'macos' && 'macOS' || matrix.os == 'windows' && 'Windows' || '???'}}
@@ -151,3 +203,30 @@ jobs:
151203
working-directory: ./project
152204
- run: nargo test
153205
working-directory: ./project
206+
- name: Check noir-inspector installation
207+
run: |
208+
# Fetch the version from `nargo` as to also check the `stable` and `nightly` toolchains
209+
VERSION=$(nargo --version | awk -F' = ' '/nargo version/ {print $2}')
210+
MIN_VERSION="1.0.0-beta.3"
211+
212+
version_gte() {
213+
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]
214+
}
215+
216+
if version_gte "$VERSION" "$MIN_VERSION"; then
217+
noir-inspector --version
218+
fi
219+
- name: Check noir-profiler installation
220+
working-directory: ./project
221+
run: |
222+
VERSION=$(nargo --version | awk -F' = ' '/nargo version/ {print $2}')
223+
MIN_VERSION="1.0.0-beta.3"
224+
225+
version_gte() {
226+
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]
227+
}
228+
229+
if version_gte "$VERSION" "$MIN_VERSION"; then
230+
noir-profiler --version
231+
noir-profiler opcodes -a ./target/project.json -o ./target
232+
fi

noirup

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ set -e
44
NARGO_HOME=${NARGO_HOME-"$HOME/.nargo"}
55
NARGO_BIN_DIR="$NARGO_HOME/bin"
66

7+
BINARIES=("nargo" "noir-profiler" "noir-inspector")
8+
79
main() {
810
need_cmd git
911
need_cmd curl
@@ -62,10 +64,19 @@ main() {
6264
RUSTFLAGS="-C target-cpu=native" ensure cargo build --release $FEATURES # need 4 speed
6365

6466
# Remove prior installations if they exist
65-
rm -f "$NARGO_BIN_DIR/nargo"
67+
for bin in "${BINARIES[@]}"; do
68+
rm -f "$NARGO_BIN_DIR/$bin"
69+
done
6670

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

7081
say "done"
7182
exit 0
@@ -121,14 +132,22 @@ main() {
121132
NOIRUP_TAG="${NOIRUP_VERSION}"
122133
fi
123134

124-
say "installing nargo (version ${NOIRUP_VERSION} with tag ${NOIRUP_TAG})"
135+
say "installing Noir binaries (version ${NOIRUP_VERSION} with tag ${NOIRUP_TAG})"
125136

126137
RELEASE_URL="https://github.com/${NOIRUP_REPO}/releases/download/${NOIRUP_TAG}"
127138
fi
128-
BIN_TARBALL_URL="${RELEASE_URL}/nargo-${ARCHITECTURE}-${PLATFORM}.tar.gz"
139+
# Current name for the binary tarball created by Noir.
140+
BIN_TARBALL_URL="${RELEASE_URL}/noir-${ARCHITECTURE}-${PLATFORM}.tar.gz"
141+
142+
# Legacy naming uses the `nargo-` for when noir-lang/noir used to only release a single nargo binary
143+
# Use the legacy naming if `noir-` does not exist
144+
# Force curl to follow redirects with `-L`
145+
if ! curl -L --head --fail --silent "$BIN_TARBALL_URL" >/dev/null 2>&1; then
146+
BIN_TARBALL_URL="${RELEASE_URL}/nargo-${ARCHITECTURE}-${PLATFORM}.tar.gz"
147+
fi
129148

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)