Skip to content

Commit 4d8403b

Browse files
authored
Merge pull request #74 from codebtech/chore/fix-tests
CI tests improvements
2 parents 8feb200 + 945de18 commit 4d8403b

29 files changed

+161
-461
lines changed

.github/workflows/e2e.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
- 'main-built'
66

77
jobs:
8-
test:
8+
e2e:
99
timeout-minutes: 60
1010
runs-on: ubuntu-latest
1111
strategy:
@@ -20,6 +20,7 @@ jobs:
2020
- uses: actions/setup-node@v4
2121
with:
2222
node-version: '20.11'
23+
cache: 'yarn'
2324

2425
- name: Cache Composer dependencies
2526
uses: actions/cache@v4

.github/workflows/js.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ on:
55
- 'main-built'
66

77
jobs:
8-
build:
9-
name: Lint & Test
8+
lint-test:
109
runs-on: ubuntu-latest
1110
steps:
1211
- uses: actions/checkout@v4
@@ -15,6 +14,7 @@ jobs:
1514
uses: actions/setup-node@v4
1615
with:
1716
node-version: 20.11
17+
cache: 'yarn'
1818

1919
- name: Install packages
2020
run: yarn install --immutable
@@ -24,3 +24,11 @@ jobs:
2424

2525
- name: JS test
2626
run: yarn test:js
27+
28+
- name: Upload artifacts
29+
uses: actions/upload-artifact@v4
30+
if: always()
31+
with:
32+
name: js-report
33+
path: js-report/
34+
retention-days: 30

.github/workflows/php.yml

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,31 @@ on:
66

77
jobs:
88
lint-test:
9-
name: ${{ matrix.php-versions }} Lint & Test
9+
timeout-minutes: 60
1010
runs-on: ubuntu-latest
1111
strategy:
1212
fail-fast: false
13-
matrix:
14-
php-versions: ['8.3']
1513

1614
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v4
19-
20-
- name: Get composer cache directory
21-
id: composer-cache
22-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: '20.11'
19+
cache: 'yarn'
2320

2421
- name: Cache Composer dependencies
2522
uses: actions/cache@v4
2623
with:
2724
path: /tmp/composer-cache
2825
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
2926

30-
- name: Setup PHP with tools
31-
uses: shivammathur/setup-php@v2
32-
with:
33-
php-version: '8.3'
34-
tools: composer:v2
35-
3627
- name: Validate Composer
3728
run: composer validate --strict
3829

39-
- name: Install dependencies
40-
run: composer install --prefer-dist
30+
- name: Setup composer
31+
uses: php-actions/composer@v6
32+
with:
33+
php_version: '8.3'
4134

4235
- name: PHP Lint
4336
run: composer lint
@@ -48,5 +41,43 @@ jobs:
4841
- name: PHPMD
4942
run: composer phpmd
5043

44+
- name: Install wp-env
45+
run: yarn add @wordpress/env -D
46+
47+
- name: Start wp-env
48+
run: yarn wp-env:coverage
49+
5150
- name: WordPress unit test
52-
run: composer test:unit
51+
run: yarn php:unit
52+
53+
- name: Unit test coverage report
54+
uses: codecov/codecov-action@v4
55+
with:
56+
files: ./unit-coverage.xml
57+
flags: unittests
58+
name: codecov-unit
59+
verbose: true
60+
token: ${{ secrets.CODECOV_TOKEN }}
61+
62+
- name: WordPress integration test
63+
run: yarn php:integration
64+
65+
- name: Integration test coverage report
66+
uses: codecov/codecov-action@v4
67+
with:
68+
files: ./integration-coverage.xml
69+
flags: integrationtests
70+
name: codecov-integration
71+
verbose: true
72+
token: ${{ secrets.CODECOV_TOKEN }}
73+
74+
- name: WordPress integration test as multisite
75+
run: yarn php:multisite
76+
77+
- name: Upload artifacts
78+
uses: actions/upload-artifact@v4
79+
if: always()
80+
with:
81+
name: php-report
82+
path: php-report/
83+
retention-days: 30

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ vendor
33
build
44
yarn-error.log
55
.phpunit.result.cache
6+
.phpunit.cache
67
.DS_Store
78
testingdb
89
.env
@@ -14,3 +15,5 @@ tests-examples/
1415
/blob-report/
1516
/playwright/.cache/
1617
build-script.sh
18+
integration-coverage.xml
19+
unit-coverage.xml

.wp-env.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{
22
"core": null,
33
"plugins": ["."],
4-
"phpVersion": "8.3"
4+
"phpVersion": "8.3",
5+
"env": {
6+
"tests": {
7+
"mappings": {
8+
"wp-content/plugins/feature-flags": "."
9+
}
10+
}
11+
}
512
}

bin/install-wp-tests.sh

Lines changed: 0 additions & 155 deletions
This file was deleted.

composer.json

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,8 @@
1212
"newsuk/nuk-wp-phpmd-config": "^0.1.0",
1313
"newsuk/nuk-wp-phpstan-config": "^0.1.0",
1414
"phpunit/phpunit": "^9.4",
15-
"wordpress/wordpress": "^6.4",
1615
"yoast/wp-test-utils": "^1.2"
1716
},
18-
"repositories": [
19-
{
20-
"type": "vcs",
21-
"url": "https://git@github.com/WordPress/wordpress-develop"
22-
}
23-
],
2417
"autoload": {
2518
"psr-4": {
2619
"CodeB\\FeatureFlags\\": [
@@ -48,8 +41,8 @@
4841
"phpmd": "phpmd plugin.php,includes text phpmd.xml.dist --color",
4942
"phpstan": "phpstan analyse --memory-limit=2048M",
5043
"phpstan-baseline": "phpstan analyse -b --allow-empty-baseline --memory-limit=2048M",
51-
"test:integration": "phpunit --dont-report-useless-tests --configuration ./phpunit-integration.xml --testsuite integration --testdox --coverage-text",
52-
"test:multisite": "phpunit --dont-report-useless-tests --configuration ./phpunit-integration-multisite.xml --testsuite integration --testdox --coverage-text",
53-
"test:unit": "phpunit --dont-report-useless-tests --configuration ./phpunit.xml --testsuite unit --testdox --coverage-text"
44+
"test:integration": "phpunit --dont-report-useless-tests --configuration ./phpunit-integration.xml --testsuite integration --testdox",
45+
"test:multisite": "phpunit --dont-report-useless-tests --configuration ./phpunit-integration-multisite.xml --testsuite integration --testdox ",
46+
"test:unit": "phpunit --dont-report-useless-tests --configuration ./phpunit.xml --testsuite unit --testdox"
5447
}
5548
}

0 commit comments

Comments
 (0)