Skip to content

Commit c589bfa

Browse files
authored
Merge pull request #251 from wp-graphql/fix/test-env-vars
fix: functional tests not always detecting env vars
2 parents ef88bd1 + beb7524 commit c589bfa

File tree

9 files changed

+869
-823
lines changed

9 files changed

+869
-823
lines changed

.env.example

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# WordPress Test Environment
2+
TEST_SITE_WP_URL=http://localhost:8080
3+
TEST_SITE_DB_HOST=localhost
4+
TEST_SITE_DB_NAME=wordpress_test
5+
TEST_SITE_DB_USER=root
6+
TEST_SITE_DB_PASSWORD=password
7+
TEST_SITE_TABLE_PREFIX=wp_
8+
WP_URL=http://localhost:8080
9+
TEST_SITE_ADMIN_USERNAME=admin
10+
TEST_SITE_ADMIN_PASSWORD=password
11+
12+
# ACF Configuration
13+
ACF_VERSION=latest
14+
ACF_PRO=1
15+
ACF_LICENSE_KEY=your_license_key_here
16+
ACF_EXTENDED_LICENSE_KEY=your_extended_license_key_here
17+
18+
# PHP and WordPress Configuration
19+
PHP_VERSION=8.0
20+
WP_VERSION=6.1
21+
COVERAGE=0
22+
USING_XDEBUG=0
23+
DEBUG=1
24+
SKIP_TESTS_CLEANUP=0
25+
WPGRAPHQL_CONTENT_BLOCKS=0

.github/workflows/testing-integration.yml

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,29 +76,35 @@ jobs:
7676
cp .env.dist .env
7777
cp .env.testing.dist .env.testing
7878
79-
- name: Build and run tests
79+
- name: Build test environment
8080
env:
8181
PHP_VERSION: ${{ matrix.php }}
8282
WP_VERSION: ${{ matrix.wordpress }}
83-
# NOTE: We test against WPGraphQL Content Blocks if ACF Pro is active
84-
run: |
85-
docker-compose build \
86-
--build-arg WP_VERSION=${{ matrix.wordpress }} \
87-
--build-arg PHP_VERSION=${{ matrix.php }} \
88-
--build-arg DOCKER_REGISTRY=ghcr.io/wp-graphql/
89-
docker-compose run \
90-
-e PHP_VERSION=${{ matrix.php }} \
91-
-e WP_VERSION=${{ matrix.wordpress }} \
92-
-e COVERAGE=${{ matrix.coverage }} \
93-
-e USING_XDEBUG=${{ matrix.coverage }} \
94-
-e DEBUG=${{ matrix.debug }} \
95-
-e SKIP_TESTS_CLEANUP=${{ matrix.coverage }} \
96-
-e ACF_PRO=${{matrix.acf_pro }} \
97-
-e ACF_LICENSE_KEY=${{secrets.ACF_LICENSE_KEY}} \
98-
-e ACF_VERSION=${{matrix.acf_version}} \
99-
-e ACF_EXTENDED_LICENSE_KEY=${{secrets.ACF_EXTENDED_LICENSE_KEY}} \
100-
-e WPGRAPHQL_CONTENT_BLOCKS=${{matrix.wpgraphql_content_blocks}} \
101-
testing
83+
COVERAGE: ${{ matrix.coverage }}
84+
USING_XDEBUG: ${{ matrix.coverage }}
85+
DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG || matrix.debug }}
86+
SKIP_TESTS_CLEANUP: ${{ matrix.coverage }}
87+
ACF_PRO: ${{matrix.acf_pro }}
88+
ACF_LICENSE_KEY: ${{secrets.ACF_LICENSE_KEY}}
89+
ACF_VERSION: ${{matrix.acf_version}}
90+
ACF_EXTENDED_LICENSE_KEY: ${{secrets.ACF_EXTENDED_LICENSE_KEY}}
91+
WPGRAPHQL_CONTENT_BLOCKS: ${{matrix.wpgraphql_content_blocks}}
92+
run: composer build-test
93+
94+
- name: Run tests
95+
run: composer run-test
96+
env:
97+
PHP_VERSION: ${{ matrix.php }}
98+
WP_VERSION: ${{ matrix.wordpress }}
99+
COVERAGE: ${{ matrix.coverage }}
100+
USING_XDEBUG: ${{ matrix.coverage }}
101+
DEBUG: 1
102+
SKIP_TESTS_CLEANUP: ${{ matrix.coverage }}
103+
ACF_PRO: ${{matrix.acf_pro }}
104+
ACF_LICENSE_KEY: ${{secrets.ACF_LICENSE_KEY}}
105+
ACF_VERSION: ${{matrix.acf_version}}
106+
ACF_EXTENDED_LICENSE_KEY: ${{secrets.ACF_EXTENDED_LICENSE_KEY}}
107+
WPGRAPHQL_CONTENT_BLOCKS: ${{matrix.wpgraphql_content_blocks}}
102108

103109
- name: Push Codecoverage to Coveralls.io
104110
if: ${{ matrix.coverage == 1 }}

bin/run-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ case "$subcommand" in
9999
;;
100100
t )
101101
source .env.testing
102-
docker-compose run --rm testing
102+
docker compose run --rm testing
103103
;;
104104
\? ) print_usage_instructions;;
105105
* ) print_usage_instructions;;

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"install-test-env": "bash bin/install-test-env.sh",
6767
"docker-build": "bash bin/run-docker.sh build",
6868
"docker-run": "bash bin/run-docker.sh run",
69-
"docker-destroy": "docker-compose down",
69+
"docker-destroy": "docker compose down",
7070
"build-and-run": [
7171
"@docker-build",
7272
"@docker-run"
@@ -79,7 +79,10 @@
7979
"composer install"
8080
],
8181
"run-app": "@docker-run -a",
82-
"run-test": "@docker-run -t",
82+
"run-test": [
83+
"php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
84+
"bash bin/run-docker.sh run -t"
85+
],
8386
"lint": "vendor/bin/phpcs",
8487
"phpcs-i": [
8588
"php ./vendor/bin/phpcs -i"

0 commit comments

Comments
 (0)