-
-
Notifications
You must be signed in to change notification settings - Fork 11
171 lines (152 loc) · 5.55 KB
/
integration-testing.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Integration Testing
on:
push:
branches:
- develop
- main
pull_request:
branches:
- develop
- main
paths:
- '**.php'
- '.github/workflows/*.yml'
- '!docs/**'
# Cancel previous workflow run groups that have not completed.
concurrency:
# Group workflow runs by workflow name, along with the head branch ref of the pull request
# or otherwise the branch or tag ref.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
continuous_integration:
runs-on: ubuntu-latest
name: WordPress ${{ matrix.wordpress }} on PHP ${{ matrix.php }}
strategy:
matrix:
php: ["8.2", "8.1", "8.0"]
wordpress: ["6.6", "6.5", "6.4", "6.3", "6.2"]
include:
- php: "8.2"
wordpress: "6.6"
coverage: 1
exclude:
# New WP versions that dont support older PHP versions
- php: "8.0"
wordpress: "6.6"
- php: "8.0"
wordpress: "6.5"
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, mbstring
tools: composer:v2
- name: Install Composer dependencies
uses: ramsey/composer-install@v3
with:
composer-options: "--no-progress"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Node.js dependencies
run: npm ci
env:
CI: true
- name: Build assets
run: |
npm run build
- name: Copy .env file
run: |
cp .docker/.env.ci .env
echo "INCLUDE_EXTENSIONS=${{ matrix.extensions }}" >> .env
echo "WP_VERSION=${{ matrix.wordpress }}" >> .env
echo "PHP_VERSION=${{ matrix.php }}" >> .env
env:
WP_VERSION: ${{ matrix.wordpress }}
PHP_VERSION: ${{ matrix.php }}
INCLUDE_EXTENSIONS: ${{ matrix.extensions }}
- name: Build test environment
run: |
composer run docker:build
env:
WP_VERSION: ${{ matrix.wordpress }}
PHP_VERSION: ${{ matrix.php }}
- name: Start test environment
run: |
composer run docker:up
CONTAINER_ID=$(docker compose ps -q wordpress)
if [ -n "$CONTAINER_ID" ]; then
docker exec $CONTAINER_ID init-docker.sh
else
echo "Error: WordPress container not found."
exit 1
fi
env:
WP_VERSION: ${{ matrix.wordpress }}
PHP_VERSION: ${{ matrix.php }}
- name: Run Acceptance Tests w/ Docker
run: |
if [ "${{ matrix.extensions }}" = "true" ]; then
docker exec \
--env DEBUG=${{ env.DEBUG }} \
--env SKIP_TESTS_CLEANUP=${{ env.SKIP_TESTS_CLEANUP }} \
--env SUITES=${{ env.SUITES }} \
$(docker compose ps -q wordpress) \
bash -c "cd wp-content/plugins/wp-graphql-headless-login && bin/run-codeception.sh"
fi
env:
DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG || matrix.debug }}
SKIP_TESTS_CLEANUP: 'true'
SUITES: acceptance
- name: Run Functional Tests w/ Docker
run: |
docker exec \
--env DEBUG=${{ env.DEBUG }} \
--env SKIP_TESTS_CLEANUP=${{ env.SKIP_TESTS_CLEANUP }} \
--env SUITES=${{ env.SUITES }} \
$(docker compose ps -q wordpress) \
bash -c "cd wp-content/plugins/wp-graphql-headless-login && bin/run-codeception.sh"
env:
DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG || matrix.debug }}
SKIP_TESTS_CLEANUP: 'true'
SUITES: functional
- name: Run WPUnit Tests w/ Docker
run: |
docker exec \
--env COVERAGE=${{ env.COVERAGE }} \
--env USING_XDEBUG=${{ env.USING_XDEBUG }} \
--env DEBUG=${{ env.DEBUG }} \
--env SUITES=${{ env.SUITES }} \
$(docker compose ps -q wordpress) \
bash -c "cd wp-content/plugins/wp-graphql-headless-login && bin/run-codeception.sh"
env:
COVERAGE: ${{ matrix.coverage }}
USING_XDEBUG: ${{ matrix.coverage }}
DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG || matrix.debug }}
SUITES: wpunit
- name: Push Codecoverage to Coveralls.io
if: ${{ matrix.coverage == 1 }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
docker exec $(docker compose ps -q wordpress) bash -c "git config --global --add safe.directory /var/www/html/wp-content/plugins/wp-graphql-headless-login"
docker exec \
--env COVERALLS_REPO_TOKEN=${{ secrets.GITHUB_TOKEN }} \
--env COVERALLS_RUN_LOCALLY=1 \
$(docker compose ps -q wordpress) \
bash -c "COVERALLS_RUN_LOCALLY=1 cd wp-content/plugins/wp-graphql-headless-login && vendor/bin/php-coveralls -v"
- name: Push CodeCoverage to CodeClimate
if: ${{ matrix.coverage == 1 }}
uses: paambaati/codeclimate-action@v9
env:
CC_TEST_REPORTER_ID: f775c7e015158d3505156743f180c5b6a4fecb372c63f682cfcd2c7d32ae23cc
with:
coverageLocations: |
${{github.workspace}}/tests/_output/*.xml:clover
prefix: '/var/www/html/wp-content/plugins/wp-graphql-headless-login'