Skip to content

Commit

Permalink
changes after running build.py
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville committed May 31, 2024
1 parent ff15cd3 commit c0ca825
Show file tree
Hide file tree
Showing 13 changed files with 419 additions and 128 deletions.
5 changes: 5 additions & 0 deletions .automation/generated/linter-links-previews.json
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@
"image": null,
"title": "PHP: Hypertext Preprocessor"
},
"php-cs-fixer": {
"description": "PHP Coding Standards Fixer",
"image": null,
"title": "PHP Coding Standards Fixer"
},
"phpcs": {
"description": "PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards. - squizlabs/PHP_CodeSniffer",
"image": "https://avatars2.githubusercontent.com/u/997547?s=400&v=4",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-BETA-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ jobs:
"php_phpstan",
"php_psalm",
"php_phplint",
"php_phpcsfixer",
"powershell_powershell",
"powershell_powershell_formatter",
"protobuf_protolint",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-DEV-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ jobs:
"php_phpstan",
"php_psalm",
"php_phplint",
"php_phpcsfixer",
"powershell_powershell",
"powershell_powershell_formatter",
"protobuf_protolint",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-RELEASE-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ jobs:
"php_phpstan",
"php_psalm",
"php_phplint",
"php_phpcsfixer",
"powershell_powershell",
"powershell_powershell_formatter",
"protobuf_protolint",
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,10 @@ RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GI
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install overtrue/phplint --force-accept-unsigned -g


# php-cs-fixer installation
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && composer global require friendsofphp/php-cs-fixer


# powershell installation
RUN pwsh -c 'Install-Module -Name PSScriptAnalyzer -RequiredVersion ${PSSA_VERSION} -Scope AllUsers -Force'

Expand Down
251 changes: 126 additions & 125 deletions docs/standalone-linters.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions flavors/cupcake/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,10 @@ RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GI
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install overtrue/phplint --force-accept-unsigned -g


# php-cs-fixer installation
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && composer global require friendsofphp/php-cs-fixer


# mypy installation
ENV MYPY_CACHE_DIR=/tmp

Expand Down
1 change: 1 addition & 0 deletions flavors/cupcake/flavor.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"PHP_PHPSTAN",
"PHP_PSALM",
"PHP_PHPLINT",
"PHP_PHPCSFIXER",
"PYTHON_PYLINT",
"PYTHON_BLACK",
"PYTHON_FLAKE8",
Expand Down
4 changes: 4 additions & 0 deletions flavors/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GI
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install overtrue/phplint --force-accept-unsigned -g


# php-cs-fixer installation
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && composer global require friendsofphp/php-cs-fixer


# protolint installation
# Managed with COPY --link --from=protolint /usr/local/bin/protolint /usr/bin/

Expand Down
2 changes: 1 addition & 1 deletion flavors/php/flavor.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"MARKDOWN_MARKDOWN_TABLE_FORMATTER",
"OPENAPI_SPECTRAL",
"PHP_PHPCS",
"PHP_PHPCSFIXER",
"PHP_PHPSTAN",
"PHP_PSALM",
"PHP_PHPLINT",
"PHP_PHPCSFIXER",
"PROTOBUF_PROTOLINT",
"REPOSITORY_CHECKOV",
"REPOSITORY_GIT_DIFF",
Expand Down
255 changes: 255 additions & 0 deletions linters/php_phpcsfixer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
# 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

##################
# Get base image #
##################
FROM python:3.12.3-alpine3.19

#############################################################################################
## @generated by .automation/build.py using descriptor files, please do not update manually ##
#############################################################################################
#ARG__START

#ARG__END

# Static args
ARG GITHUB_TOKEN

####################
# 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 \
gnupg \
php83 \
php83-phar \
php83-mbstring \
php83-xmlwriter \
php83-tokenizer \
php83-ctype \
php83-curl \
php83-dom \
php83-opcache \
php83-openssl \
php83-common \
php83-simplexml \
dpkg \
&& 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

#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 --from=composer/composer:2-bin /composer /usr/bin/composer
#COPY__END

#############################################################################################
## @generated by .automation/build.py using descriptor files, please do not update manually ##
#############################################################################################
#OTHER__START
# PHP installation
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" \
&& export GITHUB_AUTH_TOKEN \
&& wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
&& wget --tries=5 -q -O phive.phar.asc https://phar.io/releases/phive.phar.asc \
&& PHAR_KEY_ID="0x6AF725270AB81E04D79442549D8A98B29B2D5D79" \
&& ( gpg --keyserver hkps://keys.openpgp.org --recv-keys "$PHAR_KEY_ID" \
|| gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys "$PHAR_KEY_ID" \
|| gpg --keyserver keyserver.pgp.com --recv-keys "$PHAR_KEY_ID" \
|| gpg --keyserver pgp.mit.edu --recv-keys "$PHAR_KEY_ID" ) \
&& gpg --verify phive.phar.asc phive.phar \
&& chmod +x phive.phar \
&& mv phive.phar /usr/local/bin/phive \
&& rm phive.phar.asc \
&& update-alternatives --install /usr/bin/php php /usr/bin/php83 110

# Managed with COPY --from=composer/composer:2-bin /composer /usr/bin/composer
ENV PATH="/root/.composer/vendor/bin:${PATH}"

# php-cs-fixer installation
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && composer global require friendsofphp/php-cs-fixer


#OTHER__END

################################
# Installs python dependencies #
################################
COPY megalinter /megalinter
RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \
&& PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \
&& rm -rf /var/cache/apk/* \
&& find . | grep -E "(/__pycache__$|\.pyc$|\.pyo$)" | xargs rm -rf

#######################################
# 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 <[email protected]>" \
org.opencontainers.image.created=$BUILD_DATE \
org.opencontainers.image.revision=$BUILD_REVISION \
org.opencontainers.image.version=$BUILD_VERSION \
org.opencontainers.image.authors="Nicolas Vuillamy <[email protected]>" \
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=PHP_PHPCSFIXER \
FLAVOR_SUGGESTIONS=false \
SINGLE_LINTER=PHP_PHPCSFIXER \
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 \
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
4 changes: 2 additions & 2 deletions megalinter/descriptors/all_flavors.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@
"MARKDOWN_MARKDOWN_LINK_CHECK",
"MARKDOWN_MARKDOWN_TABLE_FORMATTER",
"PHP_PHPCS",
"PHP_PHPCSFIXER",
"PHP_PHPSTAN",
"PHP_PSALM",
"PHP_PHPLINT",
"PHP_PHPCSFIXER",
"PYTHON_PYLINT",
"PYTHON_BLACK",
"PYTHON_FLAKE8",
Expand Down Expand Up @@ -666,10 +666,10 @@
"MARKDOWN_MARKDOWN_TABLE_FORMATTER",
"OPENAPI_SPECTRAL",
"PHP_PHPCS",
"PHP_PHPCSFIXER",
"PHP_PHPSTAN",
"PHP_PSALM",
"PHP_PHPLINT",
"PHP_PHPCSFIXER",
"PROTOBUF_PROTOLINT",
"REPOSITORY_CHECKOV",
"REPOSITORY_GIT_DIFF",
Expand Down
14 changes: 14 additions & 0 deletions megalinter/tests/test_megalinter/linters/php_phpcsfixer_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# !/usr/bin/env python3
"""
Unit tests for PHP linter php-cs-fixer
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 php_phpcsfixer_test(TestCase, LinterTestRoot):
descriptor_id = "PHP"
linter_name = "php-cs-fixer"

0 comments on commit c0ca825

Please sign in to comment.