Skip to content

Commit

Permalink
Merge pull request #25 from 10up/feature/19448744-debug-enhancement
Browse files Browse the repository at this point in the history
19448744 | feat: php-syntax - debug flag for detailed logging
  • Loading branch information
pablojmarti authored Mar 5, 2024
2 parents 711061e + cacb6d8 commit c73fc7a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ The script allows customizable messages using the following flags: `[-u webhook_

Additional scripts can be added inside the `/custom-scripts` directory for pipeline use. All scripts with `.sh` extension inside the `/custom-scripts` directory can be executed by the `all-scripts` script.

### Custom-scripts | PHP Syntax - Debug flag for detailed logs

> In a recent patch for performance enhacnement, stdout and verbose logging withing the php-syntax checking processes was removed. For reference, kindly review [PR#23](https://github.com/10up/wordpress-ci-container/pull/23).
For php-syntax checks detailed logs could be enabled by setting a `IS_DEBUG_ENABLED` environment variable within your container or your CI.

This will enable detailed logs in php-syntax checking for debugging, trading off time for logging with increased build time for your environment.

## Node Version

For convenience, `nvm` is installed to easily manage the node version in the CI container. To install a different node version from CI just add a step to execute the command: `nvm install <version>`; you can also execute the command from within a build script.
Expand Down
14 changes: 12 additions & 2 deletions scripts/php-syntax
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
#!/bin/bash

# The -P10 option specifies the number of parallel processes (In constrainted CPUs will take approx time for 1 available cpu)
find . -type f -name '*.php' -not -path '*/vendor/*' -print0 | xargs -0 -n1 -P10 php -l 1>/dev/null
# Checking if the IS_DEBUG_ENABLED flag is put in the CI environment
IS_DEBUG_ENABLED=$( [ -n "$IS_DEBUG_ENABLED" ] && echo "$IS_DEBUG_ENABLED" || echo "" )

if [[ -n "$IS_DEBUG_ENABLED" ]]; then
# The -P10 option specifies the number of parallel processes (In constrainted CPUs will take approx time for 1 available cpu)
# This will output stdout logs
find . -type f -name '*.php' -not -path '*/vendor/*' -print0 | xargs -0 -n1 -P10 php -l
else
# The -P10 option specifies the number of parallel processes (In constrainted CPUs will take approx time for 1 available cpu)
# This will NOT output stdout logs
find . -type f -name '*.php' -not -path '*/vendor/*' -print0 | xargs -0 -n1 -P10 php -l 1>/dev/null
fi

0 comments on commit c73fc7a

Please sign in to comment.