-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds action for the slic configuration and documentation.
- Loading branch information
Showing
2 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Configure slic | ||
|
||
The composite action prepares the environment for running the tests with [slic](https://github.com/stellarwp/slic). | ||
|
||
## Inputs | ||
|
||
| Name | Required | Default | Description | | ||
|--------------------|----------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| `slic_ref` | no | 'main' | Git reference to checkout slic repository. It might be needed for debug or testing purposes. | | ||
| `php_version` | no | '' | If it's not provided the [default slic PHP version](https://github.com/stellarwp/slic/blob/f89dbeaa7af9b795ede5d43be0fea3f8d929fd4a/.env.slic#L50) will be used. Only single dot notation is supported (e.g. 8.1, not 8.1.31). Note the [WordPress Supported Version Charts](https://make.wordpress.org/core/handbook/references/php-compatibility-and-wordpress-versions/#supported-version-chart) to provide a valid `php_version` and `wp_version` combination. | | ||
| `composer_version` | no | '' | If it's not provided the [default slic Composer version](https://github.com/stellarwp/slic/blob/1bdf39f39a57f2228a80a7870880fbdaec53a66d/src/commands/composer.php#L48) will be used. 1 or 2 options can be passed. | | ||
| `wp_version` | no | '' | If it's not provided the [default slic WordPress version](https://github.com/stellarwp/slic/blob/7e79022ce53adfcad514f09528fcb2d204b9e77b/.github/workflows/publish-wordpress-docker-image.yml#L19) will be used. Any value supported by the `wp core update` `--version` argument can be passed. | | ||
| `airplane_mode` | no | 'on' | If airplane mode is enabled no external files are loaded or HTTP requests are performed. To disable airplane mode pass `off`. | | ||
|
||
|
||
## Workflow example | ||
|
||
```yaml | ||
name: Automated Testing | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
tests: | ||
name: Tests | ||
runs-on: ubuntu-latest | ||
env: | ||
PHP_VERSION: '7.4' | ||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure slic | ||
uses: stellarwp/github-actions/configure-slic@main | ||
with: | ||
wp_version: 6.7 | ||
php_version: ${{ env.PHP_VERSION }} | ||
|
||
- name: Use package | ||
run: | | ||
${SLIC_BIN} use ${{ github.event.repository.name }} | ||
- name: Configure php | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ env.PHP_VERSION }} | ||
coverage: none | ||
tools: stellarwp/pup | ||
|
||
- name: Configure Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'npm' | ||
|
||
- name: Build | ||
run: | | ||
pup build --dev | ||
- name: Run tests | ||
run: ${SLIC_BIN} run --ext DotReporter | ||
|
||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
if: ${{ failure() }} | ||
with: | ||
name: Tests failure output | ||
path: ./tests/_output/** | ||
if-no-files-found: ignore | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: Configure slic | ||
description: Installs and configures slic | ||
|
||
inputs: | ||
slic_ref: | ||
required: false | ||
default: 'main' | ||
description: Reference to checkout stellarwp/slic repository | ||
php_version: | ||
required: false | ||
default: '' | ||
description: PHP version run in the container | ||
composer_version: | ||
required: false | ||
default: '' | ||
description: Composer version to be used | ||
wp_version: | ||
required: false | ||
default: '' | ||
description: WordPress version to be installed | ||
airplane_mode: | ||
required: false | ||
default: 'on' | ||
description: Airplane mode, no external connections (on/off) | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Checkout slic | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: stellarwp/slic | ||
ref: ${{ inputs.slic_ref }} | ||
path: slic | ||
fetch-depth: 1 | ||
|
||
- name: Set up slic env vars | ||
shell: bash | ||
run: | | ||
echo "SLIC_BIN=${GITHUB_WORKSPACE}/slic/slic" >> $GITHUB_ENV | ||
echo "SLIC_WP_DIR=${GITHUB_WORKSPACE}/slic/_wordpress" >> $GITHUB_ENV | ||
echo "SLIC_WORDPRESS_DOCKERFILE=Dockerfile.base" >> $GITHUB_ENV | ||
- name: Set run context for slic | ||
shell: bash | ||
run: echo "SLIC=1" >> $GITHUB_ENV && echo "CI=1" >> $GITHUB_ENV | ||
|
||
- name: Start ssh-agent | ||
shell: bash | ||
run: | | ||
mkdir -p "${HOME}/.ssh"; | ||
ssh-agent -a /tmp/ssh_agent.sock; | ||
- name: Export SSH_AUTH_SOCK env var | ||
shell: bash | ||
run: echo "SSH_AUTH_SOCK=/tmp/ssh_agent.sock" >> $GITHUB_ENV | ||
|
||
- name: Set up slic for CI | ||
shell: bash | ||
run: | | ||
cd ${GITHUB_WORKSPACE}/.. | ||
${SLIC_BIN} here | ||
${SLIC_BIN} interactive off | ||
${SLIC_BIN} build-prompt off | ||
${SLIC_BIN} build-subdir off | ||
${SLIC_BIN} xdebug off | ||
${SLIC_BIN} debug on | ||
${SLIC_BIN} info | ||
${SLIC_BIN} config | ||
- name: Configure PHP version | ||
if: ${{ inputs.php_version != '' }} | ||
shell: bash | ||
run: | | ||
${SLIC_BIN} php-version set ${{ inputs.php_version }} --skip-rebuild | ||
- name: Configure Composer version | ||
if: ${{ inputs.composer_version != '' }} | ||
shell: bash | ||
run: | | ||
${SLIC_BIN} composer set-version ${{ inputs.composer_version }} | ||
- name: Update WordPress version | ||
if: ${{ inputs.wp_version != '' }} | ||
shell: bash | ||
run: | | ||
${SLIC_BIN} wp core update --version=${{ inputs.wp_version }} --force | ||
${SLIC_BIN} wp core update-db | ||
${SLIC_BIN} wp core version | ||
- name: Enable airplane mode | ||
if: ${{ inputs.airplane_mode == 'on' }} | ||
shell: bash | ||
run: | | ||
${SLIC_BIN} airplane-mode on |