Skip to content

ci: enhance format check with error message#4632

Merged
escapedcat merged 1 commit intoconventional-changelog:masterfrom
knocte:patch-5
Mar 1, 2026
Merged

ci: enhance format check with error message#4632
escapedcat merged 1 commit intoconventional-changelog:masterfrom
knocte:patch-5

Conversation

@knocte
Copy link
Contributor

@knocte knocte commented Mar 1, 2026

Add error message for formatting check failure.

@qodo-code-review
Copy link

Review Summary by Qodo

Add error message to format check failure

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Adds informative error message to format check failure
• Guides users to run 'yarn format-fix' command
• Improves CI feedback clarity for formatting issues
Diagram
flowchart LR
  A["Format Check"] -->|"fails"| B["Run format-fix"]
  B --> C["Check git diff"]
  C -->|"has changes"| D["Display error message"]
  D --> E["Exit with code 1"]
Loading

Grey Divider

File Changes

1. .github/workflows/CI.yml ✨ Enhancement +1/-1

Add error message to format check step

• Enhanced format check step with descriptive error message
• Added explicit exit code 1 on formatting mismatch
• Guides developers to run 'yarn format-fix' command
• Improves CI feedback for formatting failures

.github/workflows/CI.yml


Grey Divider

Qodo Logo

@qodo-code-review
Copy link

qodo-code-review bot commented Mar 1, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Format message not reliable 🐞 Bug ⛯ Reliability
Description
The added error message is placed after git diff --exit-code as a separate command, so when `git
diff --exit-code` exits non-zero (the normal case when formatting changes exist), the message is not
guaranteed to execute depending on shell error handling, undermining the PR goal of showing a
helpful message on formatting mismatch.
Code

.github/workflows/CI.yml[56]

+        run: yarn format || (yarn format-fix; git diff --exit-code; echo "Formatting did not match (see above diff), please run 'yarn format-fix'" >&2 && exit 1)
Evidence
The workflow runs git diff --exit-code before the echo ... message in a simple ;-sequenced
command list. When formatting mismatches exist, yarn format-fix will modify files and `git diff
--exit-code` will return non-zero; because the message is only executed after that command, it is
not robustly guaranteed to run in all CI shell configurations. The intent that format checks and
format-fix writes formatting is confirmed by the scripts in package.json.

.github/workflows/CI.yml[55-56]
package.json[20-21]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The `Check format` step aims to print a helpful error message when formatting does not match. Currently the message is placed after `git diff --exit-code` in a `;`-sequenced list, which makes the message execution unreliable when `git diff` returns non-zero (the common “formatting changed” case) under some shell error-handling modes.

### Issue Context
- `yarn format` runs prettier in `--check` mode.
- On failure, the workflow runs `yarn format-fix` then `git diff --exit-code`.
- The message should be shown when formatting mismatches exist (i.e., when `git diff --exit-code` detects changes after `format-fix`).

### Fix Focus Areas
- .github/workflows/CI.yml[55-56]

### Suggested implementation approach
Replace the one-liner with a multi-line `run: |` script, e.g.:

```yaml
- name: Check format
 run: |
   if ! yarn format; then
     yarn format-fix
     if ! git diff --exit-code; then
       echo "Formatting did not match (see above diff), please run 'yarn format-fix'" >&2
     else
       echo "yarn format failed, but no formatting diff was produced; see logs above" >&2
     fi
     exit 1
   fi
```

This ensures the message prints deterministically and the step fails when `yarn format` fails.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 1, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Add error message for formatting check failure.
@escapedcat escapedcat merged commit b2d06ae into conventional-changelog:master Mar 1, 2026
12 checks passed
This was referenced Mar 3, 2026
This was referenced Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants