Skip to content

Commit 95d031d

Browse files
committed
Verify formatting of code snippets in CI
1 parent 3cf0926 commit 95d031d

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

Diff for: .ci.readme.fmt.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# Verify that the code snippets in README.md are formatted.
4+
# The tool https://github.com/hougesen/mdsf is used.
5+
6+
if [ -n "$(mdsf verify --config .mdsf.json README.md 2>&1)" ]; then
7+
echo "Go code in the README.md is not formatted."
8+
echo "Did you forget to run 'mdsf format README.md'?"
9+
exit 1
10+
fi

Diff for: .github/workflows/main.yml

+5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ jobs:
1515
uses: actions/setup-go@v5
1616
with:
1717
go-version: ${{ matrix.go_version }}
18+
- uses: actions/setup-node@v4
19+
- name: Install mdsf to check formatting of code snippets in markdown files
20+
run: npm install -g mdsf-cli
1821
- run: ./.ci.gogenerate.sh
1922
- run: ./.ci.gofmt.sh
2023
- run: ./.ci.govet.sh
2124
- run: go test -v -race ./...
25+
- name: Verify formatting of code snippets in README.md
26+
run: ./.ci.readme.fmt.sh
2227
test:
2328
runs-on: ubuntu-latest
2429
strategy:

Diff for: .mdsf.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/hougesen/mdsf/main/schemas/v0.4.1/mdsf.schema.json",
3+
"format_finished_document": false,
4+
"languages": {
5+
"go": [
6+
[
7+
"gofmt",
8+
"goimports"
9+
]
10+
]
11+
}
12+
}

0 commit comments

Comments
 (0)