Skip to content

Commit ff9e2e5

Browse files
authored
Merge pull request #1872 from o1-labs/dw/sed-macos-gnu
Makefile: enforce GNU sed on macOS
2 parents e7be09e + 738e06e commit ff9e2e5

File tree

6 files changed

+71
-6
lines changed

6 files changed

+71
-6
lines changed

.github/workflows/whitespace-check.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,37 @@ jobs:
1616

1717
- name: Check for trailing whitespaces
1818
run: make check-trailing-whitespace
19+
20+
test-fix-whitespace:
21+
timeout-minutes: 5
22+
strategy:
23+
matrix:
24+
os: [ubuntu-latest, macos-latest]
25+
runs-on: ${{ matrix.os }}
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v6
29+
30+
- name: Install GNU sed (macOS)
31+
if: runner.os == 'macOS'
32+
run: ./website/docs/developers/scripts/setup/install-gnu-sed-macos.sh
33+
34+
- name: Create test file with trailing whitespace
35+
run: printf 'line with trailing spaces \nclean line\n' > test-whitespace.md
36+
37+
- name: Run fix-trailing-whitespace
38+
run: make fix-trailing-whitespace
39+
40+
- name: Verify trailing whitespace was removed
41+
run: |
42+
if grep -q '[[:space:]]$' test-whitespace.md; then
43+
echo "ERROR: Trailing whitespace was not removed"
44+
cat -vet test-whitespace.md
45+
exit 1
46+
else
47+
echo "Trailing whitespace successfully removed"
48+
cat -vet test-whitespace.md
49+
fi
50+
51+
- name: Clean up test file
52+
run: rm -f test-whitespace.md

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525

2626
- **Dependencies**: vendor redux-rs into `vendor/redux` to centralize all code
2727
in the monorepo ([#1814](https://github.com/o1-labs/mina-rust/pull/1814))
28+
- **Build System**: enforce GNU sed on macOS, require `brew install gnu-sed`
29+
for `make fix-trailing-whitespace`, add CI test for cross-platform support,
30+
fix [#1864](https://github.com/o1-labs/mina-rust/issues/1864)
31+
([#1872](https://github.com/o1-labs/mina-rust/pull/1872))
2832
- **Dependency**: use tag instead of references of o1-labs/proof-systems, fix
2933
[[#1674](https://github.com/o1-labs/mina-rust/issues/1674)]
3034
([#1673](https://github.com/o1-labs/mina-rust/pull/1673))

CLAUDE.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,5 @@ When modifying CI workflows, especially for performance improvements:
424424
- **MANDATORY**: Run `make fix-trailing-whitespace` before every commit
425425
- **MANDATORY**: Run `make check-trailing-whitespace` to verify no trailing
426426
whitespaces remain
427-
- **macOS only**: After running `make fix-trailing-whitespace` or
428-
`make format-md`, run these commands to clean up backup files created by sed:
429-
```bash
430-
git clean -f -- '*-e' && git clean -f -- '**/*-e'
431-
```
432427
- This applies to ALL file modifications, regardless of file type
433428
- Trailing whitespaces are strictly prohibited in the codebase

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ CIRCUITS_REPO ?= https://github.com/o1-labs/circuit-blobs.git
4242
CIRCUITS_REV ?= main
4343
CIRCUITS_NETWORKS ?= 3.0.0mainnet berkeley-devnet
4444

45+
# Detect GNU sed (macOS requires gsed from Homebrew gnu-sed)
46+
UNAME_S := $(shell uname -s)
47+
ifeq ($(UNAME_S),Darwin)
48+
SED := $(shell command -v gsed 2>/dev/null)
49+
ifeq ($(SED),)
50+
$(error GNU sed (gsed) not found on macOS. Install with: brew install gnu-sed)
51+
endif
52+
else
53+
SED := sed
54+
endif
55+
4556
# Documentation server port
4657
DOCS_PORT ?= 3000
4758

@@ -179,14 +190,16 @@ fix-trailing-whitespace: ## Remove trailing whitespaces from all files
179190
-o -name "*.js" -o -name "*.jsx" -o -name "*.sh" \) \
180191
-not -path "./target/*" \
181192
-not -path "./node_modules/*" \
193+
-not -path "./frontend/.angular/*" \
182194
-not -path "./frontend/node_modules/*" \
183195
-not -path "./frontend/dist/*" \
196+
-not -path "./pkg/*" \
184197
-not -path "./website/node_modules/*" \
185198
-not -path "./website/build/*" \
186199
-not -path "./website/static/api-docs/*" \
187200
-not -path "./website/.docusaurus/*" \
188201
-not -path "./.git/*" \
189-
-exec sh -c 'echo "Processing: $$1"; sed -i'\'''\'' -e "s/[[:space:]]*$$//" "$$1"' _ {} \; && \
202+
-exec sh -c 'echo "Processing: $$1"; $(SED) -i -e "s/[[:space:]]*$$//" "$$1"' _ {} \; && \
190203
echo "Trailing whitespaces removed."
191204

192205
.PHONY: check-trailing-whitespace
@@ -198,8 +211,10 @@ check-trailing-whitespace: ## Check for trailing whitespaces in source files
198211
-o -name "*.js" -o -name "*.jsx" -o -name "*.sh" \) \
199212
-not -path "./target/*" \
200213
-not -path "./node_modules/*" \
214+
-not -path "./frontend/.angular/*" \
201215
-not -path "./frontend/node_modules/*" \
202216
-not -path "./frontend/dist/*" \
217+
-not -path "./pkg/*" \
203218
-not -path "./website/node_modules/*" \
204219
-not -path "./website/build/*" \
205220
-not -path "./website/static/api-docs/*" \

website/docs/developers/getting-started.mdx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import TabItem from "@theme/TabItem";
1010
import InstallRustSh from "!!raw-loader!./scripts/setup/install-rust.sh";
1111
import InstallSystemDepsSh from "!!raw-loader!./scripts/setup/install-system-deps.sh";
1212
import InstallSystemDepsMacOSSh from "!!raw-loader!./scripts/setup/install-system-deps-macos.sh";
13+
import InstallGnuSedMacOSSh from "!!raw-loader!./scripts/setup/install-gnu-sed-macos.sh";
1314

1415
import InstallDockerSh from "!!raw-loader!./scripts/setup/install-docker.sh";
1516
import InstallDockerMacOSSh from "!!raw-loader!./scripts/setup/install-docker-macos.sh";
@@ -142,6 +143,21 @@ The Mina Rust Node maintains strict code quality standards:
142143

143144
<CodeBlock language="bash">{FormatAndLintSh}</CodeBlock>
144145

146+
<!-- prettier-ignore-start -->
147+
148+
:::note macOS users
149+
150+
The `make fix-trailing-whitespace` command requires GNU sed. Install it with
151+
Homebrew:
152+
153+
<CodeBlock language="bash">{InstallGnuSedMacOSSh}</CodeBlock>
154+
155+
The Makefile will automatically use `gsed` on macOS when available.
156+
157+
:::
158+
159+
<!-- prettier-ignore-stop -->
160+
145161
### Working with Makefiles
146162

147163
The project's Makefile provides many helpful commands. View all available
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
brew install gnu-sed

0 commit comments

Comments
 (0)