docs: add linter (#4945)

This commit is contained in:
Alessandro Ros
2025-09-06 22:51:45 +02:00
committed by GitHub
parent 5f61395915
commit 3a4d4e1802
4 changed files with 48 additions and 28 deletions

View File

@@ -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

View File

@@ -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"

View File

@@ -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.

View File

@@ -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