Skip to content

Commit

Permalink
chore: checking noir formatting in CI (#3828)
Browse files Browse the repository at this point in the history
Fixes #3825
  • Loading branch information
benesjan committed Jan 4, 2024
1 parent f8976ad commit b53bacf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
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

0 comments on commit b53bacf

Please sign in to comment.