forked from godaddy-wordpress/go
-
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.
Improve CircleCI builds (godaddy-wordpress#718)
- Loading branch information
1 parent
1b2f18e
commit af6876d
Showing
131 changed files
with
1,050 additions
and
1,337 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,18 @@ | ||
#! /bin/bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
URLS=$(curl -sS https://wpnux.godaddy.com/v2/api/templates | jq -r '.[].styles[].preview_url') | ||
|
||
for URL in $URLS; do | ||
params=(${URL//[=&]/ }) | ||
|
||
template=${params[1]} | ||
style=${params[3]} | ||
|
||
preview_url=$(printf '%q' "$URL") | ||
spec_filename="${template}-${style}.spec.js" | ||
|
||
sed "s/{{TEMPLATE}}/$template/g; s/{{STYLE}}/$style/g; s,{{PREVIEW_URL}},$preview_url,g;" .dev/tests/cypress/vr-template.stub > ".dev/tests/cypress/integration/visual-regression/${spec_filename}" | ||
done |
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,51 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Allow files to be passed into the script | ||
CHANGEDFILES=${@-$(git diff --name-only origin/master)} | ||
SPECS=() | ||
SPECSTRING='' | ||
TEMPLATE_INCLUDES='' | ||
|
||
for FILE in $CHANGEDFILES | ||
do | ||
# Changed file matches /.dev/assets/design-styles/* | ||
if [[ $FILE == *".dev/assets/design-styles/"* ]]; then | ||
testSpec=$(echo $FILE | cut -d'/' -f4) | ||
foundwords=$(echo ${SPECS[@]} | grep -o "${testSpec}" | wc -w) | ||
# The test spec does not yet exist in the SPECS array | ||
if [[ "${foundwords}" -eq 0 ]]; then | ||
# Spec file string is empty, do not start string with a , | ||
if [[ ${#SPECSTRING} -eq 0 ]]; then | ||
SPECSTRING=".dev/tests/cypress/integration/visual-regression/*-$testSpec.spec.js" | ||
else | ||
SPECSTRING="${SPECSTRING},.dev/tests/cypress/integration/visual-regression/*-$testSpec.spec.js" | ||
fi | ||
SPECS=( "${SPECS[@]}" "${testSpec}" ) | ||
fi | ||
fi | ||
done | ||
|
||
# No spec files to run | ||
if [ ${#SPECS[@]} -eq 0 ]; then | ||
echo "Changes do not require visual regression testing." | ||
circleci-agent step halt | ||
exit | ||
fi | ||
|
||
printf "\n\033[0;33mRunning the following Cypress spec files: ${SPECS[*]}\033[0m\n" | ||
|
||
# Store $SPECSTRING value in /tmp/specstring file for later use | ||
echo $SPECSTRING > /tmp/specstring | ||
|
||
for SPEC in "${SPECS[@]}" | ||
do | ||
# Spec file string is empty, do not start string with a , | ||
if [[ ${#TEMPLATE_INCLUDES} -eq 0 ]]; then | ||
TEMPLATE_INCLUDES="--include '*$SPEC*'" | ||
else | ||
TEMPLATE_INCLUDES="${TEMPLATE_INCLUDES} --include '*$SPEC*'" | ||
fi | ||
done | ||
|
||
# Store $TEMPLATE_INCLUDES value in /tmp/template_includes file for later use | ||
echo $TEMPLATE_INCLUDES > /tmp/template_includes |
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 |
---|---|---|
|
@@ -17,7 +17,7 @@ DB_HOST=${4-localhost} | |
WP_VERSION=${5-latest} | ||
SKIP_DB_CREATE=${6-false} | ||
|
||
TMPDIR=${TMPDIR-/tmp} | ||
TMPDIR=${TMPDIR-/var/www/html} | ||
TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//") | ||
WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib} | ||
WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/} | ||
|
@@ -45,9 +45,9 @@ elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then | |
WP_TESTS_TAG="trunk" | ||
else | ||
# http serves a single offer, whereas https serves multiple. we only want one | ||
download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json | ||
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json | ||
LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//') | ||
download http://api.wordpress.org/core/version-check/1.7/ /var/www/html/wp-latest.json | ||
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /var/www/html/wp-latest.json | ||
LATEST_VERSION=$(grep -o '"version":"[^"]*' /var/www/html/wp-latest.json | sed 's/"version":"//') | ||
if [[ -z "$LATEST_VERSION" ]]; then | ||
echo "Latest WordPress version could not be found" | ||
exit 1 | ||
|
@@ -117,6 +117,8 @@ setup_wp() { | |
[email protected] \ | ||
--skip-email \ | ||
--path=$WP_CORE_DIR | ||
|
||
wp option set permalink_structure "/%postname%/" --path=$WP_CORE_DIR | ||
} | ||
|
||
install_test_suite() { | ||
|
@@ -174,6 +176,17 @@ install_db() { | |
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA | ||
} | ||
|
||
install_rsync() { | ||
|
||
if [ ! -z $(which rsync) ]; then | ||
return 0 | ||
fi | ||
|
||
sudo apt-get update --allow-releaseinfo-change | ||
sudo apt install rsync | ||
|
||
} | ||
|
||
install_wp | ||
setup_wp | ||
install_test_suite | ||
|
@@ -185,10 +198,14 @@ if [ "$CIRCLE_JOB" == 'theme-check' ]; then | |
cd ~/.wp-cli/packages/vendor/anhskohbo/wp-cli-themecheck && git pull | ||
fi | ||
|
||
if [ "$CIRCLE_JOB" == 'a11y-tests' ]; then | ||
if [[ "$CIRCLE_JOB" == 'a11y-tests' || "$CIRCLE_JOB" == 'visual-regression-chrome' || "$CIRCLE_JOB" == 'visual-regression-firefox' ]]; then | ||
sudo cp ~/project/.dev/tests/apache-ci.conf /etc/apache2/sites-available | ||
sudo a2ensite apache-ci.conf | ||
sudo a2enmod rewrite | ||
sudo service apache2 restart | ||
fi | ||
|
||
if [[ "$CIRCLE_JOB" == 'a11y-tests' ]]; then | ||
wp db reset --yes --path=$WP_CORE_DIR | ||
wp db import ~/project/.dev/tests/a11y-test-db.sql --path=$WP_CORE_DIR | ||
wp search-replace https://go.test http://go.test --path=$WP_CORE_DIR | ||
|
@@ -197,9 +214,29 @@ fi | |
export INSTALL_PATH=$WP_CORE_DIR/wp-content/themes/go | ||
mkdir -p $INSTALL_PATH | ||
|
||
if [[ "$CIRCLE_JOB" == 'unit-test-73' || "$CIRCLE_JOB" == 'unit-test-74' ]]; then | ||
# Unit test job, copy entire directory including config files | ||
rsync -av --delete ~/project/. $INSTALL_PATH/ | ||
# If the ~/project/go directory exists, it persisted from the build job | ||
if [ -d ~/project/go ]; then | ||
cp -r ~/project/go/* $INSTALL_PATH/ | ||
else | ||
install_rsync | ||
rsync -av --exclude-from ~/project/.distignore --delete ~/project/. $INSTALL_PATH/ | ||
fi | ||
|
||
# PHPUnit requires the configuration file, the .dev/tests directory and | ||
# the languages directory (which is not shipped in the build) | ||
if [[ "$CIRCLE_JOB" == 'unit-tests' ]]; then | ||
cp -r ~/project/languages $INSTALL_PATH/ | ||
cp ~/project/composer.json $INSTALL_PATH/ | ||
cp ~/project/composer.lock $INSTALL_PATH/ | ||
cp -r ~/project/.dev $INSTALL_PATH/ | ||
cp ~/project/phpunit.xml $INSTALL_PATH/ | ||
fi | ||
|
||
# Visual regression tests need the .dev and the languages directories | ||
if [[ "$CIRCLE_JOB" == 'visual-regression-chrome' || "$CIRCLE_JOB" == 'visual-regression-firefox' ]]; then | ||
cp ~/project/composer.json $INSTALL_PATH/ | ||
cp ~/project/composer.lock $INSTALL_PATH/ | ||
cp -r ~/project/languages $INSTALL_PATH/ | ||
cp -r ~/project/.dev $INSTALL_PATH/ | ||
wp theme activate go --path=$WP_CORE_DIR | ||
fi |
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
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
Oops, something went wrong.