Skip to content

Commit

Permalink
[Add] VS Code tasks configuration for Tests, GitHub Workflows and Cod…
Browse files Browse the repository at this point in the history
…eStyle,

[Change] Add verbose flag back to PHP Code Sniffer examples & useage,
[Change] Dont run Coveralis / Scruntinizer GitHub Workflow Steps in ACT environment,
[Add] PHP Coding Standards Fixer configuration
  • Loading branch information
bumbummen99 committed Dec 2, 2024
1 parent e68bf2e commit 209308a
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 4 deletions.
30 changes: 29 additions & 1 deletion .devcontainer/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
########################## Base ###########################
# Create & configure the base for this DevContainer image #
###########################################################

# Define the DevContainer template to be used as the base
ARG PHP=8.3
ARG DISTRO=bullseye

FROM mcr.microsoft.com/vscode/devcontainers/php:$PHP-$DISTRO

# Add global Composer /bin to PATH for vscode
USER vscode

RUN echo "export PATH=\$(XDEBUG_MODE=off composer global config bin-dir --absolute --quiet):\$PATH" >> ~/.bashrc

# Add global Composer /bin to PATH for root
USER root

RUN echo "export PATH=\$(XDEBUG_MODE=off composer global config bin-dir --absolute --quiet):\$PATH" >> ~/.bashrc

##################### Dependencies #####################
# Add any dependencies required to develop the project #
########################################################

# Update the registry once
RUN apt-get update

Expand All @@ -12,5 +30,15 @@ RUN apt-get install -y libbz2-dev \
&& docker-php-ext-configure bz2 \
&& docker-php-ext-install bz2


###################### Tools ######################
# Install tools that are required for development #
###################################################

# Install act
RUN curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash -s -- -b /usr/local/bin
RUN curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash -s -- -b /usr/local/bin

# Install PHP Code Sniffer Fixer
USER vscode

RUN composer global require friendsofphp/php-cs-fixer
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ composer.phar
.phpunit.result.cache
coverage/
build/logs/*
!build/logs/.gitkeep
!build/logs/.gitkeep

# PHP Code Sniffer Fixer
.php-cs-fixer.cache
29 changes: 29 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in([
__DIR__.'/src',
__DIR__.'/tests',
])
;

return (new PhpCsFixer\Config())
->setRules([
'@PSR2' => true,

/* Imports / use */
'no_unused_imports' => true,
'no_unneeded_import_alias' => true,
'no_leading_import_slash' => true,
'ordered_imports' => true,

/* Comments */
'single_line_comment_style' => true,

/* Blank lines */
'no_extra_blank_lines' => [
'tokens' => ['curly_brace_block']
]
])
->setFinder($finder)
;
11 changes: 10 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@
"--ignore=bootstrap",
"--report=checkstyle",
"--report-file=build/logs/checkstyle.xml",
"--standard=build/config/phpcs.xml"
"--standard=build/config/phpcs.xml",
"-v"
]
},
{
"label": "PHP Coding Standards Fixer",
"type": "shell",
"command": "php-cs-fixer",
"args": [
"fix"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Contributions are **welcome** and will be fully **credited**.
- Use the following commands to check your code before committing it:

```sh
$ vendor/bin/phpcs src tests --extensions=php --ignore=bootstrap --report=checkstyle --report-file=build/logs/checkstyle.xml --standard=build/config/phpcs.xml
$ vendor/bin/phpcs src tests --extensions=php --ignore=bootstrap --report=checkstyle --report-file=build/logs/checkstyle.xml --standard=build/config/phpcs.xml -v
$ vendor/bin/phpmd src,tests xml build/config/phpmd.xml
```

Expand Down

0 comments on commit 209308a

Please sign in to comment.