diff --git a/.ci.readme.fmt.sh b/.ci.readme.fmt.sh new file mode 100755 index 000000000..0616c8ead --- /dev/null +++ b/.ci.readme.fmt.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Verify that the code snippets in README.md are formatted. +# The tool https://github.com/hougesen/mdsf is used. + +if [ -n "$(mdsf verify --config .mdsf.json README.md 2>&1)" ]; then + echo "Go code in the README.md is not formatted." + echo "Did you forget to run 'mdsf format README.md'?" + exit 1 +fi diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1dd4e650f..95a2fd35a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,10 +15,15 @@ jobs: uses: actions/setup-go@v5 with: go-version: ${{ matrix.go_version }} + - uses: actions/setup-node@v4 + - name: Install mdsf to check formatting of code snippets in markdown files + run: npm install -g mdsf-cli - run: ./.ci.gogenerate.sh - run: ./.ci.gofmt.sh - run: ./.ci.govet.sh - run: go test -v -race ./... + - name: Verify formatting of code snippets in README.md + run: ./.ci.readme.fmt.sh test: runs-on: ubuntu-latest strategy: diff --git a/.mdsf.json b/.mdsf.json new file mode 100644 index 000000000..7617589ce --- /dev/null +++ b/.mdsf.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://raw.githubusercontent.com/hougesen/mdsf/main/schemas/v0.4.1/mdsf.schema.json", + "format_finished_document": false, + "languages": { + "go": [ + [ + "gofmt", + "goimports" + ] + ] + } +}