Skip to content

Commit 9adf4eb

Browse files
committed
Add github actions workflow
1 parent 2ffc4b2 commit 9adf4eb

File tree

7 files changed

+442
-8
lines changed

7 files changed

+442
-8
lines changed

Diff for: .coveralls.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
service_name: travis-ci
16-
coverage_clover: build/logs/clover.xml
17-
json_path: build/logs/coveralls-upload.json
15+
coverage_clover: plugin/tests/coverage/clover.xml
16+
json_path: plugin/tests/coverage/coveralls-upload.json

Diff for: .github/workflows/lint-tests.yml

+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: Lint and Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- develop
8+
pull_request:
9+
10+
env:
11+
DEV_LIB_PATH: vendor/xwp/wp-dev-lib/scripts
12+
13+
jobs:
14+
lint:
15+
name: 'Lint'
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Use Node.js
21+
uses: actions/setup-node@v1
22+
with:
23+
node-version: '14'
24+
- run: npm ci
25+
- run: npm run lint
26+
27+
test-e2e-coverage:
28+
needs: [lint]
29+
name: 'E2E tests (PHP 7.4, WordPress latest, with code coverage)'
30+
runs-on: ubuntu-latest
31+
32+
env:
33+
NODE_ENV: e2e
34+
WP_VERSION: 5.7
35+
36+
steps:
37+
- uses: actions/checkout@v2
38+
39+
- name: Use Node.js
40+
uses: actions/setup-node@v1
41+
with:
42+
node-version: '14'
43+
- run: npm ci
44+
- run: npm run env:start
45+
- run: npm run wp -- wp core install --title=WordPress --admin_user=admin --admin_password=password [email protected] --skip-email --url=http://localhost:8088 --quiet
46+
- run: npm run wp -- wp plugin activate foo-bar
47+
- run: npm run build:js
48+
- run: npm run test:e2e:coverage
49+
50+
- name: Coveralls
51+
uses: coverallsapp/github-action@master
52+
with:
53+
github-token: ${{ secrets.GITHUB_TOKEN }}
54+
path-to-lcov: ./plugin/tests/coverage/e2e/lcov.info
55+
flag-name: 'E2E Tests'
56+
parallel: true
57+
58+
test-js-coverage:
59+
needs: [lint]
60+
name: 'JS unit tests (with code coverage)'
61+
runs-on: ubuntu-latest
62+
63+
steps:
64+
- uses: actions/checkout@v2
65+
66+
- name: Use Node.js
67+
uses: actions/setup-node@v1
68+
with:
69+
node-version: '14'
70+
- run: npm ci
71+
- run: npm run test:js:coverage
72+
73+
- name: Coveralls
74+
uses: coverallsapp/github-action@master
75+
with:
76+
github-token: ${{ secrets.GITHUB_TOKEN }}
77+
path-to-lcov: ./plugin/tests/coverage/js/lcov.info
78+
flag-name: 'JS Unit Tests'
79+
parallel: true
80+
81+
test-php:
82+
needs: [lint]
83+
name: 'PHP tests (PHP ${{ matrix.php_versions }}, WordPress ${{ matrix.wp_versions }})'
84+
runs-on: ${{ matrix.os }}
85+
strategy:
86+
fail-fast: false
87+
matrix:
88+
php_versions: [7.4, 7.3, 7.2, 7.1]
89+
wp_versions: ['latest']
90+
os: [ubuntu-latest]
91+
include:
92+
- php_versions: 7.4
93+
wp_versions: 'trunk'
94+
os: ubuntu-latest
95+
96+
- php_versions: '7.0'
97+
wp_versions: 'latest'
98+
os: ubuntu-18.04 # Use ubuntu-18.4 which has MySQL 5.7 for back-compat < PHP7.0
99+
100+
- php_versions: 5.6.20
101+
wp_versions: 'latest'
102+
os: ubuntu-18.04
103+
104+
- php_versions: 5.6.20
105+
wp_versions: '5.0'
106+
os: ubuntu-18.04
107+
108+
env:
109+
WP_VERSION: ${{ matrix.wp_versions }}
110+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
COVERALLS_PARALLEL: true
112+
COVERALLS: ${{ matrix.php_versions == 7.4 && matrix.wp_versions == 'latest' }}
113+
114+
steps:
115+
- uses: actions/checkout@v2
116+
- name: Setup PHP ${{ matrix.php_versions }}
117+
uses: shivammathur/setup-php@v2
118+
with:
119+
php-version: ${{ matrix.php_versions }}
120+
tools: phpunit
121+
122+
- name: Start MySQL
123+
run: |
124+
sudo systemctl enable mysql.service
125+
sudo systemctl start mysql.service
126+
127+
- name: Install dependencies
128+
run: composer install
129+
130+
- name: Install and Run tests
131+
if: ${{ matrix.php_versions == '7.0' || matrix.php_versions == '5.6.20' }}
132+
run: |
133+
wget -O bin/phpunit https://phar.phpunit.de/phpunit-5.phar
134+
chmod +x bin/phpunit
135+
source bin/php-tests.sh wordpress_test root root localhost false bin/phpunit
136+
137+
- name: Install and Run tests
138+
if: ${{ matrix.php_versions != '7.0' && matrix.php_versions != '5.6.20' }}
139+
run: source bin/php-tests.sh wordpress_test root root localhost
140+
141+
finish:
142+
needs: [test-e2e-coverage, test-js-coverage, test-php]
143+
name: Finish
144+
runs-on: ubuntu-latest
145+
steps:
146+
- name: Coveralls Finished
147+
uses: coverallsapp/github-action@master
148+
with:
149+
github-token: ${{ secrets.github_token }}
150+
parallel-finished: true

0 commit comments

Comments
 (0)