Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add action for slic configuration #16

Merged
merged 6 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions configure-slic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Configure slic

The composite action prepares the environment for running the tests with [slic](https://github.com/stellarwp/slic).

## Inputs

| Name | Required | Default | Description |
|-----------------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `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 `wp core update` `--version` argument can be passed. |
| `airplane_mode` | no | 'on' | If airplane mode enabled no external files are loaded or HTTP requests 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
steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Configure slic
uses: stellarwp/github-actions/configure-slic@main
with:
wp_version: 6.7

- name: Use package
run: |
${SLIC_BIN} use ${{ github.event.repository.name }}

- name: Configure php
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
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
```
71 changes: 71 additions & 0 deletions configure-slic/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Configure slic
description: Installs and configures slic

inputs:
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: main
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: 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