diff --git a/.automation/generated/linter-links-previews.json b/.automation/generated/linter-links-previews.json index b31a0b9906b..08e9f449d08 100644 --- a/.automation/generated/linter-links-previews.json +++ b/.automation/generated/linter-links-previews.json @@ -449,6 +449,11 @@ "image": "https://opengraph.githubassets.com/125c259b7ef6ad7bf2a4d9b3af0e3bc2b1f8561c1d4ce8923b052cc30d8b8d75/charliermarsh/ruff", "title": "GitHub - charliermarsh/ruff: An extremely fast Python linter, written in Rust." }, + "ruff-format": { + "description": "An extremely fast Python linter and code formatter, written in Rust. - astral-sh/ruff", + "image": "https://opengraph.githubassets.com/38f6877259b2afe1e6f34f52be78027dce0e559671d0403656bae0f133893abc/astral-sh/ruff", + "title": "GitHub - astral-sh/ruff: An extremely fast Python linter and code formatter, written in Rust." + }, "scalafix": { "description": "Refactoring and linting tool for Scala", "image": "https://scalacenter.github.io//scalafix/img/scalacenter2x.png", diff --git a/.github/workflows/deploy-BETA-linters.yml b/.github/workflows/deploy-BETA-linters.yml index f362945d41a..0873541b4f0 100644 --- a/.github/workflows/deploy-BETA-linters.yml +++ b/.github/workflows/deploy-BETA-linters.yml @@ -127,6 +127,7 @@ jobs: "python_mypy", "python_pyright", "python_ruff", + "python_ruff_format", "r_lintr", "raku_raku", "repository_checkov", diff --git a/.github/workflows/deploy-DEV-linters.yml b/.github/workflows/deploy-DEV-linters.yml index e09a61ca663..76d874cc855 100644 --- a/.github/workflows/deploy-DEV-linters.yml +++ b/.github/workflows/deploy-DEV-linters.yml @@ -107,6 +107,7 @@ jobs: "python_mypy", "python_pyright", "python_ruff", + "python_ruff_format", "r_lintr", "raku_raku", "repository_checkov", diff --git a/.github/workflows/deploy-RELEASE-linters.yml b/.github/workflows/deploy-RELEASE-linters.yml index 28c91615ec7..75abd68966a 100644 --- a/.github/workflows/deploy-RELEASE-linters.yml +++ b/.github/workflows/deploy-RELEASE-linters.yml @@ -120,6 +120,7 @@ jobs: "python_mypy", "python_pyright", "python_ruff", + "python_ruff_format", "r_lintr", "raku_raku", "repository_checkov", diff --git a/Dockerfile b/Dockerfile index 026103af642..69f4018ade0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -246,6 +246,7 @@ RUN PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir --upgrade pip virtuale && mkdir -p "/venvs/mypy" && cd "/venvs/mypy" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir mypy && deactivate && cd ./../.. \ && mkdir -p "/venvs/pyright" && cd "/venvs/pyright" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir pyright && deactivate && cd ./../.. \ && mkdir -p "/venvs/ruff" && cd "/venvs/ruff" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir ruff && deactivate && cd ./../.. \ + && mkdir -p "/venvs/ruff-format" && cd "/venvs/ruff-format" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir ruff && deactivate && cd ./../.. \ && mkdir -p "/venvs/checkov" && cd "/venvs/checkov" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir packaging checkov && deactivate && cd ./../.. \ && mkdir -p "/venvs/semgrep" && cd "/venvs/semgrep" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir semgrep && deactivate && cd ./../.. \ && mkdir -p "/venvs/rst-lint" && cd "/venvs/rst-lint" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir Pygments restructuredtext_lint && deactivate && cd ./../.. \ @@ -258,7 +259,7 @@ RUN PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir --upgrade pip virtuale && mkdir -p "/venvs/yamllint" && cd "/venvs/yamllint" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir yamllint && deactivate && cd ./../.. \ && find /venvs \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete \ && rm -rf /root/.cache -ENV PATH="${PATH}":/venvs/ansible-lint/bin:/venvs/cpplint/bin:/venvs/cfn-lint/bin:/venvs/djlint/bin:/venvs/pylint/bin:/venvs/black/bin:/venvs/flake8/bin:/venvs/isort/bin:/venvs/bandit/bin:/venvs/mypy/bin:/venvs/pyright/bin:/venvs/ruff/bin:/venvs/checkov/bin:/venvs/semgrep/bin:/venvs/rst-lint/bin:/venvs/rstcheck/bin:/venvs/rstfmt/bin:/venvs/snakemake/bin:/venvs/snakefmt/bin:/venvs/proselint/bin:/venvs/sqlfluff/bin:/venvs/yamllint/bin +ENV PATH="${PATH}":/venvs/ansible-lint/bin:/venvs/cpplint/bin:/venvs/cfn-lint/bin:/venvs/djlint/bin:/venvs/pylint/bin:/venvs/black/bin:/venvs/flake8/bin:/venvs/isort/bin:/venvs/bandit/bin:/venvs/mypy/bin:/venvs/pyright/bin:/venvs/ruff/bin:/venvs/ruff-format/bin:/venvs/checkov/bin:/venvs/semgrep/bin:/venvs/rst-lint/bin:/venvs/rstcheck/bin:/venvs/rstfmt/bin:/venvs/snakemake/bin:/venvs/snakefmt/bin:/venvs/proselint/bin:/venvs/sqlfluff/bin:/venvs/yamllint/bin #PIPVENV__END ############################ diff --git a/docs/standalone-linters.md b/docs/standalone-linters.md index 557c50439d6..7331cad5c14 100644 --- a/docs/standalone-linters.md +++ b/docs/standalone-linters.md @@ -77,6 +77,7 @@ | PYTHON_MYPY | oxsecurity/megalinter-only-python_mypy:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-python_mypy/beta) | | PYTHON_PYRIGHT | oxsecurity/megalinter-only-python_pyright:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-python_pyright/beta) | | PYTHON_RUFF | oxsecurity/megalinter-only-python_ruff:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-python_ruff/beta) | +| PYTHON_RUFF_FORMAT | oxsecurity/megalinter-only-python_ruff_format:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-python_ruff_format/beta) | | R_LINTR | oxsecurity/megalinter-only-r_lintr:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-r_lintr/beta) | | RAKU_RAKU | oxsecurity/megalinter-only-raku_raku:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-raku_raku/beta) | | REPOSITORY_CHECKOV | oxsecurity/megalinter-only-repository_checkov:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-repository_checkov/beta) | diff --git a/flavors/cupcake/Dockerfile b/flavors/cupcake/Dockerfile index 58a68c35301..e25a88885ea 100644 --- a/flavors/cupcake/Dockerfile +++ b/flavors/cupcake/Dockerfile @@ -201,6 +201,7 @@ RUN PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir --upgrade pip virtuale && mkdir -p "/venvs/mypy" && cd "/venvs/mypy" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir mypy && deactivate && cd ./../.. \ && mkdir -p "/venvs/pyright" && cd "/venvs/pyright" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir pyright && deactivate && cd ./../.. \ && mkdir -p "/venvs/ruff" && cd "/venvs/ruff" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir ruff && deactivate && cd ./../.. \ + && mkdir -p "/venvs/ruff-format" && cd "/venvs/ruff-format" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir ruff && deactivate && cd ./../.. \ && mkdir -p "/venvs/checkov" && cd "/venvs/checkov" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir packaging checkov && deactivate && cd ./../.. \ && mkdir -p "/venvs/semgrep" && cd "/venvs/semgrep" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir semgrep && deactivate && cd ./../.. \ && mkdir -p "/venvs/rst-lint" && cd "/venvs/rst-lint" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir Pygments restructuredtext_lint && deactivate && cd ./../.. \ @@ -211,7 +212,7 @@ RUN PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir --upgrade pip virtuale && mkdir -p "/venvs/yamllint" && cd "/venvs/yamllint" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir yamllint && deactivate && cd ./../.. \ && find /venvs \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete \ && rm -rf /root/.cache -ENV PATH="${PATH}":/venvs/ansible-lint/bin:/venvs/cpplint/bin:/venvs/cfn-lint/bin:/venvs/djlint/bin:/venvs/pylint/bin:/venvs/black/bin:/venvs/flake8/bin:/venvs/isort/bin:/venvs/mypy/bin:/venvs/pyright/bin:/venvs/ruff/bin:/venvs/checkov/bin:/venvs/semgrep/bin:/venvs/rst-lint/bin:/venvs/rstcheck/bin:/venvs/rstfmt/bin:/venvs/proselint/bin:/venvs/sqlfluff/bin:/venvs/yamllint/bin +ENV PATH="${PATH}":/venvs/ansible-lint/bin:/venvs/cpplint/bin:/venvs/cfn-lint/bin:/venvs/djlint/bin:/venvs/pylint/bin:/venvs/black/bin:/venvs/flake8/bin:/venvs/isort/bin:/venvs/mypy/bin:/venvs/pyright/bin:/venvs/ruff/bin:/venvs/ruff-format/bin:/venvs/checkov/bin:/venvs/semgrep/bin:/venvs/rst-lint/bin:/venvs/rstcheck/bin:/venvs/rstfmt/bin:/venvs/proselint/bin:/venvs/sqlfluff/bin:/venvs/yamllint/bin #PIPVENV__END ############################ diff --git a/flavors/cupcake/flavor.json b/flavors/cupcake/flavor.json index af7070c8d7e..4cab24b4893 100644 --- a/flavors/cupcake/flavor.json +++ b/flavors/cupcake/flavor.json @@ -60,6 +60,7 @@ "PYTHON_MYPY", "PYTHON_PYRIGHT", "PYTHON_RUFF", + "PYTHON_RUFF_FORMAT", "REPOSITORY_CHECKOV", "REPOSITORY_GIT_DIFF", "REPOSITORY_GITLEAKS", diff --git a/flavors/formatters/Dockerfile b/flavors/formatters/Dockerfile index a88780c2f22..06f7cf539d3 100644 --- a/flavors/formatters/Dockerfile +++ b/flavors/formatters/Dockerfile @@ -114,11 +114,12 @@ ENV PATH="/root/.cargo/bin:${PATH}" RUN PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir --upgrade pip virtualenv \ && mkdir -p "/venvs/black" && cd "/venvs/black" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir black && deactivate && cd ./../.. \ && mkdir -p "/venvs/isort" && cd "/venvs/isort" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir isort black && deactivate && cd ./../.. \ + && mkdir -p "/venvs/ruff-format" && cd "/venvs/ruff-format" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir ruff && deactivate && cd ./../.. \ && mkdir -p "/venvs/rstfmt" && cd "/venvs/rstfmt" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir rstfmt && deactivate && cd ./../.. \ && mkdir -p "/venvs/snakefmt" && cd "/venvs/snakefmt" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir snakefmt && deactivate && cd ./../.. \ && find /venvs \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete \ && rm -rf /root/.cache -ENV PATH="${PATH}":/venvs/black/bin:/venvs/isort/bin:/venvs/rstfmt/bin:/venvs/snakefmt/bin +ENV PATH="${PATH}":/venvs/black/bin:/venvs/isort/bin:/venvs/ruff-format/bin:/venvs/rstfmt/bin:/venvs/snakefmt/bin #PIPVENV__END ############################ diff --git a/flavors/formatters/flavor.json b/flavors/formatters/flavor.json index 5091fd79861..f1d4a73dada 100644 --- a/flavors/formatters/flavor.json +++ b/flavors/formatters/flavor.json @@ -19,6 +19,7 @@ "POWERSHELL_POWERSHELL_FORMATTER", "PYTHON_BLACK", "PYTHON_ISORT", + "PYTHON_RUFF_FORMAT", "RST_RSTFMT", "SNAKEMAKE_SNAKEFMT", "TERRAFORM_TERRAFORM_FMT", diff --git a/flavors/python/Dockerfile b/flavors/python/Dockerfile index 22182484c6c..c02f3c92ccb 100644 --- a/flavors/python/Dockerfile +++ b/flavors/python/Dockerfile @@ -162,6 +162,7 @@ RUN PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir --upgrade pip virtuale && mkdir -p "/venvs/mypy" && cd "/venvs/mypy" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir mypy && deactivate && cd ./../.. \ && mkdir -p "/venvs/pyright" && cd "/venvs/pyright" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir pyright && deactivate && cd ./../.. \ && mkdir -p "/venvs/ruff" && cd "/venvs/ruff" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir ruff && deactivate && cd ./../.. \ + && mkdir -p "/venvs/ruff-format" && cd "/venvs/ruff-format" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir ruff && deactivate && cd ./../.. \ && mkdir -p "/venvs/checkov" && cd "/venvs/checkov" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir packaging checkov && deactivate && cd ./../.. \ && mkdir -p "/venvs/semgrep" && cd "/venvs/semgrep" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir semgrep && deactivate && cd ./../.. \ && mkdir -p "/venvs/rst-lint" && cd "/venvs/rst-lint" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir Pygments restructuredtext_lint && deactivate && cd ./../.. \ @@ -174,7 +175,7 @@ RUN PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir --upgrade pip virtuale && mkdir -p "/venvs/yamllint" && cd "/venvs/yamllint" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir yamllint && deactivate && cd ./../.. \ && find /venvs \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete \ && rm -rf /root/.cache -ENV PATH="${PATH}":/venvs/ansible-lint/bin:/venvs/cpplint/bin:/venvs/djlint/bin:/venvs/pylint/bin:/venvs/black/bin:/venvs/flake8/bin:/venvs/isort/bin:/venvs/bandit/bin:/venvs/mypy/bin:/venvs/pyright/bin:/venvs/ruff/bin:/venvs/checkov/bin:/venvs/semgrep/bin:/venvs/rst-lint/bin:/venvs/rstcheck/bin:/venvs/rstfmt/bin:/venvs/snakemake/bin:/venvs/snakefmt/bin:/venvs/proselint/bin:/venvs/sqlfluff/bin:/venvs/yamllint/bin +ENV PATH="${PATH}":/venvs/ansible-lint/bin:/venvs/cpplint/bin:/venvs/djlint/bin:/venvs/pylint/bin:/venvs/black/bin:/venvs/flake8/bin:/venvs/isort/bin:/venvs/bandit/bin:/venvs/mypy/bin:/venvs/pyright/bin:/venvs/ruff/bin:/venvs/ruff-format/bin:/venvs/checkov/bin:/venvs/semgrep/bin:/venvs/rst-lint/bin:/venvs/rstcheck/bin:/venvs/rstfmt/bin:/venvs/snakemake/bin:/venvs/snakefmt/bin:/venvs/proselint/bin:/venvs/sqlfluff/bin:/venvs/yamllint/bin #PIPVENV__END ############################ diff --git a/flavors/python/flavor.json b/flavors/python/flavor.json index 88071537b7e..feb30206700 100644 --- a/flavors/python/flavor.json +++ b/flavors/python/flavor.json @@ -42,6 +42,7 @@ "PYTHON_MYPY", "PYTHON_PYRIGHT", "PYTHON_RUFF", + "PYTHON_RUFF_FORMAT", "REPOSITORY_CHECKOV", "REPOSITORY_GIT_DIFF", "REPOSITORY_GITLEAKS", diff --git a/linters/python_ruff_format/Dockerfile b/linters/python_ruff_format/Dockerfile new file mode 100644 index 00000000000..2be96489c51 --- /dev/null +++ b/linters/python_ruff_format/Dockerfile @@ -0,0 +1,235 @@ +# syntax=docker/dockerfile:1 +########################################### +########################################### +## Dockerfile to run MegaLinter ## +########################################### +########################################### + +# @not-generated + +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# +#ARGTOP__START + +#ARGTOP__END + +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# +#FROM__START + +#FROM__END + +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.5.4 AS uv +FROM python:3.12.7-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + +################## +# Get base image # +################## +FROM python:3.12.7-alpine3.20 + +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# +#ARG__START + +#ARG__END + +#################### +# Run APK installs # +#################### + +WORKDIR / + +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# +#APK__START +RUN apk add --no-cache \ + bash \ + ca-certificates \ + curl \ + gcc \ + git \ + git-lfs \ + libffi-dev \ + make \ + musl-dev \ + openssh \ + && git config --global core.autocrlf true +#APK__END + +# PATH for golang & python +ENV GOROOT=/usr/lib/go \ + GOPATH=/go + # PYTHONPYCACHEPREFIX="$HOME/.cache/cpython/" NV: not working for all packages :/ +# hadolint ignore=DL3044 +ENV PATH="$PATH":"$GOROOT"/bin:"$GOPATH"/bin +RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin || true && \ + # Ignore npm package issues + yarn config set ignore-engines true || true + +############################## +# Installs rust dependencies # +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# + +#CARGO__START + +#CARGO__END + +################################ +# Installs python dependencies # +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# + +#PIPVENV__START +RUN PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir --upgrade pip virtualenv \ + && mkdir -p "/venvs/ruff-format" && cd "/venvs/ruff-format" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir ruff && deactivate && cd ./../.. \ + && find /venvs \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete \ + && rm -rf /root/.cache +ENV PATH="${PATH}":/venvs/ruff-format/bin +#PIPVENV__END + +############################ +# Install NPM dependencies # +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# + +ENV NODE_OPTIONS="--max-old-space-size=8192" \ + NODE_ENV=production +#NPM__START + +#NPM__END + +# Add node packages to path # +ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ + NODE_PATH="/node-deps/node_modules" + +############################## +# Installs ruby dependencies # +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# + +#GEM__START + +#GEM__END + +############################## +# COPY instructions # +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# + +#COPY__START + +#COPY__END + +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# +#OTHER__START + +#OTHER__END + +################################ +# Installs python dependencies # +################################ +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . + +####################################### +# Copy scripts and rules to container # +####################################### +COPY megalinter/descriptors /megalinter-descriptors +COPY TEMPLATES /action/lib/.automation + +# Copy server scripts +COPY server /server + +########################### +# Get the build arguments # +########################### +ARG BUILD_DATE +ARG BUILD_REVISION +ARG BUILD_VERSION + +################################################# +# Set ENV values used for debugging the version # +################################################# +ENV BUILD_DATE=$BUILD_DATE \ + BUILD_REVISION=$BUILD_REVISION \ + BUILD_VERSION=$BUILD_VERSION + +#FLAVOR__START +ENV MEGALINTER_FLAVOR=none +#FLAVOR__END + +######################################### +# Label the instance and set maintainer # +######################################### +LABEL com.github.actions.name="MegaLinter" \ + com.github.actions.description="The ultimate linters aggregator to make sure your projects are clean" \ + com.github.actions.icon="code" \ + com.github.actions.color="red" \ + maintainer="Nicolas Vuillamy " \ + org.opencontainers.image.created=$BUILD_DATE \ + org.opencontainers.image.revision=$BUILD_REVISION \ + org.opencontainers.image.version=$BUILD_VERSION \ + org.opencontainers.image.authors="Nicolas Vuillamy " \ + org.opencontainers.image.url="https://megalinter.io" \ + org.opencontainers.image.source="https://github.com/oxsecurity/megalinter" \ + org.opencontainers.image.documentation="https://megalinter.io" \ + org.opencontainers.image.vendor="Nicolas Vuillamy" \ + org.opencontainers.image.description="Lint your code base with GitHub Actions" + +#EXTRA_DOCKERFILE_LINES__START +ENV ENABLE_LINTERS=PYTHON_RUFF_FORMAT \ + FLAVOR_SUGGESTIONS=false \ + SINGLE_LINTER=PYTHON_RUFF_FORMAT \ + PRINT_ALPACA=false \ + LOG_FILE=none \ + SARIF_REPORTER=true \ + TEXT_REPORTER=false \ + UPDATED_SOURCES_REPORTER=false \ + GITHUB_STATUS_REPORTER=false \ + GITHUB_COMMENT_REPORTER=false \ + EMAIL_REPORTER=false \ + API_REPORTER=false \ + FILEIO_REPORTER=false \ + CONFIG_REPORTER=false \ + SARIF_TO_HUMAN=false +RUN mkdir /root/docker_ssh && mkdir /usr/bin/megalinter-sh +EXPOSE 22 +COPY entrypoint.sh /entrypoint.sh +COPY sh /usr/bin/megalinter-sh +COPY sh/megalinter_exec /usr/bin/megalinter_exec +COPY sh/motd /etc/motd +RUN find /usr/bin/megalinter-sh/ -type f -iname "*.sh" -exec chmod +x {} \; && \ + chmod +x entrypoint.sh && \ + chmod +x /usr/bin/megalinter_exec && \ + echo "alias megalinter='python -m megalinter.run'" >> ~/.bashrc && source ~/.bashrc && \ + echo "alias megalinter_exec='/usr/bin/megalinter_exec'" >> ~/.bashrc && source ~/.bashrc +RUN export STANDALONE_LINTER_VERSION="$(python -m megalinter.run --input /tmp --linterversion)" && \ + echo $STANDALONE_LINTER_VERSION +ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] +#EXTRA_DOCKERFILE_LINES__END diff --git a/megalinter/descriptors/all_flavors.json b/megalinter/descriptors/all_flavors.json index 1062a9a0e49..3706b3704e2 100644 --- a/megalinter/descriptors/all_flavors.json +++ b/megalinter/descriptors/all_flavors.json @@ -153,6 +153,7 @@ "PYTHON_MYPY", "PYTHON_PYRIGHT", "PYTHON_RUFF", + "PYTHON_RUFF_FORMAT", "REPOSITORY_CHECKOV", "REPOSITORY_GIT_DIFF", "REPOSITORY_GITLEAKS", @@ -427,6 +428,7 @@ "POWERSHELL_POWERSHELL_FORMATTER", "PYTHON_BLACK", "PYTHON_ISORT", + "PYTHON_RUFF_FORMAT", "RST_RSTFMT", "SNAKEMAKE_SNAKEFMT", "TERRAFORM_TERRAFORM_FMT", @@ -736,6 +738,7 @@ "PYTHON_MYPY", "PYTHON_PYRIGHT", "PYTHON_RUFF", + "PYTHON_RUFF_FORMAT", "REPOSITORY_CHECKOV", "REPOSITORY_GIT_DIFF", "REPOSITORY_GITLEAKS", diff --git a/megalinter/descriptors/python.megalinter-descriptor.yml b/megalinter/descriptors/python.megalinter-descriptor.yml index d2a49017f53..a76890b40c6 100644 --- a/megalinter/descriptors/python.megalinter-descriptor.yml +++ b/megalinter/descriptors/python.megalinter-descriptor.yml @@ -383,3 +383,51 @@ linters: vscode: - name: Ruff url: https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff + + # ruff + - linter_name: ruff-format + name: PYTHON_RUFF_FORMAT + is_formatter: true + can_output_sarif: true + linter_text: | + An extremely fast Python linter, written in Rust. Configured for formatting only. + linter_url: https://github.com/astral-sh/ruff + linter_repo: https://github.com/astral-sh/ruff + linter_spdx_license: MIT + linter_speed: 5 + linter_rules_url: https://docs.astral.sh/ruff/rules/ + linter_rules_configuration_url: https://docs.astral.sh/ruff/configuration/ + linter_rules_inline_disable_url: https://docs.astral.sh/ruff/linter/#error-suppression + cli_executable: ruff + cli_lint_mode: list_of_files + cli_config_arg_name: "--config" + cli_help_arg_name: "help" + cli_version_arg_name: "--version" + cli_lint_extra_args: + - format + - --check + cli_lint_fix_remove_args: + - --check + cli_lint_errors_count: regex_number + cli_lint_errors_regex: "Found ([0-9]+) error" + config_file_name: ".ruff.toml" + cli_sarif_args: + - --output-format + - sarif + - --output-file + - "{{SARIF_OUTPUT_FILE}}" + test_folder: python_ruff + examples: + - "ruff format --check myfile.py myfile2.py" + - "ruff format --config .ruff.toml myfile.py myfile2.py" + install: + pip: + - ruff + ide: + idea: + - name: Ruff + url: https://plugins.jetbrains.com/plugin/20574-ruff + id: com.koxudaxi.ruff + vscode: + - name: Ruff + url: https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff diff --git a/megalinter/descriptors/schemas/megalinter-configuration.jsonschema.json b/megalinter/descriptors/schemas/megalinter-configuration.jsonschema.json index 21e8da3f09f..354703dfdba 100644 --- a/megalinter/descriptors/schemas/megalinter-configuration.jsonschema.json +++ b/megalinter/descriptors/schemas/megalinter-configuration.jsonschema.json @@ -214,6 +214,7 @@ "PYTHON_PYLINT", "PYTHON_PYRIGHT", "PYTHON_RUFF", + "PYTHON_RUFF_FORMAT", "RAKU_RAKU", "REPOSITORY_CHECKOV", "REPOSITORY_DEVSKIM", diff --git a/megalinter/tests/test_megalinter/linters/python_ruff_format_test.py b/megalinter/tests/test_megalinter/linters/python_ruff_format_test.py new file mode 100644 index 00000000000..a42f609049f --- /dev/null +++ b/megalinter/tests/test_megalinter/linters/python_ruff_format_test.py @@ -0,0 +1,14 @@ +# !/usr/bin/env python3 +""" +Unit tests for PYTHON linter ruff-format +This class has been automatically @generated by .automation/build.py, please don't update it manually +""" + +from unittest import TestCase + +from megalinter.tests.test_megalinter.LinterTestRoot import LinterTestRoot + + +class python_ruff_format_test(TestCase, LinterTestRoot): + descriptor_id = "PYTHON" + linter_name = "ruff-format"