From 3a4d4e180257d649092aff527db211cedff98cc5 Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Sat, 6 Sep 2025 22:51:45 +0200 Subject: [PATCH] docs: add linter (#4945) --- .github/workflows/code_lint.yml | 16 ++++++++++++---- Makefile | 4 ++-- docs/1-kickoff/1-introduction.md | 28 ++++++++++++++-------------- scripts/lint.mk | 28 ++++++++++++++++++++-------- 4 files changed, 48 insertions(+), 28 deletions(-) diff --git a/.github/workflows/code_lint.yml b/.github/workflows/code_lint.yml index 0c1ed9e9..136aad09 100644 --- a/.github/workflows/code_lint.yml +++ b/.github/workflows/code_lint.yml @@ -7,7 +7,7 @@ on: branches: [ main ] jobs: - golangci_lint: + go: runs-on: ubuntu-22.04 steps: @@ -25,7 +25,7 @@ jobs: with: version: v2.4.0 - mod_tidy: + go_mod: runs-on: ubuntu-22.04 steps: @@ -35,7 +35,15 @@ jobs: with: go-version: "1.24" - - run: make lint-mod-tidy + - run: make lint-go-mod + + docs: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v5 + + - run: make lint-docs api_docs: runs-on: ubuntu-22.04 @@ -43,4 +51,4 @@ jobs: steps: - uses: actions/checkout@v5 - - run: make lint-apidocs + - run: make lint-api-docs diff --git a/Makefile b/Makefile index cdbd750d..b7d30919 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ BASE_IMAGE = golang:1.24-alpine3.20 -LINT_IMAGE = golangci/golangci-lint:v2.4.0 +GOLANGCI_LINT_IMAGE = golangci/golangci-lint:v2.4.0 NODE_IMAGE = node:20-alpine3.20 .PHONY: $(shell ls) @@ -9,7 +9,7 @@ help: @echo "" @echo "available actions:" @echo "" - @echo " format format source files" + @echo " format format code" @echo " test run tests" @echo " test-32 run tests on a 32-bit system" @echo " test-e2e run end-to-end tests" diff --git a/docs/1-kickoff/1-introduction.md b/docs/1-kickoff/1-introduction.md index 62f2fe4d..bd2ecd4c 100644 --- a/docs/1-kickoff/1-introduction.md +++ b/docs/1-kickoff/1-introduction.md @@ -6,19 +6,19 @@ MediaMTX is a ready-to-use and zero-dependency live media server and media proxy Main features: -* [Publish](/docs/usage/publish) live streams to the server with SRT, WebRTC, RTSP, RTMP, HLS, MPEG-TS, RTP -* [Read](/docs/usage/read) live streams from the server with SRT, WebRTC, RTSP, RTMP, HLS -* Streams are automatically converted from a protocol to another -* Serve several streams at once in separate paths -* [Record](/docs/usage/record) streams to disk in fMP4 or MPEG-TS format -* [Playback](/docs/usage/playback) recorded streams -* [Authenticate](/docs/usage/authentication) users with internal, HTTP or JWT authentication -* [Forward](/docs/usage/forward) streams to other servers -* [Proxy](/docs/usage/proxy) requests to other servers -* [Control](/docs/usage/control-api) the server through the Control API -* Reload the configuration without disconnecting existing clients (hot reloading) -* [Monitor](/docs/usage/metrics) the server through Prometheus-compatible metrics -* [Run hooks](/docs/usage/hooks) (external commands) when clients connect, disconnect, read or publish streams -* Compatible with Linux, Windows and macOS, does not require any dependency or interpreter, it's a single executable +- [Publish](/docs/usage/publish) live streams to the server with SRT, WebRTC, RTSP, RTMP, HLS, MPEG-TS, RTP +- [Read](/docs/usage/read) live streams from the server with SRT, WebRTC, RTSP, RTMP, HLS +- Streams are automatically converted from a protocol to another +- Serve several streams at once in separate paths +- [Record](/docs/usage/record) streams to disk in fMP4 or MPEG-TS format +- [Playback](/docs/usage/playback) recorded streams +- [Authenticate](/docs/usage/authentication) users with internal, HTTP or JWT authentication +- [Forward](/docs/usage/forward) streams to other servers +- [Proxy](/docs/usage/proxy) requests to other servers +- [Control](/docs/usage/control-api) the server through the Control API +- Reload the configuration without disconnecting existing clients (hot reloading) +- [Monitor](/docs/usage/metrics) the server through Prometheus-compatible metrics +- [Run hooks](/docs/usage/hooks) (external commands) when clients connect, disconnect, read or publish streams +- Compatible with Linux, Windows and macOS, does not require any dependency or interpreter, it's a single executable Use the menu to navigate through the documentation. diff --git a/scripts/lint.mk b/scripts/lint.mk index 99981f1d..d50dd684 100644 --- a/scripts/lint.mk +++ b/scripts/lint.mk @@ -1,21 +1,33 @@ -define DOCKERFILE_APIDOCS_LINT +define DOCKERFILE_DOCS_LINT +FROM $(NODE_IMAGE) +RUN yarn global add prettier@3.6.2 +endef +export DOCKERFILE_DOCS_LINT + +define DOCKERFILE_API_DOCS_LINT FROM $(NODE_IMAGE) RUN yarn global add @redocly/cli@1.0.0-beta.123 endef -export DOCKERFILE_APIDOCS_LINT +export DOCKERFILE_API_DOCS_LINT -lint-golangci: +lint-go: docker run --rm -v "$(shell pwd):/app" -w /app \ - $(LINT_IMAGE) \ + $(GOLANGCI_LINT_IMAGE) \ golangci-lint run -v -lint-mod-tidy: +lint-go-mod: go mod tidy git diff --exit-code -lint-apidocs: - echo "$$DOCKERFILE_APIDOCS_LINT" | docker build . -f - -t temp +lint-docs: + echo "$$DOCKERFILE_DOCS_LINT" | docker build . -f - -t temp + docker run --rm -v "$(shell pwd)/docs:/s" -w /s temp \ + sh -c "prettier --write ." + git diff --exit-code + +lint-api-docs: + echo "$$DOCKERFILE_API_DOCS_LINT" | docker build . -f - -t temp docker run --rm -v "$(shell pwd)/api:/s" -w /s temp \ sh -c "openapi lint openapi.yaml" -lint: lint-golangci lint-mod-tidy lint-apidocs +lint: lint-go lint-go-mod lint-docs lint-api-docs