-
Notifications
You must be signed in to change notification settings - Fork 32
134 lines (111 loc) · 4.72 KB
/
ci.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: hCaptcha CI
on: [ push, pull_request ]
jobs:
cs_and_tests:
strategy:
matrix:
os: [ubuntu-latest]
php-version: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ]
env:
wp-directory: wordpress
wp-plugin-directory: wordpress/wp-content/plugins/hcaptcha-wordpress-plugin
DB_HOST: localhost
DB_TABLE_PREFIX: wp_
DB_NAME: wp_tests
DB_USER: test
DB_PASSWORD: test
WP_URL: https://test.test
WP_DOMAIN: test.test
WP_ADMIN_USERNAME: admin
WP_ADMIN_PASSWORD: admin
WP_ADMIN_EMAIL: [email protected]
runs-on: ${{ matrix.os }}
name: PHP ${{ matrix.php-version }} on ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@master
with:
path: ${{ env.wp-plugin-directory }}
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: json, mysqli, mbstring, zip
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Composer cache directory
working-directory: ${{ env.wp-plugin-directory }}
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Set up Composer caching
uses: actions/cache@master
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: Install dependencies
working-directory: ${{ env.wp-plugin-directory }}
run: |
composer config github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
composer install
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run code sniffer
working-directory: ${{ env.wp-plugin-directory }}
run: composer phpcs
- name: Run ESLint
working-directory: ${{ env.wp-plugin-directory }}
if: ${{ matrix.php-version == '8.2' }}
run: |
yarn set version stable
yarn
yarn dev
yarn lint
- name: Install WP CLI
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mkdir -p wp-cli
sudo mv wp-cli.phar wp-cli/wp
echo "$GITHUB_WORKSPACE/wp-cli" >> $GITHUB_PATH
- name: Start mysql
run: |
echo '[mysqld]' | sudo tee -a /etc/mysql/my.cnf
echo 'default_authentication_plugin=mysql_native_password' | sudo tee -a /etc/mysql/my.cnf
sudo systemctl start mysql
mysql -e "CREATE USER '${{ env.DB_USER }}'@'${{ env.DB_HOST }}' IDENTIFIED BY '${{ env.DB_PASSWORD }}'" -uroot -proot 2>/dev/null
mysql -e "ALTER USER '${{ env.DB_USER }}'@'${{ env.DB_HOST }}' IDENTIFIED WITH mysql_native_password BY '${{ env.DB_PASSWORD }}'" -uroot -proot 2>/dev/null
mysql -e "GRANT ALL PRIVILEGES ON *.* TO '${{ env.DB_USER }}'@'${{ env.DB_HOST }}'" -uroot -proot 2>/dev/null
mysql -e 'FLUSH PRIVILEGES' -uroot -proot 2>/dev/null
- name: Install WP
working-directory: ${{ env.wp-directory }}
run: |
wp core download
wp config create --dbname="${{ env.DB_NAME }}" --dbuser="${{ env.DB_USER }}" --dbpass="${{ env.DB_PASSWORD }}" --dbhost="${{ env.DB_HOST }}" --dbprefix="${{ env.DB_TABLE_PREFIX }}"
wp db create
wp core install --url="${{ env.WP_URL }}" --title="Test" --admin_user="${{ env.WP_ADMIN_USERNAME }}" --admin_password="${{ env.WP_ADMIN_PASSWORD }}" --admin_email="${{ env.WP_ADMIN_EMAIL }}" --skip-email
- name: Run unit tests
working-directory: ${{ env.wp-plugin-directory }}
run: composer unit
- name: Install plugins
working-directory: ${{ env.wp-directory }}
run: wp plugin install bbpress buddypress contact-form-7 ultimate-member wpforms-lite wpforo
- name: Install plugins requiring 7.1
if: ${{ matrix.php-version >= '7.1' }}
working-directory: ${{ env.wp-directory }}
run: wp plugin install ninja-forms
- name: Install plugins requiring 7.3
if: ${{ matrix.php-version >= '7.3' }}
working-directory: ${{ env.wp-directory }}
run: wp plugin install woocommerce
- name: Run WP tests
working-directory: ${{ env.wp-plugin-directory }}
run: composer integration -- --env github-actions
- name: Run Jest
if: ${{ matrix.php-version == '8.2' }}
working-directory: ${{ env.wp-plugin-directory }}
run: |
yarn jest