Skip to content

Commit 640823f

Browse files
committed
ci: run markdown formatting check via the Makefile target
The lint workflow duplicated the prettier invocation inline, so it could drift from the Makefile, and the `lint.markdown` target was interactive (prompted y/n) — unusable in CI and in scripts. It also probed a misspelled `node_module` directory. Collapse `lint.markdown` to a single non-interactive target that reformats with prettier, sharing one `PRETTIER_ARGS` definition. CI now runs `make lint.markdown` and fails on any resulting diff, so the workflow and local formatting use the exact same rules. Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
1 parent e0d0520 commit 640823f

2 files changed

Lines changed: 7 additions & 35 deletions

File tree

.github/workflows/lint.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@ jobs:
3939
- name: Install dependencies
4040
run: npm i -g prettier
4141
- name: Check markdown files
42-
run: prettier --prose-wrap never --print-width 300 --check "**/*.md"
42+
run: |
43+
make lint.markdown
44+
git diff --exit-code || { echo "::error::Markdown files are not formatted. Run 'make lint.markdown' and commit the result."; exit 1; }

Makefile

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -249,40 +249,10 @@ lint.local: ## Run lint locally (not in Docker) across all build-tag combinatio
249249
cd cmd/osgen && golangci-lint run --fix --build-tags $(GOLANGCI_LINT_BUILD_TAGS) --timeout=5m -v ./...
250250

251251
package := "prettier"
252-
lint.markdown: ## Check markdown formatting with prettier (same check as CI)
253-
@printf "\033[2m-> Checking node installed...\033[0m\n"
254-
if type node > /dev/null 2>&1 && which node > /dev/null 2>&1 ; then \
255-
node -v; \
256-
echo -e "\033[33m Node is installed, continue...\033[0m\n"; \
257-
else \
258-
echo -e "\033[31m Please install node\033[0m\n"; \
259-
exit 1; \
260-
fi
261-
@printf "\033[2m-> Checking npm installed...\033[0m\n"
262-
if type npm > /dev/null 2>&1 && which npm > /dev/null 2>&1 ; then \
263-
npm -v; \
264-
echo -e "\033[33m NPM is installed, continue...\033[0m\n"; \
265-
else \
266-
echo -e "\033[31m Please install npm\033[0m\n"; \
267-
exit 1; \
268-
fi
269-
@printf "\033[2m-> Checking $(package) installed...\033[0m\n"
270-
if [ `npm list -g | grep -c $(package)` -eq 0 -o ! -d node_module ]; then \
271-
echo -e "\033[33m Installing $(package)...\033[0m"; \
272-
npm install -g $(package) --no-shrinkwrap; \
273-
fi
274-
@printf "\033[2m-> Running markdown lint...\033[0m\n"
275-
if npx $(package) --prose-wrap never --print-width 300 --check "**/*.md"; [[ $$? -ne 0 ]]; then \
276-
echo -e "\033[32m-> Found invalid files. Want to auto-format invalid files? (y/n) \033[0m"; \
277-
read RESP; \
278-
if [ "$$RESP" = "y" ] || [ "$$RESP" = "Y" ]; then \
279-
echo -e "\033[33m Formatting...\033[0m"; \
280-
npx $(package) --prose-wrap never --print-width 300 --write "**/*.md"; \
281-
echo -e "\033[34m \nAll invalid files are formatted\033[0m"; \
282-
else \
283-
echo -e "\033[33m Skipping auto-format. CI will flag any remaining issues.\033[0m"; \
284-
fi \
285-
fi
252+
PRETTIER_ARGS := --prose-wrap never --print-width 300 "**/*.md"
253+
254+
lint.markdown: ## Reformat markdown files with prettier
255+
npx $(package) $(PRETTIER_ARGS) --write
286256

287257

288258
backport: ## Backport one or more commits from main into version branches

0 commit comments

Comments
 (0)