Skip to content

Modernize Testing Infrastructure and Theme Structure #35

Modernize Testing Infrastructure and Theme Structure

Modernize Testing Infrastructure and Theme Structure #35

Workflow file for this run

name: Test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
test:
name: PHP ${{ matrix.php-version }} / WP ${{ matrix.wp-version }}
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2']
wp-version: ['6.4.3', '6.3.5']
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.php-version }}-${{ hashFiles('tests/Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.php-version }}-
${{ runner.os }}-buildx-
- name: Build and run tests
id: phpunit
shell: bash
run: |
{
echo "### PHP ${{ matrix.php-version }} / WordPress ${{ matrix.wp-version }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
docker compose build --build-arg PHP_VERSION=${{ matrix.php-version }} \
--cache-from type=local,src=/tmp/.buildx-cache \
--cache-to type=local,dest=/tmp/.buildx-cache-new,mode=max \
wordpress-test
WP_VERSION=${{ matrix.wp-version }} docker compose run --rm wordpress-test sh -c "composer install && ./vendor/bin/phpunit --log-text=test_output.txt"
grep "^Time\|^OK\|^FAILURES\!" test_output.txt >> $GITHUB_STEP_SUMMARY
exit ${PIPESTATUS[0]}
} || {
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
exit 1
}
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Temp fix for https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
if: always()
run: |
rm -rf /tmp/.buildx-cache
if [ -d /tmp/.buildx-cache-new ]; then
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
fi