Kunde21 / markdownfmt

Like gofmt, but for Markdown.
MIT License
55 stars 7 forks source link

ci: Add linting #44

Closed abhinav closed 1 year ago

abhinav commented 1 year ago

This PR adds basic linting to CI for the repository.

First, a preview:

% make help
help:           Prints list of targets and help for them.
build:          Builds all packages.
test:           Tests all packages.
lint:           Runs various analyses on the code.
gofmt:          Makes all files gofmt compliant.
check-gofmt:    Checks that all files are gofmt-compliant.
tidy:           Makes go.mod and go.sum up-to-date
check-tidy:     Checks that go.mod/go.sum are up-to-date.
mdfmt:          Reformats Markdown files with markdownfmt.
check-mdfmt:    Verifies that all Markdown files are properly formatted.

What's included

Currently, linting (make lint) performs three checks:

Because the behavior of gofmt changes between versions of Go, linting runs in CI only on the latest version of Go.

The make check-* targets above include non-check variants to fix the problems they find. For example, make gofmt reformats Go code, and make check-gofmt verifies that it's formatted properly.

Why the other changes?

This includes two changes besides the GitHub Workflow and the Makefile:

As part of adding these checks to linting, this PR also fixes these issues. So the README.md is now markdownfmt-compliant.

Why no other linters?

The change is already pretty large, so I elected to skip third-party linters for now. A future change could add staticcheck, golangci-lint, etc. if desired.

Refs #30


Each commit is independently reviewable.

abhinav commented 1 year ago

This will probably conflict with #43 because of the README change. I'll rebase as needed.

abhinav commented 1 year ago

Rebased now that #43 landed.