Skip to content

Commit fd7b00c

Browse files
committed
Moved codeception into its own action.
1 parent 4910d38 commit fd7b00c

File tree

2 files changed

+121
-94
lines changed

2 files changed

+121
-94
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# codeception/action.yml
2+
name: 'Run Codeception Tests'
3+
description: 'Sets up environment and runs Codeception test suites'
4+
inputs:
5+
working-directory:
6+
description: 'Plugin directory to run tests in'
7+
required: true
8+
php:
9+
description: 'PHP version'
10+
required: true
11+
wordpress:
12+
description: 'WordPress version'
13+
required: true
14+
extensions:
15+
description: 'Extensions flag'
16+
required: false
17+
default: ''
18+
coverage:
19+
description: 'Enable coverage'
20+
required: false
21+
default: ''
22+
runs:
23+
using: "composite"
24+
steps:
25+
- name: Install PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ inputs.php }}
29+
extensions: json, mbstring
30+
tools: composer:v2
31+
32+
- name: Install Composer dependencies
33+
uses: ramsey/composer-install@v3
34+
with:
35+
working-directory: ${{ inputs.working-directory }}
36+
composer-options: "--no-progress"
37+
38+
- name: Copy .env file
39+
working-directory: ${{ inputs.working-directory }}
40+
run: |
41+
cp .docker/.env.ci .env
42+
echo "INCLUDE_EXTENSIONS=${{ inputs.extensions }}" >> .env
43+
echo "WP_VERSION=${{ inputs.wordpress }}" >> .env
44+
echo "PHP_VERSION=${{ inputs.php }}" >> .env
45+
env:
46+
WP_VERSION: ${{ inputs.wordpress }}
47+
PHP_VERSION: ${{ inputs.php }}
48+
INCLUDE_EXTENSIONS: ${{ inputs.extensions }}
49+
50+
- name: Build test environment
51+
working-directory: ${{ inputs.working-directory }}
52+
run: |
53+
composer run docker:build
54+
env:
55+
WP_VERSION: ${{ inputs.wordpress }}
56+
PHP_VERSION: ${{ inputs.php }}
57+
58+
- name: Start test environment
59+
working-directory: ${{ inputs.working-directory }}
60+
run: |
61+
docker compose --env-file .env up --detach
62+
63+
CONTAINER_ID=$(docker compose ps -q wordpress)
64+
if [ -n "$CONTAINER_ID" ]; then
65+
docker exec $CONTAINER_ID init-docker.sh
66+
else
67+
echo "Error: WordPress container not found."
68+
exit 1
69+
fi
70+
env:
71+
WP_VERSION: ${{ inputs.wordpress }}
72+
PHP_VERSION: ${{ inputs.php }}
73+
74+
- name: Run Acceptance Tests w/ Docker
75+
working-directory: ${{ inputs.working-directory }}
76+
run: |
77+
if [ "${{ inputs.extensions }}" = "true" ]; then
78+
docker exec \
79+
--env DEBUG=${{ env.DEBUG }} \
80+
--env SKIP_TESTS_CLEANUP=${{ env.SKIP_TESTS_CLEANUP }} \
81+
--env SUITES=acceptance \
82+
$(docker compose ps -q wordpress) \
83+
bash -c "cd wp-content/plugins/$(basename ${{ inputs.working-directory }}) && bin/run-codeception.sh"
84+
fi
85+
env:
86+
DEBUG: ${{ env.ACTIONS_STEP_DEBUG }}
87+
SKIP_TESTS_CLEANUP: 'true'
88+
continue-on-error: true
89+
90+
- name: Run Functional Tests w/ Docker
91+
working-directory: ${{ inputs.working-directory }}
92+
run: |
93+
docker exec \
94+
--env DEBUG=${{ env.DEBUG }} \
95+
--env SKIP_TESTS_CLEANUP=${{ env.SKIP_TESTS_CLEANUP }} \
96+
--env SUITES=functional \
97+
$(docker compose ps -q wordpress) \
98+
bash -c "cd wp-content/plugins/$(basename ${{ inputs.working-directory }}) && bin/run-codeception.sh"
99+
env:
100+
DEBUG: ${{ env.ACTIONS_STEP_DEBUG }}
101+
SKIP_TESTS_CLEANUP: 'true'
102+
continue-on-error: true
103+
104+
- name: Run WPUnit Tests w/ Docker
105+
working-directory: ${{ inputs.working-directory }}
106+
run: |
107+
docker exec \
108+
--env COVERAGE=${{ inputs.coverage }} \
109+
--env USING_XDEBUG=${{ inputs.coverage }} \
110+
--env DEBUG=${{ env.DEBUG }} \
111+
--env SUITES=wpunit \
112+
$(docker compose ps -q wordpress) \
113+
bash -c "cd wp-content/plugins/$(basename ${{ inputs.working-directory }}) && bin/run-codeception.sh"
114+
env:
115+
DEBUG: ${{ env.ACTIONS_STEP_DEBUG }}

.github/workflows/codeception.yml

Lines changed: 6 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -57,99 +57,11 @@ jobs:
5757
- name: Checkout
5858
uses: actions/checkout@v4
5959

60-
- name: Install PHP
61-
uses: shivammathur/setup-php@v2
62-
with:
63-
php-version: ${{ matrix.php }}
64-
extensions: json, mbstring
65-
tools: composer:v2
66-
67-
- name: Install Composer dependencies
68-
uses: ramsey/composer-install@v3
60+
- name: Run Codeception Tests
61+
uses: ./codeception/action
6962
with:
7063
working-directory: plugins/${{ steps.plugin.outputs.slug }}
71-
composer-options: "--no-progress"
72-
73-
- name: Copy .env file
74-
working-directory: plugins/${{ steps.plugin.outputs.slug }}
75-
run: |
76-
cp .docker/.env.ci .env
77-
echo "INCLUDE_EXTENSIONS=${{ matrix.extensions }}" >> .env
78-
echo "WP_VERSION=${{ matrix.wordpress }}" >> .env
79-
echo "PHP_VERSION=${{ matrix.php }}" >> .env
80-
env:
81-
WP_VERSION: ${{ matrix.wordpress }}
82-
PHP_VERSION: ${{ matrix.php }}
83-
INCLUDE_EXTENSIONS: ${{ matrix.extensions }}
84-
85-
- name: Build test environment
86-
working-directory: plugins/${{ steps.plugin.outputs.slug }}
87-
run: |
88-
composer run docker:build
89-
env:
90-
WP_VERSION: ${{ matrix.wordpress }}
91-
PHP_VERSION: ${{ matrix.php }}
92-
93-
- name: Start test environment
94-
working-directory: plugins/${{ steps.plugin.outputs.slug }}
95-
run: |
96-
docker compose --env-file .env up --detach
97-
98-
CONTAINER_ID=$(docker compose ps -q wordpress)
99-
if [ -n "$CONTAINER_ID" ]; then
100-
docker exec $CONTAINER_ID init-docker.sh
101-
else
102-
echo "Error: WordPress container not found."
103-
exit 1
104-
fi
105-
env:
106-
WP_VERSION: ${{ matrix.wordpress }}
107-
PHP_VERSION: ${{ matrix.php }}
108-
109-
- name: Run Acceptance Tests w/ Docker
110-
working-directory: plugins/${{ steps.plugin.outputs.slug }}
111-
run: |
112-
if [ "${{ matrix.extensions }}" = "true" ]; then
113-
docker exec \
114-
--env DEBUG=${{ env.DEBUG }} \
115-
--env SKIP_TESTS_CLEANUP=${{ env.SKIP_TESTS_CLEANUP }} \
116-
--env SUITES=${{ env.SUITES }} \
117-
$(docker compose ps -q wordpress) \
118-
bash -c "cd wp-content/plugins/${{ steps.plugin.outputs.slug }} && bin/run-codeception.sh"
119-
fi
120-
env:
121-
DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG || matrix.debug }}
122-
SKIP_TESTS_CLEANUP: 'true'
123-
SUITES: acceptance
124-
continue-on-error: true
125-
126-
- name: Run Functional Tests w/ Docker
127-
working-directory: plugins/${{ steps.plugin.outputs.slug }}
128-
run: |
129-
docker exec \
130-
--env DEBUG=${{ env.DEBUG }} \
131-
--env SKIP_TESTS_CLEANUP=${{ env.SKIP_TESTS_CLEANUP }} \
132-
--env SUITES=${{ env.SUITES }} \
133-
$(docker compose ps -q wordpress) \
134-
bash -c "cd wp-content/plugins/${{ steps.plugin.outputs.slug }} && bin/run-codeception.sh"
135-
env:
136-
DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG || matrix.debug }}
137-
SKIP_TESTS_CLEANUP: 'true'
138-
SUITES: functional
139-
continue-on-error: true
140-
141-
- name: Run WPUnit Tests w/ Docker
142-
working-directory: plugins/${{ steps.plugin.outputs.slug }}
143-
run: |
144-
docker exec \
145-
--env COVERAGE=${{ env.COVERAGE }} \
146-
--env USING_XDEBUG=${{ env.USING_XDEBUG }} \
147-
--env DEBUG=${{ env.DEBUG }} \
148-
--env SUITES=${{ env.SUITES }} \
149-
$(docker compose ps -q wordpress) \
150-
bash -c "cd wp-content/plugins/${{ steps.plugin.outputs.slug }} && bin/run-codeception.sh"
151-
env:
152-
COVERAGE: ${{ matrix.coverage }}
153-
USING_XDEBUG: ${{ matrix.coverage }}
154-
DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG || matrix.debug }}
155-
SUITES: wpunit
64+
php: ${{ matrix.php }}
65+
wordpress: ${{ matrix.wordpress }}
66+
extensions: ${{ matrix.extensions }}
67+
coverage: ${{ matrix.coverage }}

0 commit comments

Comments
 (0)