Skip to content

Commit 0897d30

Browse files
committed
Install gsed on macOS in CI, revert Makefile gsed check
- Add step to install GNU sed via brew on macOS runners - Revert Makefile to original gsed check at parse time
1 parent ae8cc81 commit 0897d30

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

.github/workflows/actions.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ jobs:
1515
- uses: actions/setup-python@v6
1616
with:
1717
python-version: ${{ matrix.python-version }}
18+
- name: Install GNU sed on macOS
19+
if: runner.os == 'macOS'
20+
run: brew install gnu-sed
1821
- name: Install poetry
1922
run: pip install poetry==${{ matrix.poetry-version}}
2023
- name: Install deps

Makefile

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,30 @@ clean: ## Clean build artifacts
6060
find . -type f -name "*.pyc" -delete 2>/dev/null || true
6161

6262
# Trailing whitespace targets
63-
# Note: fix-trailing-whitespace requires GNU sed (gsed) on macOS
63+
UNAME_S := $(shell uname -s)
64+
ifeq ($(UNAME_S),Darwin)
65+
SED := $(shell command -v gsed 2>/dev/null)
66+
ifeq ($(SED),)
67+
$(error GNU sed (gsed) not found on macOS. Install with: brew install gnu-sed)
68+
endif
69+
else
70+
SED := sed
71+
endif
72+
6473
.PHONY: fix-trailing-whitespace
6574
fix-trailing-whitespace: ## Remove trailing whitespaces from all files
66-
@if [ "$$(uname -s)" = "Darwin" ]; then \
67-
SED=$$(command -v gsed 2>/dev/null); \
68-
if [ -z "$$SED" ]; then \
69-
echo "Error: GNU sed (gsed) not found on macOS."; \
70-
echo "Install with: brew install gnu-sed"; \
71-
exit 1; \
72-
fi; \
73-
else \
74-
SED=sed; \
75-
fi; \
76-
echo "Removing trailing whitespaces from all files..."; \
77-
find . -type f \( \
75+
@echo "Removing trailing whitespaces from all files..."
76+
@find . -type f \( \
7877
-name "*.py" -o -name "*.toml" -o -name "*.md" -o -name "*.yaml" \
7978
-o -name "*.yml" -o -name "*.json" \) \
8079
-not -path "./.git/*" \
8180
-not -path "./.mypy_cache/*" \
8281
-not -path "./.pytest_cache/*" \
8382
-not -path "./.ruff_cache/*" \
84-
-exec sh -c "$$SED -i -e 's/[[:space:]]*$$//' \"\$$1\"" _ {} \; && \
85-
echo "Trailing whitespaces removed."
83+
-exec sh -c \
84+
'$(SED) -i -e "s/[[:space:]]*$$//" "$$1"' \
85+
_ {} \; && \
86+
echo "Trailing whitespaces removed."
8687

8788
.PHONY: check-trailing-whitespace
8889
check-trailing-whitespace: ## Check for trailing whitespaces in source files

0 commit comments

Comments
 (0)