This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
97 lines (83 loc) · 2.7 KB
/
unit-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Unit tests
on:
push:
branches:
- main
pull_request:
jobs:
tests:
name: PHPUnit
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis:5.0
ports:
- 6379:6379
options: --entrypoint redis-server
continue-on-error: ${{ matrix.can_fail }}
strategy:
fail-fast: true
matrix:
php: [7.4]
wp_version: ["latest"]
can_fail: [false]
env:
WP_DEVELOP_DIR: /tmp/wordpress
WP_CORE_DIR: /tmp/wordpress
WP_VERSION: ${{ matrix.wp_version }}
steps:
- name: Cancel previous runs of this workflow (pull requests only)
if: ${{ github.event_name == 'pull_request' }}
uses: styfle/cancel-workflow-action@0.5.0
with:
access_token: ${{ github.token }}
- name: Checkout code
uses: actions/checkout@v2
- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Set up Composer caching
uses: actions/cache@v2
env:
cache-name: cache-composer-dependencies
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd
tools: composer:v2
coverage: none
- name: Setup Memcached
uses: niden/actions-memcached@v7
- name: Install PHPUnit
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer global require "phpunit/phpunit=^7.5"
- name: Install WordPress and Copy Project
shell: bash
run: |
bash bin/install-wp-tests.sh wordpress_unit_tests root '' 127.0.0.1 $WP_VERSION
# Go into the core directory and replace wp-content.
# mkdir -p ${WP_CORE_DIR}/wp-content/plugins/wp-irving
rm -rf ${WP_CORE_DIR}/wp-content/plugins/wp-irving
rsync -aWq --no-compress . ${WP_CORE_DIR}/wp-content/plugins/wp-irving
- name: Run PHPUnit
shell: bash
run: |
cd ${WP_CORE_DIR}/wp-content/plugins/wp-irving
phpunit
WP_MULTISITE=1 phpunit