Skip to content

Commit

Permalink
NEW Install extra PHP extensions for some unit tests (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Jul 12, 2024
1 parent dd68dec commit 2dec015
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ on:
phpunit:
type: boolean
default: true
phpunit_skip_suites:
type: string
required: false
default: ''
js:
type: boolean
default: true
Expand Down Expand Up @@ -112,6 +116,7 @@ jobs:
phpcoverage_force_off: ${{ inputs.phpcoverage_force_off }}
phplinting: ${{ inputs.phplinting }}
phpunit: ${{ inputs.phpunit }}
phpunit_skip_suites: ${{ inputs.phpunit_skip_suites }}
js: ${{ inputs.js }}
doclinting: ${{ inputs.doclinting }}

Expand Down Expand Up @@ -197,6 +202,8 @@ jobs:
# COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Configure PHP
env:
INSTALL_IN_MEMORY_CACHE_EXTS: ${{ matrix.install_in_memory_cache_exts }}
run: |
# Set memory limit and disable xdebug if not running phpcoverage
if [[ -z $(which php) ]]; then
Expand Down Expand Up @@ -234,6 +241,13 @@ jobs:
echo "Removed PHP extension $extension"
fi
if [[ $INSTALL_IN_MEMORY_CACHE_EXTS == 'true' ]]; then
sudo apt-get install php${{ matrix.php }}-memcached
sudo sh -c "echo 'apc.enable_cli=On' >> /etc/php/${{ matrix.php }}/cli/php.ini"
echo 'Installed in-memory cache extensions and set APCu to be enabled'
echo 'Note that Redis will be added as a composer dependency'
fi
echo "PHP has been configured"
- name: Install additional requirements
Expand Down Expand Up @@ -424,6 +438,7 @@ jobs:
env:
INPUTS_COMPOSER_REQUIRE_EXTRA: ${{ inputs.composer_require_extra }}
MATRIX_COMPOSER_REQUIRE_EXTRA: ${{ matrix.composer_require_extra }}
INSTALL_IN_MEMORY_CACHE_EXTS: ${{ matrix.install_in_memory_cache_exts }}
PARENT_BRANCH: ${{ matrix.parent_branch }}
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
# github.base_ref is only available on pull-requests events is the target branch - is is NOT prefixed with refs/heads/
Expand Down Expand Up @@ -533,6 +548,9 @@ jobs:
if [[ "${{ matrix.endtoend }}" == "true" ]] && ! [[ $GITHUB_REPOSITORY =~ /recipe-testing$ ]]; then
composer require "silverstripe/recipe-testing:^2 || ^3 || ^4" --dev --no-update
fi
if [[ $INSTALL_IN_MEMORY_CACHE_EXTS == 'true' ]]; then
composer require predis/predis --no-update
fi
# Require silverstripe/installer for non-recipes and all but a few modules
# Note: this block needs to be above COMPOSER_REQUIRE_EXTRA to allow that to override what is set here
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ Runs linting against documentation using [silverstripe/documentation-lint](https
Runs PHPunit if the `phpunit.xml` or `phpunit.xml.dist` config file is available. Default is true, disable PHPunit tests with:
`phpunit: false`

##### Skip PHPUnit suites
Skips specific PHPUnit suites in the dynamically generated matrix. Default is to run all suites. Configure with:
`phpunit_skip_suites: suite-to-skip,another-to-skip`

##### PHP linting
Runs phpcs and phpstan if the `phpcs.xml.dist` or `phpstan.neon.dist` config files are available. Default is true, disable with:
`phplinting: false`
Expand All @@ -104,7 +108,7 @@ Runs `yarn lint`, `yarn test` and `yarn build` + `git diff-files` + `git diff` i
`js: false`

##### Extra jobs
Define specific test combinations (e.g. php and db versions). All inputs are false by default so you only need to include config for the input(s) you want enabled. All inputs except `dynamic_matrix` and `simple_matrix` are available in this context. There are also some additional inputs specific to the extra_jobs input (see below). Use a multi-line yml string
Define specific test combinations (e.g. php and db versions). All inputs are false by default so you only need to include config for the input(s) you want enabled. All inputs except `dynamic_matrix`, `simple_matrix`, and `phpunit_skip_suites` are available in this context. There are also some additional inputs specific to the extra_jobs input (see below). Use a multi-line yml string
```yml
extra_jobs: |
- php: '8.0'
Expand Down Expand Up @@ -149,3 +153,6 @@ The end-to-end suite as defined in `behat.yml`. Must be defined, specify 'root'

###### endtoend_config
The `behat.yml` config file to use if not using the root `behat.yml`. Only used if running behat tests in a different module

###### install_in_memory_cache_exts
Must be true or false. Determines whether to install in-memory cache extensions for framework unit tests.

0 comments on commit 2dec015

Please sign in to comment.