Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatsby-source-wordpress): use docker for tests #30938

Merged
merged 53 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
b59c5cb
use linux vm for wp int tests
TylerBarnes Apr 19, 2021
3a83793
temp comment out other tests
TylerBarnes Apr 19, 2021
d9fe56a
Revert "temp comment out other tests"
TylerBarnes Apr 19, 2021
8fb5036
temp disable other tests
TylerBarnes Apr 19, 2021
272531e
restore lint job for wp job
TylerBarnes Apr 19, 2021
124cd42
restore typecheck
TylerBarnes Apr 19, 2021
aab36c6
temp don't require unit tests
TylerBarnes Apr 19, 2021
60f01ba
remove docker node executor to use linux vm
TylerBarnes Apr 19, 2021
9a2c956
temp disable e2e test requires
TylerBarnes Apr 19, 2021
09506bc
add image with node
TylerBarnes Apr 19, 2021
6813f09
remove bad config option
TylerBarnes Apr 19, 2021
09d809b
setup nvm
TylerBarnes Apr 19, 2021
fbdfdf3
indentation
TylerBarnes Apr 19, 2021
fab2959
test
TylerBarnes Apr 19, 2021
5587380
install yarn
TylerBarnes Apr 19, 2021
3903d57
require typecheck which requires bootstrap
TylerBarnes Apr 19, 2021
41c90ec
remove steps that seem to be unneeded
TylerBarnes Apr 19, 2021
5142d91
Revert "remove steps that seem to be unneeded"
TylerBarnes Apr 19, 2021
0472459
combine run commands
TylerBarnes Apr 19, 2021
fa36ec6
move nvm commands to new line
TylerBarnes Apr 19, 2021
7c715da
break back onto multi-line since that worked before
TylerBarnes Apr 19, 2021
e49db46
use v12 instead of 12
TylerBarnes Apr 19, 2021
d937cd5
fix yarn
TylerBarnes Apr 19, 2021
04c84c7
move gatsby-source-wordpress docker-compose.yml to int tests
TylerBarnes Apr 19, 2021
aea4fd2
unignore docker wordpress dir
TylerBarnes Apr 20, 2021
09534c3
expose db to localhost for importing/exporting db
TylerBarnes Apr 20, 2021
acc9884
use closest supported docker compose version
TylerBarnes Apr 20, 2021
a4d7fb9
don't exit after printing version!
TylerBarnes Apr 20, 2021
9a95ff7
start in detached mode so the process isn't blocked
TylerBarnes Apr 20, 2021
4ce1ea5
make tests pass with correct db
TylerBarnes Apr 20, 2021
2beb0a0
bail on first failing test
TylerBarnes Apr 20, 2021
6cf2211
switch to urling from wait-on because it seems to be more reliable fo…
TylerBarnes Apr 20, 2021
a59fbb6
force prune docker in the rebuild script to remove caches
TylerBarnes Apr 21, 2021
6770387
remove unneeded exts
TylerBarnes Apr 21, 2021
005c3b4
remove core install because core is already installed
TylerBarnes Apr 21, 2021
44fe5a1
clean up plugin commands
TylerBarnes Apr 21, 2021
44be551
remove unused file
TylerBarnes Apr 21, 2021
46af385
update seed db
TylerBarnes Apr 21, 2021
11faf24
fix failing tests
TylerBarnes Apr 21, 2021
357ed3e
build with no cache before starting
TylerBarnes Apr 21, 2021
e811382
clean start
TylerBarnes Apr 21, 2021
b793936
Install CPTUI from github releases instead of from WP.org
TylerBarnes Apr 22, 2021
e0c6a3b
start docker compose in detached mode
TylerBarnes Apr 22, 2021
b9a0f70
wait for the /graphql endpoint and retry 15 times instead of 3
TylerBarnes Apr 22, 2021
c3ac33c
don't fail if there are no volumes to delete
TylerBarnes Apr 22, 2021
c0b9c88
update docker compose command to work on ci
TylerBarnes Apr 22, 2021
bb58b2c
Update config.yml
TylerBarnes Apr 23, 2021
5943c46
Update config.yml
TylerBarnes Apr 23, 2021
64ffa37
remove unneeded rebuild script
TylerBarnes Apr 23, 2021
add9285
Update tests doc
TylerBarnes Apr 23, 2021
cc52547
add info about updating the WP db
TylerBarnes Apr 23, 2021
3417249
Add contributing docs
TylerBarnes Apr 23, 2021
86e338c
revert debugging code
TylerBarnes Apr 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,16 @@ jobs:
<<: *test_template

integration_tests_gatsby_source_wordpress:
executor: node
machine: true
pieh marked this conversation as resolved.
Show resolved Hide resolved
steps:
- run:
command: |
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
echo ' [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
- run: nvm install v12
- run: nvm alias default v12
- run: nvm use v12
- run: npm i -g [email protected]
- e2e-test:
test_path: integration-tests/gatsby-source-wordpress

Expand Down
12 changes: 11 additions & 1 deletion integration-tests/gatsby-source-wordpress/.env.test
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
WPGRAPHQL_URL="https://gatsbyinttests.wpengine.com/graphql"
WPGRAPHQL_VERSION=v1.1.2
WPGATSBY_VERSION=v0.9.1
WPGRAPHQL_ACF_VERSION=v0.3.1
WPGRAPHQL_CPT_UI_VERSION=v1.1
CPT_UI_VERSION=1.8.1
ACF_VERSION=5.8.7

WPGRAPHQL_URL="http://localhost:8001/graphql"
HTACCESS_USERNAME="admin"
HTACCESS_PASSWORD="secret"
WORDPRESS_BASIC_AUTH=YWRtaW46c2VjcmV0
2 changes: 2 additions & 0 deletions integration-tests/gatsby-source-wordpress/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
WordPress
!docker/wordpress
.wordpress-cache
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,31 @@ exports[`[gatsby-source-wordpress] Run tests on develop build data resolution re
Array [
Object {
"id": "cG9zdDo3NzQ4",
"mediaItemUrl": "https://gatsbyinttests.wpengine.com/wp-content/uploads/2020/08/1002-4312x2868-1-scaled.jpg",
"mediaItemUrl": "http://localhost:8001/wp-content/uploads/2020/08/1002-4312x2868-1-scaled.jpg",
},
Object {
"id": "cG9zdDo3NzQw",
"mediaItemUrl": "https://gatsbyinttests.wpengine.com/wp-content/uploads/2020/08/file-sample_1MB.doc",
"mediaItemUrl": "http://localhost:8001/wp-content/uploads/2020/08/file-sample_1MB.doc",
},
Object {
"id": "cG9zdDo3NzU2",
"mediaItemUrl": "https://gatsbyinttests.wpengine.com/wp-content/uploads/2020/08/1001-5616x3744-1-scaled.jpg",
"mediaItemUrl": "http://localhost:8001/wp-content/uploads/2020/08/1001-5616x3744-1-scaled.jpg",
},
Object {
"id": "cG9zdDo3NzUy",
"mediaItemUrl": "https://gatsbyinttests.wpengine.com/wp-content/uploads/2020/08/1003-1181x1772-1.jpg",
"mediaItemUrl": "http://localhost:8001/wp-content/uploads/2020/08/1003-1181x1772-1.jpg",
},
Object {
"id": "cG9zdDoxMDQ0NQ==",
"mediaItemUrl": "https://gatsbyinttests.wpengine.com/wp-content/uploads/2020/10/sample.doc",
"mediaItemUrl": "http://localhost:8001/wp-content/uploads/2020/10/sample.doc",
},
Object {
"id": "cG9zdDoxMDQzOQ==",
"mediaItemUrl": "https://gatsbyinttests.wpengine.com/wp-content/uploads/2020/10/sample.pdf",
"mediaItemUrl": "http://localhost:8001/wp-content/uploads/2020/10/sample.pdf",
},
Object {
"id": "cG9zdDozNjI=",
"mediaItemUrl": "https://gatsbyinttests.wpengine.com/wp-content/uploads/2020/03/84-1000x1000-1.jpg",
"mediaItemUrl": "http://localhost:8001/wp-content/uploads/2020/03/84-1000x1000-1.jpg",
},
]
`;
Expand Down Expand Up @@ -197,7 +197,22 @@ Object {
},
"author": Object {
"node": Object {
"name": "Tyler",
"name": "admin",
},
},
"title": "Activity",
"uri": "/activity/",
"wpChildren": Object {
"nodes": Array [],
},
},
Object {
"acfPageFields": Object {
"fieldGroupName": "acfPageFields",
},
"author": Object {
"node": Object {
"name": "admin",
},
},
"title": "ACF Field Test",
Expand All @@ -222,7 +237,7 @@ Object {
"author": Object {
"node": Object {
"avatar": Object {
"url": "https://secure.gravatar.com/avatar/5fc9a2065017733c9d5f49a5ecd71d64?s=96&d=mm&r=g",
"url": "http://2.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=96&d=mm&r=g",
TylerBarnes marked this conversation as resolved.
Show resolved Hide resolved
},
"comments": Object {
"nodes": Array [],
Expand All @@ -232,7 +247,7 @@ Object {
"featuredImage": Object {
"node": Object {
"altText": "",
"sourceUrl": "https://gatsbyinttests.wpengine.com/wp-content/uploads/2020/03/84-1000x1000-1.jpg",
"sourceUrl": "http://localhost:8001/wp-content/uploads/2020/03/84-1000x1000-1.jpg",
},
},
"title": "Hello world!",
Expand Down Expand Up @@ -261,7 +276,7 @@ Object {
"generalSettingsTimeFormat": "g:i a",
"generalSettingsTimezone": "",
"generalSettingsTitle": "Automated testing for Gatsby source WordPress V4",
"generalSettingsUrl": "https://gatsbyinttests.wpengine.com",
"generalSettingsUrl": "http://localhost:8001",
"readingSettingsPostsPerPage": 10,
"writingSettingsDefaultCategory": 23,
"writingSettingsDefaultPostFormat": "",
Expand All @@ -285,13 +300,16 @@ Object {
"allWpUser": Object {
"nodes": Array [
Object {
"databaseId": 1,
"name": "Tyler",
"databaseId": 4,
"name": "admin",
"pages": Object {
"nodes": Array [
Object {
"title": "ACF Field Test",
},
Object {
"title": "Activity",
},
],
},
"posts": Object {
Expand All @@ -305,7 +323,7 @@ Object {
],
},
"testUser": Object {
"firstName": "Tyler",
"name": "admin",
},
},
"extensions": Object {},
Expand Down
9 changes: 6 additions & 3 deletions integration-tests/gatsby-source-wordpress/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ require(`dotenv`).config({
path: `.env.test`,
})

const on = require(`wait-on`)
const urling = require(`urling`)

const {
spawnGatsbyProcess,
gatsbyCleanBeforeAll,
Expand All @@ -18,7 +19,9 @@ const isWarmCache = process.env.WARM_CACHE
const testOnColdCacheOnly = isWarmCache ? test.skip : test

describe(`[gatsby-source-wordpress] Build default options`, () => {
beforeAll(done => {
beforeAll(async done => {
await urling({ url: `http://localhost:8001/graphql`, retry: 15 })
TylerBarnes marked this conversation as resolved.
Show resolved Hide resolved

if (isWarmCache) {
done()
} else {
Expand Down Expand Up @@ -51,7 +54,7 @@ describe(`[gatsby-source-wordpress] Run tests on develop build`, () => {

gatsbyDevelopProcess = spawnGatsbyProcess(`develop`)

await on({ resources: [`http://localhost:8000`] })
await urling(`http://localhost:8000`)
done()
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3.8"
version: "3.2"

services:
db:
Expand All @@ -8,23 +8,18 @@ services:
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: gtsb-wp-dckr-user
ports:
- "3306:3306"
restart: always
volumes:
- "db_data:/var/lib/mysql"
- "./docker/seed:/docker-entrypoint-initdb.d"

docker-host:
image: qoomon/docker-host
cap_add: ["NET_ADMIN", "NET_RAW"]
mem_limit: 8M
restart: on-failure

wordpress:
depends_on:
- db
env_file:
- ./test-site/.env.test
- ./test-site/.env.plugins
- ./.env.test
build:
context: ./docker/wordpress
ports:
Expand All @@ -43,12 +38,8 @@ services:
depends_on:
- db
- wordpress
# Specify versions for wp cli or composer here
environment:
CPT_UI_VERSION: 1.8.1
env_file:
- ./test-site/.env.test
- ./test-site/.env.plugins
- ./.env.test
build:
context: ./docker/wp-cli
volumes:
Expand Down
Loading