Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: checking noir formatting in CI #3828

Merged
merged 5 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion yarn-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"prepare": "node ./yarn-project-base/scripts/update_package_jsons.mjs && yarn workspaces foreach run prepare && workspaces-to-typescript-project-references --tsconfigPath tsconfig.json && prettier -w */tsconfig.json",
"prepare:check": "node ./yarn-project-base/scripts/update_package_jsons.mjs --check && workspaces-to-typescript-project-references --check --tsconfigPath tsconfig.json",
"docs": "typedoc --out docs/dist && cd docs && yarn serve",
"formatting": "FORCE_COLOR=true yarn workspaces foreach -p -j unlimited -v run formatting",
"formatting": "./run_nargo_fmt.sh --check && FORCE_COLOR=true yarn workspaces foreach -p -j unlimited -v run formatting",
"formatting:fix": "./run_nargo_fmt.sh && FORCE_COLOR=true yarn workspaces foreach -p -v run formatting:fix",
"lint": "yarn eslint --cache --ignore-pattern l1-artifacts .",
"format": "yarn prettier --cache -w .",
Expand Down
21 changes: 19 additions & 2 deletions yarn-project/run_nargo_fmt.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
#!/bin/bash
#!/usr/bin/env bash

nargo_executable="$(git rev-parse --show-toplevel)/noir/target/release/nargo"
# Note: This script formats the files multiple times when the given project is included in a workspace.
# Tackling this became a time sink, so I decided to leave it as is for now.

set -eu

# We set the executable path as if we were in CI
nargo_executable="/usr/src/noir/target/release/nargo"

# Check if nargo_executable exists and is executable
if [ ! -x "$nargo_executable" ]; then
# If not, we try to set a nargo path as if the script was run locally
nargo_executable="$(git rev-parse --show-toplevel)/noir/target/release/nargo"

if [ ! -x "$nargo_executable" ]; then
echo "Error: nargo executable not found"
exit 1
fi
fi

# Find all Nargo.toml files and run 'nargo fmt'
find . -name "Nargo.toml" | while read -r file; do
Expand Down