Skip to content

Commit

Permalink
Implement PHPCS GitHub Action
Browse files Browse the repository at this point in the history
This installs PHPCS and some nice addon standards to be used as GitHub
Action.
  • Loading branch information
ypcs committed Jun 17, 2024
1 parent bb3c7e7 commit c56b07b
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*~
*.swp
18 changes: 18 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[submodule "phpcs/phpcs-core"]
path = thirdparty/phpcs-core
url = https://github.com/PHPCSStandards/PHP_CodeSniffer/
[submodule "phpcs/phpcompatibility"]
path = thirdparty/phpcompatibility
url = https://github.com/PHPCompatibility/PHPCompatibility
[submodule "phpcs/phpcsutils"]
path = thirdparty/phpcsutils
url = https://github.com/PHPCSStandards/PHPCSUtils
[submodule "phpcs/phpcsextra"]
path = thirdparty/phpcsextra
url = https://github.com/PHPCSStandards/PHPCSExtra
[submodule "thirdparty/security"]
path = thirdparty/security
url = https://github.com/FloeDesignTechnologies/phpcs-security-audit
[submodule "thirdparty/wordpress"]
path = thirdparty/wordpress
url = https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM ghcr.io/seravo/ubuntu:noble

RUN apt-setup && \
apt-get --assume-yes install \
php-cli \
php-xml && \
apt-cleanup

RUN useradd user

# Install PHP CodeSniffer with WordPress and Security standards
# NOTE! PHP CodeSniffer master is development version, so one must use latest tagged version instead
RUN mkdir -p /usr/share/php/PHP
COPY thirdparty/phpcs-core /usr/share/php/PHP/CodeSniffer
COPY thirdparty/wordpress /usr/share/php/PHP/CodeSniffer/src/Standards/
COPY thirdparty/security /usr/share/php/PHP/CodeSniffer/src/Standards/
COPY thirdparty/phpcompatibility /usr/share/php/PHP/CodeSniffer/src/Standards/
COPY thirdparty/phpcsutils /usr/share/php/PHP/CodeSniffer/src/Standards/
COPY thirdparty/phpcsextra /usr/share/php/PHP/CodeSniffer/src/Standards/

USER user

ENTRYPOINT ["/usr/bin/php", "/usr/share/php/PHP/CodeSniffer/bin/phpcs"]
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
DOCKER = docker
IMAGE = ghcr.io/seravo/phpcs:latest

all:

build:
$(DOCKER) build -t $(IMAGE) .

run:
$(DOCKER) run --rm -it $(IMAGE)

15 changes: 15 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: "Run PHPCS linter"
description: "Lint code using PHPCS"

inputs:
rules:
description: "PHPCS args"
required: true
default: ''

runs:
using: "docker"
image: "Dockerfile"
args:
- ${{ inputs.args }}
1 change: 1 addition & 0 deletions thirdparty/phpcompatibility
Submodule phpcompatibility added at 9fb324
1 change: 1 addition & 0 deletions thirdparty/phpcs-core
Submodule phpcs-core added at 8f90f7
1 change: 1 addition & 0 deletions thirdparty/phpcsextra
Submodule phpcsextra added at 11d387
1 change: 1 addition & 0 deletions thirdparty/phpcsutils
Submodule phpcsutils added at 87b233
1 change: 1 addition & 0 deletions thirdparty/security
Submodule security added at 68a6c5
1 change: 1 addition & 0 deletions thirdparty/wordpress
Submodule wordpress added at 9333ef

0 comments on commit c56b07b

Please sign in to comment.