Skip to content

Commit 07df9f2

Browse files
ci: enforce formatting with prettier
1 parent 396fc60 commit 07df9f2

7 files changed

Lines changed: 70 additions & 4 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
lockfileVersion: '9.0'
2+
3+
settings:
4+
autoInstallPeers: true
5+
excludeLinksFromLockfile: false
6+
7+
importers:
8+
9+
.:
10+
dependencies:
11+
prettier:
12+
specifier: 3.9.8
13+
version: 3.9.8
14+
15+
packages:
16+
17+
prettier@3.9.8:
18+
resolution: {integrity: sha512-WRFq3Wn3WId7LLROfMLdH7xaFr2jR62wU8nLO6rQUOLOxNZUviyJQs1M0iIhLexSFy+L+w0ch66wtoO2jRjG0A==}
19+
engines: {node: '>=14'}
20+
hasBin: true
21+
22+
snapshots:
23+
24+
prettier@3.9.8: {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "mise-npm-install",
3+
"private": true,
4+
"dependencies": {
5+
"prettier": "3.9.8"
6+
}
7+
}

‎.prettierignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# generated files
2+
## release-please
3+
*/CHANGELOG.md
4+
## mise
5+
.mise/

‎.prettierrc.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"proseWrap": "never"
3+
}

‎CONTRIBUTING.md‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,26 @@ Each shared reusable workflow is backed by a Component directory `<name>/` that
77
After editing any `.github/workflows/<name>.yml` for a workflow listed in `release-please-config.json`, run:
88

99
```sh
10-
bash scripts/compute-workflow-sha256.sh
10+
mise run update-checksums
1111
```
1212

13-
This regenerates `<name>/workflow-sha256`, a checksum of the workflow file. Commit the resulting diff alongside your workflow change — this is what makes the change visible to release-please for that Component.
13+
This formats the repository (see [Formatting](#formatting)), then runs `scripts/compute-workflow-sha256.sh`, which regenerates `<name>/workflow-sha256`, a checksum of the workflow file. Commit the resulting diff alongside your workflow change — this is what makes the change visible to release-please for that Component.
1414

1515
CI enforces this on every pull request via `bash scripts/compute-workflow-sha256.sh --check`, which fails if any `workflow-sha256` file is out of date.
1616

17+
## Formatting
18+
19+
Files are formatted with [Prettier](https://prettier.io), using its default settings. Generated files (release-please changelogs, mise files) are excluded via `.prettierignore`. Format the repository with:
20+
21+
```sh
22+
mise run format
23+
```
24+
25+
Formatting can rewrite workflow files, which changes their checksum. After editing a workflow, run `mise run update-checksums` instead of `mise run format` alone, so `workflow-sha256` files are computed from the formatted content.
26+
1727
## Linting
1828

19-
Workflows are linted with [actionlint](https://github.com/rhysd/actionlint), which also runs [shellcheck](https://github.com/koalaman/shellcheck) on inline `run:` scripts. Shell scripts committed to the repository (`*.sh`, e.g. under `scripts/`) are linted with shellcheck directly. Both tools are pinned in `mise.toml` and `mise.lock`. Install them with [mise](https://mise.jdx.dev):
29+
Workflows are linted with [actionlint](https://github.com/rhysd/actionlint), which also runs [shellcheck](https://github.com/koalaman/shellcheck) on inline `run:` scripts. Shell scripts committed to the repository (`*.sh`, e.g. under `scripts/`) are linted with shellcheck directly. Formatting is checked with `prettier --check`. All tools are pinned in `mise.toml` and `mise.lock`. Install them with [mise](https://mise.jdx.dev):
2030

2131
```sh
2232
mise install --locked

‎mise.lock‎

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎mise.toml‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ lockfile = true
55
[tools]
66
"aqua:actionlint" = "1.7.12"
77
"aqua:koalaman/shellcheck" = "0.11.0"
8+
"npm:prettier" = "3.9.8"
9+
10+
[tasks.format]
11+
run = "prettier --write ."
12+
13+
[tasks."update-checksums"]
14+
run = "scripts/compute-workflow-sha256.sh"
15+
depends = ["format"]
16+
17+
[tasks."lint:format"]
18+
run = "prettier --check ."
819

920
[tasks."lint:actionlint"]
1021
run = "actionlint"
@@ -14,4 +25,4 @@ shell = "bash -euo pipefail -c"
1425
run = "git ls-files -z --cached --others --exclude-standard '*.sh' | xargs -0 -r shellcheck"
1526

1627
[tasks.lint]
17-
depends = [ "lint:actionlint", "lint:shellcheck" ]
28+
depends = [ "lint:format", "lint:actionlint", "lint:shellcheck" ]

0 commit comments

Comments
 (0)