Skip to content

Commit 0529ae6

Browse files
authored
Merge pull request #236 from GravityKit/feature/e2e-setup
Add E2E smoke tests
2 parents 7c12ba9 + 4ea8358 commit 0529ae6

10 files changed

Lines changed: 5424 additions & 2 deletions

.circleci/config.yml

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,98 @@ anchors:
99
machine:
1010
image: default
1111

12+
test_job_config: &test_job_config
13+
<<: *context
14+
requires:
15+
- prepare_test_and_build_environment
16+
1217
jobs:
13-
build_package_release:
18+
prepare_test_and_build_environment:
1419
<<: *default_job_config
1520
steps:
1621
- checkout
1722
- run:
1823
name: Getting GravityKit test/build tools
1924
command: |
2025
git clone git@github.com:GravityKit/Tooling.git /home/circleci/tooling
26+
- run:
27+
name: Create .npmrc
28+
command: |
29+
echo "//npm.pkg.github.com/:_authToken=${GH_AUTH_TOKEN}" >> ~/.npmrc
30+
echo "@gravitykit:registry=https://npm.pkg.github.com" >> ~/.npmrc
31+
- restore_cache:
32+
key: composer-dependencies-{{ .Environment.CACHE_VERSION }}-{{ checksum "composer.lock" }}
33+
- restore_cache:
34+
key: node-dependencies-{{ .Environment.CACHE_VERSION }}-{{ checksum "package-lock.json" }}
35+
- run:
36+
name: Install dependencies
37+
command: |
38+
/home/circleci/tooling/build-tools/build_tools.sh composer -o install
39+
/home/circleci/tooling/build-tools/build_tools.sh npm -o install
40+
- run:
41+
name: Download Gravity Forms
42+
command: |
43+
/home/circleci/tooling/build-tools/build_tools.sh gh -o 'release download -R gravityforms/gravityforms --clobber --pattern "*.zip" --dir .tmp'
44+
unzip .tmp/gravityforms*.zip -d .tmp
45+
- run:
46+
name: Configure environment variables
47+
command: |
48+
cp .env.sample .env
49+
sed -i "s|WP_ENV_PLUGINS=.*|WP_ENV_PLUGINS=${PWD}/.tmp/gravityforms|" .env
50+
sed -i "s|GRAVITY_FORMS_LICENSE_KEY=.*|GRAVITY_FORMS_LICENSE_KEY=${GRAVITYFORMS_KEY}|" .env
51+
sed -i "s|GRAVITYKIT_LICENSE_KEY=.*|GRAVITYKIT_LICENSE_KEY=${GRAVITYKIT_LICENSE_KEY}|" .env
52+
- save_cache:
53+
key: composer-dependencies-{{ .Environment.CACHE_VERSION }}-{{ checksum "composer.lock" }}
54+
paths:
55+
- vendor
56+
- vendor_prefixed
57+
- save_cache:
58+
key: node-dependencies-{{ .Environment.CACHE_VERSION }}-{{ checksum "package-lock.json" }}
59+
paths:
60+
- node_modules
61+
- persist_to_workspace:
62+
root: /home/circleci
63+
paths:
64+
- .
65+
66+
run_e2e_tests:
67+
<<: *default_job_config
68+
parallelism: 1
69+
resource_class: xlarge
70+
steps:
71+
- attach_workspace:
72+
at: /home/circleci
73+
- run:
74+
name: Run E2E tests
75+
command: |
76+
attempt=0
77+
max_attempts=3
78+
sleep_time=5
79+
while [ $attempt -lt $max_attempts ]; do
80+
npm run tests:e2e:setup && break
81+
attempt=$(( attempt + 1 ))
82+
rm -rf /home/circleci/.wp-env
83+
echo "Retrying WP-ENV setup in $sleep_time seconds… (attempt $attempt/$max_attempts)"
84+
sleep $sleep_time
85+
done
86+
if [ $attempt -eq $max_attempts ]; then
87+
echo "WP-ENV setup failed."
88+
exit 1
89+
fi
90+
TESTFILES=$(circleci tests glob "tests/E2E/tests/**/*.spec.js")
91+
echo "$TESTFILES" | circleci tests run --command="xargs npx playwright test --config=tests/E2E/setup/playwright.config.js" --verbose
92+
- store_artifacts:
93+
path: tests/E2E/results
94+
- store_artifacts:
95+
path: tests/E2E/report
96+
- store_test_results:
97+
path: tests/E2E/results/junit.xml
98+
99+
build_package_release:
100+
<<: *default_job_config
101+
steps:
102+
- attach_workspace:
103+
at: /home/circleci
21104
- run:
22105
name: Building and packaging
23106
command: |
@@ -31,7 +114,7 @@ jobs:
31114
cp -R build gf-entries-in-excel
32115
rm -rf gf-entries-in-excel/build/composer.* gf-entries-in-excel/build/strauss.phar
33116
zip -gr $(ls gf-entries-in-excel-*.zip) gf-entries-in-excel
34-
zip -d $(ls gf-entries-in-excel-*.zip) "gf-entries-in-excel/src/*" "gf-entries-in-excel/assets/*"
117+
zip -d $(ls gf-entries-in-excel-*.zip) "gf-entries-in-excel/src/*" "gf-entries-in-excel/assets/*"
35118
mkdir .release
36119
cp gf-entries-in-excel-*.zip .release
37120
- run:
@@ -56,5 +139,11 @@ workflows:
56139
version: 2
57140
test_and_package:
58141
jobs:
142+
- prepare_test_and_build_environment:
143+
<<: *context
144+
- run_e2e_tests:
145+
<<: *test_job_config
59146
- build_package_release:
60147
<<: *context
148+
requires:
149+
- run_e2e_tests

.env.sample

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
WP_ENV_PLUGINS=
2+
3+
GRAVITY_FORMS_LICENSE_KEY=
4+
GRAVITYKIT_LICENSE_KEY=
5+
6+
# E2E_KEEP_DATA=0
7+
# USE_LOCAL_BROWSER=0
8+
# SLOW_MO=0

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,13 @@ vendor_prefixed
1414
!build/strauss.phar
1515
!build/vendor_prefixed/.gitkeep
1616
phpstan.neon
17+
18+
# Environment
19+
.env
20+
21+
# E2E Testing
22+
tests/E2E/setup/.wp-env.json
23+
tests/E2E/setup/.e2e-ports.json
24+
tests/E2E/setup/.state.json
25+
tests/E2E/results/
26+
tests/E2E/report/

0 commit comments

Comments
 (0)