Skip to content

Commit 9937175

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

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-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 --config .mdsf.json README.md'?"
9+
exit 1
10+
fi

Diff for: .github/workflows/main.yml

+13
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
uses: actions/setup-go@v5
1616
with:
1717
go-version: ${{ matrix.go_version }}
18+
- uses: actions/setup-node@v4
1819
- run: ./.ci.gogenerate.sh
1920
- run: ./.ci.gofmt.sh
2021
- run: ./.ci.govet.sh
@@ -37,3 +38,15 @@ jobs:
3738
with:
3839
go-version: ${{ matrix.go_version }}
3940
- run: go test -v -race ./...
41+
format:
42+
name: Check formatting of code snippets in markdown files
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
- name: Setup Go
47+
uses: actions/setup-go@v5
48+
with:
49+
go-version: stable
50+
- run: npm install -g mdsf-cli
51+
- run: ./.ci.gofmt.sh
52+
- run: ./.ci.readme.fmt.sh

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)