Browse Source

DX: Ability to run Sphinx linter locally (#7481)

Greg Korba 1 year ago
parent
commit
d6643d7a00
3 changed files with 20 additions and 2 deletions
  1. 11 2
      Dockerfile
  2. 1 0
      compose.override.dist.yaml
  3. 8 0
      compose.yaml

+ 11 - 2
Dockerfile

@@ -1,7 +1,16 @@
-ARG PHP_VERSION
+ARG PHP_VERSION=8.3
 ARG ALPINE_VERSION=3.18
 
-FROM php:${PHP_VERSION}-cli-alpine${ALPINE_VERSION}
+FROM alpine:3.18.4 as sphinx-lint
+
+RUN apk add python3 py3-pip git \
+    && pip install sphinx-lint
+
+# This must be the same as in CI's job, but `--null` must be changed to `-0` (Alpine)
+CMD git ls-files --cached -z -- '*.rst' \
+    | xargs -0 -- python3 -m sphinxlint --enable all --disable trailing-whitespace --max-line-length 2000
+
+FROM php:${PHP_VERSION}-cli-alpine${ALPINE_VERSION} as php
 
 ARG DOCKER_USER_ID
 ARG DOCKER_GROUP_ID

+ 1 - 0
compose.override.dist.yaml

@@ -3,6 +3,7 @@ version: '3.8'
 services:
   php-7.4: &php
     build:
+      target: php
       args: &base_build_args
         DOCKER_USER_ID: ${DOCKER_USER_ID:-1000}
         DOCKER_GROUP_ID: ${DOCKER_GROUP_ID:-1000}

+ 8 - 0
compose.yaml

@@ -3,6 +3,7 @@ version: '3.8'
 services:
   php-7.4: &php
     build:
+      target: php
       args:
         ALPINE_VERSION: "3.16"
         PHP_VERSION: "7.4"
@@ -42,3 +43,10 @@ services:
       args:
         PHP_VERSION: "8.3"
         PHP_XDEBUG_VERSION: "3.3.0"
+
+  sphinx-lint:
+    build:
+      target: sphinx-lint
+    working_dir: /app
+    volumes:
+      - .:/app