Skip to content

Add a format gate in CI#21

Merged
davidbuzinski merged 13 commits intomainfrom
format-in-ci
Apr 7, 2026
Merged

Add a format gate in CI#21
davidbuzinski merged 13 commits intomainfrom
format-in-ci

Conversation

@davidbuzinski
Copy link
Copy Markdown
Contributor

We already had a npm run format-check that fails the build and a npm run format to fix locally available. This change just adds format-check to our ci script so that the build will fail if there is a formatter finding. The user can correct them by running npm format locally and recommitting. I plan to make this change in all of our actions repos.

Comment thread package.json
"package": "ncc build --minify",
"test": "NODE_OPTIONS='--experimental-vm-modules' jest",
"all": "npm test && npm run build && npm run package",
"all": "npm run format-check && npm test && npm run build && npm run package",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only "manual" change in this PR. All the other changes come from the formatter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can see I let the format-check fail in CI the first build before applying a commit with the fixes to verify the behavior.

Copy link
Copy Markdown
Member

@mcafaro mcafaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably have some instructions for setting up npm format as a git commit hook.

@davidbuzinski
Copy link
Copy Markdown
Contributor Author

We should probably have some instructions for setting up npm format as a git commit hook.

I added our devel/contributing.md, which we didn't have for this repository yet. I ended up adding instructions to add a pre-commit hook to run all CI checks and block the commit if they fail. I don't like the idea of auto-fixing formats in a hook because it's not clear which files should be re-added, and it doesn't seem correct to add all files because you may add files that were modified but not staged. I'd rather just fail the commit and the author can run npm run format.

Comment thread devel/contributing.md Outdated
Comment on lines +17 to +44
## Adding a pre-commit hook

You may choose to run all CI checks before each commit by adding a pre-commit hook. To do so, navigate to the repository root directory, and run the following commands:

_bash (Unix/macOS)_

```sh
echo '#!/bin/sh' > .git/hooks/pre-commit
echo 'npm run ci' >> .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
```

_Command Prompt (Windows)_

```cmd
echo #!/bin/sh > .git\hooks\pre-commit
echo npm run ci >> .git\hooks\pre-commit
```

_PowerShell (Windows)_

```pwsh
Set-Content .git\hooks\pre-commit '#!/bin/sh'
Add-Content .git\hooks\pre-commit 'npm run ci'
```

> **Note:**
> Git hooks are not version-controlled, so you’ll need to set up this hook for each fresh clone of the repository.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mw-hrastega Most of this file is the same as what we have in our other repositories, but this section is new. It is primarily intended as documentation for the devs on our team, but I wanted to include you because it is part of a public repository.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Added some comments.

Comment thread devel/contributing.md Outdated
Comment thread devel/contributing.md Outdated
Comment thread devel/contributing.md Outdated
Comment thread devel/contributing.md Outdated
davidbuzinski and others added 5 commits April 6, 2026 09:35
Bumps [handlebars](https://github.com/handlebars-lang/handlebars.js) from 4.7.8 to 4.7.9.
- [Release notes](https://github.com/handlebars-lang/handlebars.js/releases)
- [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/v4.7.9/release-notes.md)
- [Commits](handlebars-lang/handlebars.js@v4.7.8...v4.7.9)

---
updated-dependencies:
- dependency-name: handlebars
  dependency-version: 4.7.9
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
@davidbuzinski davidbuzinski merged commit 3fd85d6 into main Apr 7, 2026
7 checks passed
@davidbuzinski davidbuzinski deleted the format-in-ci branch April 7, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants