Skip to content

Commit

Permalink
NEW Install extra PHP extensions for some unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Jul 9, 2024
1 parent add97c1 commit cf1d6d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
18 changes: 16 additions & 2 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 @@ -101,7 +105,7 @@ jobs:
steps:
- name: Generate matrix
id: generate-matrix
uses: silverstripe/gha-generate-matrix@v1
uses: creative-commoners/gha-generate-matrix@pulls/1/in-memory-cache
with:
composer_install: ${{ inputs.composer_install }}
extra_jobs: ${{ inputs.extra_jobs }}
Expand All @@ -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 @@ -187,7 +192,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
extensions: curl, dom, gd, intl, json, ldap, mbstring, mysql, tidy, xdebug, zip
tools: composer:v2
tools: composer:v2, pecl
coverage: xdebug
# While this should be the correct way to allow forks in composer.json repositories
# in practice there are still many sporadic "Could not authenticate against github.com" errors
Expand All @@ -197,6 +202,8 @@ jobs:
# COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Configure PHP
env:
INSTALL_IN_MEMORY_CACHE_EXTS: ${{ matrix.install_inmemory_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
pecl install memcache
pecl install redis
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'
fi
echo "PHP has been configured"
- name: Install additional requirements
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_inmemory_cache_exts
Must be true or false. Determines whether to install in-memory cache extensions for framework unit tests.

0 comments on commit cf1d6d3

Please sign in to comment.