Skip to content

Commit 15ffa88

Browse files
author
lihu
committed
feat!: Replace markdownlint with prettier
We use prettier in 95% of our repos for formatting markdown. This codifies/automates that choice.
1 parent ced4867 commit 15ffa88

File tree

3 files changed

+58
-70
lines changed

3 files changed

+58
-70
lines changed

.github/workflows/markdownlint.yaml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/workflows/prettier.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
"on":
3+
workflow_call:
4+
inputs:
5+
jobs_run_on:
6+
default: "ubuntu-latest"
7+
description: "The runner group on which jobs will run."
8+
required: false
9+
type: "string"
10+
timeout_minutes:
11+
description: "The maximum time (in minutes) for a job to run."
12+
default: 5
13+
required: false
14+
type: "number"
15+
working_directory:
16+
description: "The working directory where all jobs should be executed."
17+
default: "."
18+
required: false
19+
type: "string"
20+
jobs:
21+
prettier:
22+
defaults:
23+
run:
24+
working-directory: "${{ inputs.working_directory }}"
25+
runs-on: "${{ inputs.jobs_run_on }}"
26+
timeout-minutes: "${{ inputs.timeout_minutes }}"
27+
env:
28+
PRETTIER_VERSION: "3"
29+
steps:
30+
- name: "Checkout repo"
31+
uses: "actions/checkout@v4"
32+
- name: "Set up Node.js"
33+
uses: "actions/setup-node@v4"
34+
with:
35+
node-version: "22.x"
36+
- name: "Get yarn cache directory"
37+
id: "cache-dir"
38+
run: >-
39+
echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
40+
- uses: "actions/cache@v4"
41+
id: "cache"
42+
with:
43+
path: "${{ steps.cache-dir.outputs.dir }}"
44+
key: "${{ runner.os }}-prettier@${{ env.PRETTIER_VERSION }}"
45+
- name: "Install prettier"
46+
run: >-
47+
yarn add "prettier@${{ env.PRETTIER_VERSION }}"
48+
- name: "Put node executables in the system PATH"
49+
run: >-
50+
echo -n "$(yarn bin)" >> $GITHUB_PATH
51+
- name: "Check all files with prettier"
52+
run: >-
53+
prettier --prose-wrap always --check **/*.md

docs/README.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,25 +113,17 @@ and the [release-please-action](https://github.com/googleapis/release-please-act
113113
These are local Actions that run for this repository. This workflow is not
114114
visible or usable outside of this repository.
115115

116-
### markdownlint.yaml
117-
118-
This workflow will run the
119-
[DavidAnson/markdownlint-cli2-action](https://github.com/DavidAnson/markdownlint-cli2-action)
120-
action to lint markdown files.
121-
122-
#### markdownlint Inputs
123-
124-
* `config_file`: The configuration file to use. Default: `.markdownlint-cli2.yaml`
125-
* `fix`: If set to true, fix any issues found. Default: `false`
126-
* `globs`: The glob to use to find all markdown files. Default: `**/*.md`
127-
* `separator`: The character used to separate globs. Default: `,`
128-
129116
### pre-commit.yaml
130117

131118
This workflow runs the
132119
[pre-commmit action](https://github.com/pre-commit/action) with minimal options
133120
for configuration.
134121

122+
### prettier.yaml
123+
124+
This workflow will run [prettier](https://prettier.io/) to check formatting of
125+
markdown files. The only option passed is `--prose-wrap always`.
126+
135127
### puppet-build.yaml
136128

137129
This workflow will setup [Puppet][7] using

0 commit comments

Comments
 (0)