forked from wpengine/wp-graphql-content-blocks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build(GH): upload schema artifact (wpengine#125)
* Build(GH): WIP upload schema artifact * Build: Update composer.json scripts * Build: use WP_CORE_DIR * Build: Add install-test-env * Build: Add .env.dist * Build: Add missing install step * Build: Add missing wp rewrite structure * Build: Add data folder * Build: Fix configure_wordpress * Build: Fix $WP_CORE_DIR * Build: Fix WP_CORE_DIR * Build: Add missing composer install --no-dev * Build: Upload artifact * Build: Upload Artifact * Build: Add schema-linter task * Build: Update push trigger * Build: Add missing steps * Build: Remove quote * Lint: Add missing type descriptions * Build: Reuse setup-wordpress action * Build: Fix action.yml * Build: Uses actions/checkout@v2 * Build: Use checkout before calling action * Build: Add missing shell: bash * Lint: phpcs fix * Lint: Add missing comment * Refactor: install-test-env * Chore: Refactor scripts * Build: Change on release mode for Upload task * Update .github/actions/setup-wordpress/action.yml Co-authored-by: John Parris <[email protected]> --------- Co-authored-by: John Parris <[email protected]>
- Loading branch information
Showing
15 changed files
with
426 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# COPY THIS TO .env and change the values | ||
|
||
# Used to create the WP install. | ||
DB_NAME=wordpress | ||
DB_HOST=app_db | ||
DB_USER=wordpress | ||
DB_PASSWORD=wordpress | ||
|
||
WP_TABLE_PREFIX=wp_ | ||
WP_URL=http://localhost:8091 | ||
WP_DOMAIN=localhost | ||
WP_ROOT_FOLDER=/tmp/wordpress | ||
|
||
[email protected] | ||
ADMIN_USERNAME=admin | ||
ADMIN_PASSWORD=password | ||
ADMIN_PATH=/wp-admin | ||
|
||
# Used by Codeception/WPBrowser | ||
# If running locally, these are likely the same as above | ||
TEST_DB_NAME=wptests | ||
TEST_DB_HOST=127.0.0.1 | ||
TEST_DB_USER=root | ||
TEST_DB_PASSWORD=root | ||
|
||
TEST_WP_TABLE_PREFIX=wp_ | ||
TEST_WP_URL=http://localhost:8091 | ||
TEST_WP_DOMAIN=localhost | ||
TEST_WP_ROOT_FOLDER=/tmp/wordpress | ||
[email protected] | ||
|
||
TESTS_DIR=tests | ||
TESTS_OUTPUT=tests/_output | ||
TESTS_DATA=tests/_data | ||
TESTS_SUPPORT=tests/_support | ||
TESTS_ENVS=tests/_envs | ||
|
||
# Used by wp-config.php | ||
WORDPRESS_DB_HOST=${DB_HOST} | ||
WORDPRESS_DB_USER=${DB_USER} | ||
WORDPRESS_DB_PASSWORD=${DB_PASSWORD} | ||
WORDPRESS_DB_NAME=${DB_NAME} | ||
WORDPRESS_TABLE_PREFIX=${WP_TABLE_PREFIX} | ||
|
||
# If your docker instance differs from the local WP install, change these values. | ||
MYSQL_ROOT_PASSWORD=${DB_PASSWORD} | ||
MYSQL_DATABASE=${DB_NAME} | ||
MYSQL_USER=${DB_USER} | ||
MYSQL_PASSWORD=${DB_PASSWORD} | ||
|
||
# Change these to test different versions of WP, WPGraphQL, ACF etc. | ||
WP_VERSION=6.2 | ||
PHP_VERSION=8.0 | ||
WPGRAPHQL_VERSION=latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Set up WordPress | ||
description: Sets up WordPress. Assumes mariadb is available as a service. | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Setup PHP w/ Composer & WP-CLI | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.0 | ||
extensions: mbstring, intl, bcmath, exif, gd, mysqli, opcache, zip, pdo_mysql | ||
coverage: none | ||
tools: composer:v2, wp-cli | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
|
||
- name: Install dependencies | ||
shell: bash | ||
run: composer install --no-dev | ||
|
||
- name: Setup WordPress | ||
shell: bash | ||
run: | | ||
cp .env.dist .env | ||
composer run install-test-env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Schema Linter | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
- main | ||
pull_request: | ||
branches: | ||
- develop | ||
- main | ||
|
||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
name: Lint WPGraphQL Schema | ||
if: contains(github.event.pull_request.labels.*.name, 'safe to test ✔') || github.repository == github.event.repository.full_name || github.event_name == 'push' | ||
|
||
services: | ||
mariadb: | ||
image: mariadb:10.8.2 | ||
ports: | ||
- 3306:3306 | ||
env: | ||
MYSQL_ROOT_PASSWORD: root | ||
# Ensure docker waits for mariadb to start | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
||
steps: | ||
- name: Cancel previous runs of this workflow (pull requests only) | ||
if: ${{ github.event_name == 'pull_request_target' }} | ||
uses: styfle/[email protected] | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Setup WordPress | ||
uses: ./.github/actions/setup-wordpress | ||
|
||
- name: Setup GraphQL Schema Linter | ||
run: npm install -g graphql-schema-linter@^3.0 graphql@^16 | ||
|
||
- name: Generate the Static Schema | ||
run: | | ||
cd /tmp/wordpress/ | ||
# Output: /tmp/schema.graphql | ||
wp graphql generate-static-schema | ||
- name: Lint the Static Schema | ||
run: | | ||
graphql-schema-linter --except=relay-connection-types-spec,relay-page-info-spec /tmp/schema.graphql | ||
- name: Display ignored linting errors | ||
run: | | ||
graphql-schema-linter /tmp/schema.graphql || true | ||
- name: Get Latest tag | ||
uses: actions-ecosystem/action-get-latest-tag@v1 | ||
id: get-latest-tag | ||
|
||
- name: Test Schema for breaking changes | ||
run: | | ||
echo "Previous tagged schema ${{ steps.get-latest-tag.outputs.tag }}" | ||
- name: Get Previous Released Schema | ||
run: curl 'https://github.com/wp-graphql-content-blocks/releases/download/${{ steps.get-latest-tag.outputs.tag }}/schema.graphql' -L --output /tmp/${{ steps.get-latest-tag.outputs.tag }}.graphql | ||
|
||
# https://github.com/marketplace/actions/graphql-inspector | ||
- name: Install Schema Inspector | ||
run: | | ||
npm install @graphql-inspector/config @graphql-inspector/cli graphql | ||
- name: Run Schema Inspector | ||
run: | | ||
# This schema and previous release schema | ||
node_modules/.bin/graphql-inspector diff /tmp/${{ steps.get-latest-tag.outputs.tag }}.graphql /tmp/schema.graphql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Upload Schema Artifact | ||
|
||
on: | ||
release: | ||
types: [ published ] | ||
|
||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
name: Generate and Upload WPGraphQL Schema Artifact | ||
services: | ||
mariadb: | ||
image: mariadb:10.8.2 | ||
ports: | ||
- 3306:3306 | ||
env: | ||
MYSQL_ROOT_PASSWORD: root | ||
# Ensure docker waits for mariadb to start | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: Setup WordPress | ||
uses: ./.github/actions/setup-wordpress | ||
|
||
- name: Generate the Static Schema | ||
run: | | ||
cd /tmp/wordpress | ||
# Output: /tmp/schema.graphql | ||
wp graphql generate-static-schema | ||
- name: Upload schema as release artifact | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: /tmp/schema.graphql | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
|
||
set +u | ||
|
||
print_usage_instruction() { | ||
echo "ERROR!" | ||
echo "Values in the .env file are missing or incorrect." | ||
echo "Open the .env file at the root of this plugin and enter values to match your local environment settings" | ||
exit 1 | ||
} | ||
|
||
if [[ -z "$TEST_DB_NAME" ]]; then | ||
echo "TEST_DB_NAME not found" | ||
print_usage_instruction | ||
else | ||
DB_NAME=$TEST_DB_NAME | ||
fi | ||
if [[ -z "$TEST_DB_USER" ]]; then | ||
echo "TEST_DB_USER not found" | ||
print_usage_instruction | ||
else | ||
DB_USER=$TEST_DB_USER | ||
fi | ||
|
||
DB_HOST=${TEST_DB_HOST-localhost} | ||
DB_PASS=${TEST_DB_PASSWORD-""} | ||
WP_VERSION=${WP_VERSION-latest} | ||
TMPDIR=${TMPDIR-/tmp} | ||
TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//") | ||
WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib} | ||
WP_CORE_DIR=${TEST_WP_ROOT_FOLDER-$TMPDIR/wordpress/} | ||
PLUGIN_DIR=$(pwd) | ||
if [[ ! -z "$PLUGIN_SLUG" ]]; then | ||
PLUGIN_DIR="${PLUGIN_DIR}/${PLUGIN_SLUG}" | ||
echo "Using $PLUGIN_DIR as source" | ||
fi | ||
|
||
WP_CLI_CONFIG_PATH="${PLUGIN_DIR}/bin/wp-cli.yml" | ||
|
||
SKIP_DB_CREATE=${SKIP_DB_CREATE-false} |
Oops, something went wrong.