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.
Introduce CI/CD pipeline (godaddy-wordpress#217)
* start building out deploy pipeline * Update phpcs * PHPCS syntax updates * PHPCS syntax updates * PHPCS syntax updates * PHPCS syntax updates * Update permissions * Update * Updates * Updates * Updates * Updates. Get theme check running. * Updates * Updates * Update * Test deploy (without actual deploy) * Test deploy * Update test * Update deployment pipeline, setup grunt version, setup npm version major|minor|patch * Assets for a11y testing in CI/CD pipeline * Assets for a11y testing in CI/CD pipeline * Update * Tweak image to use apache * Tweak conf file name * Run a11y tests in CI/CD pipeline * Update local url * Fail ci/cd build on pa11y error * Fail ci/cd build on pa11y error * Re-run pa11y tests to display formatted output * Always output pa11y results, not just on failure * Introduce npm package command to build maverick theme locally in a build/ directory * Remove grunt dependencies for building a release package. Tweaked npm run package. * Re-add npm run build to npm run package * Clean up PHPCS warnings * Re-add npm packages removed in merge * Start framework for unit testing * Bump php version in circleci image * Add composer install * Update * Update * Install wpcli * Generate coverage, store in artifacts. Add a working_directory to the command executions. * Fix working_directory path * Tweaks * Tweaks * Tweaks * Updates * update * Updates * Updates * Renable all other tests * Consolidate WP setup scripts, update PHP versions/names in builds * Add --path flag to theme check install WPCLI command * Generate wp-config.php on a11y builds * Generate wp-config.php on theme-check builds * Add setup_wp function * Tweak setup_wp db name * Remove duplicate config create, reset db before import in a11y build * Fix path
- Loading branch information
Showing
30 changed files
with
3,045 additions
and
220 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,258 @@ | ||
workflows: | ||
version: 2 | ||
main: | ||
jobs: | ||
# Support PHP Versions | ||
# http://php.net/supported-versions.php | ||
- php56-phpcs: # EOL December 31, 2018, latest PHP version supported by Maverick | ||
filters: | ||
tags: | ||
only: /.*/ | ||
- php73-phpcs: # Will be deprecated on 30 Nov 2020 | ||
filters: | ||
tags: | ||
only: /.*/ | ||
- unit-tests: | ||
filters: | ||
tags: | ||
only: /.*/ | ||
- theme-check: | ||
filters: | ||
tags: | ||
only: /.*/ | ||
- a11y-tests: | ||
filters: | ||
tags: | ||
only: /.*/ | ||
- deploy: | ||
requires: | ||
- php56-phpcs | ||
- php73-phpcs | ||
- unit-tests | ||
- theme-check | ||
- a11y-tests | ||
filters: | ||
tags: | ||
only: /.*/ | ||
branches: | ||
ignore: /.*/ | ||
|
||
version: 2 | ||
jobs: | ||
php56-phpcs: | ||
docker: | ||
- image: circleci/php:5.6 | ||
steps: | ||
- checkout | ||
- run: | ||
name: "Setup Environment Variables" | ||
command: | | ||
echo "export PATH=$HOME/.composer/vendor/bin:$PATH" >> $BASH_ENV | ||
source /home/circleci/.bashrc | ||
- run: | ||
name: "Install Dependencies" | ||
command: | | ||
composer global require wp-coding-standards/wpcs | ||
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs | ||
- run: | ||
name: "Run PHPCS" | ||
command: phpcs --standard=phpcs.xml --extensions=php --colors -s -p -v . | ||
|
||
php73-phpcs: | ||
docker: | ||
- image: circleci/php:7.3.8 | ||
steps: | ||
- checkout | ||
- run: | ||
name: "Setup Environment Variables" | ||
command: | | ||
echo "export PATH=$HOME/.composer/vendor/bin:$PATH" >> $BASH_ENV | ||
source /home/circleci/.bashrc | ||
- run: | ||
name: "Install Dependencies" | ||
command: | | ||
composer global require wp-coding-standards/wpcs | ||
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs | ||
- run: | ||
name: "Run PHPCS" | ||
command: phpcs --standard=phpcs.xml --extensions=php --colors -s -p -v . | ||
|
||
unit-tests: | ||
docker: | ||
- image: circleci/php:7.3.8-apache-node-browsers | ||
- image: circleci/mysql:5.7 | ||
steps: | ||
- checkout | ||
- run: | ||
name: Update hosts | ||
command: echo 127.0.0.1 maverick.test | sudo tee -a /etc/hosts | ||
- run: | ||
name: Update npm | ||
command: sudo npm install -g npm@latest | ||
- run: | ||
name: Install rsync | ||
command: sudo apt install rsync | ||
- run: | ||
name: Install WPCLI | ||
command: | | ||
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | ||
chmod +x wp-cli.phar | ||
sudo mv wp-cli.phar /usr/local/bin/wp | ||
- run: | ||
name: Setup WordPress site | ||
command: bash .dev/deploy-scripts/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest | ||
- run: | ||
name: Install Composer packages | ||
command: composer install | ||
working_directory: /tmp/wordpress/wp-content/themes/maverick | ||
- restore_cache: | ||
key: dependency-cache-{{ checksum "package.json" }} | ||
- run: | ||
name: Install node packages | ||
command: npm install | ||
working_directory: /tmp/wordpress/wp-content/themes/maverick | ||
- save_cache: | ||
key: dependency-cache-{{ checksum "package.json" }} | ||
paths: | ||
- node_modules | ||
- run: | ||
name: "Run PHPUnit - Generate Coverage Reports" | ||
command: ./vendor/bin/phpunit --coverage-html=/tmp/artifacts/code-coverage/html --coverage-clover=/tmp/artifacts/code-coverage/clover --coverage-text | ||
working_directory: /tmp/wordpress/wp-content/themes/maverick | ||
- store_artifacts: | ||
path: /tmp/artifacts/code-coverage/html | ||
destination: phpunit-coverage | ||
|
||
theme-check: | ||
docker: | ||
- image: circleci/php:7.3.8-node-browsers | ||
- image: circleci/mysql:5.7 | ||
steps: | ||
- checkout | ||
- run: | ||
name: Update npm | ||
command: sudo npm install -g npm@latest | ||
- run: | ||
name: Install rsync | ||
command: sudo apt install rsync | ||
- run: | ||
name: Install Grunt.js | ||
command: sudo npm install -g grunt-cli | ||
- restore_cache: | ||
key: dependency-cache-{{ checksum "package.json" }} | ||
- run: | ||
name: Install node packages | ||
command: npm install | ||
- save_cache: | ||
key: dependency-cache-{{ checksum "package.json" }} | ||
paths: | ||
- node_modules | ||
- run: | ||
name: Install WPCLI | ||
command: | | ||
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | ||
chmod +x wp-cli.phar | ||
sudo mv wp-cli.phar /usr/local/bin/wp | ||
- run: | ||
name: Build the Maverick Theme | ||
command: npm run build | ||
- run: | ||
name: Setup WordPress site and install the Theme Check package | ||
command: bash .dev/deploy-scripts/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest | ||
- run: | ||
name: Run theme check | ||
command: wp themecheck --theme=maverick --no-interactive --path=/tmp/wordpress | ||
|
||
a11y-tests: | ||
docker: | ||
- image: circleci/php:7.3.8-apache-node-browsers | ||
- image: circleci/mysql:5.7 | ||
steps: | ||
- checkout | ||
- run: | ||
name: Update hosts | ||
command: echo 127.0.0.1 maverick.test | sudo tee -a /etc/hosts | ||
- run: | ||
name: Update npm | ||
command: sudo npm install -g npm@latest | ||
- run: | ||
name: Install rsync | ||
command: sudo apt install rsync | ||
- run: | ||
name: Install Grunt.js | ||
command: sudo npm install -g grunt-cli | ||
- restore_cache: | ||
key: dependency-cache-{{ checksum "package.json" }} | ||
- run: | ||
name: Install node packages | ||
command: npm install | ||
- save_cache: | ||
key: dependency-cache-{{ checksum "package.json" }} | ||
paths: | ||
- node_modules | ||
- run: | ||
name: Install WPCLI | ||
command: | | ||
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | ||
chmod +x wp-cli.phar | ||
sudo mv wp-cli.phar /usr/local/bin/wp | ||
- run: | ||
name: Build the Maverick Theme | ||
command: npm run build | ||
- run: | ||
name: Setup WordPress site | ||
command: bash .dev/deploy-scripts/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest | ||
- run: | ||
name: Run a11y tests | ||
command: | | ||
RESULTS=$(npm run test-a11y) | ||
# rerun tests to display the formatted output | ||
npm run test-a11y | ||
if [[ $RESULTS != *"All accessibility tests have passed"* ]]; then | ||
exit 1 | ||
fi | ||
deploy: | ||
docker: | ||
- image: circleci/golang:latest-node-browsers-legacy | ||
steps: | ||
- checkout | ||
- run: | ||
name: Update npm | ||
command: sudo npm install -g npm@latest | ||
- run: | ||
name: Install Grunt.js | ||
command: sudo npm install -g grunt-cli | ||
- run: | ||
name: Install PHP | ||
command: sudo apt-get install php libapache2-mod-php php-mbstring | ||
- run: | ||
name: Install WPCLI | ||
command: | | ||
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | ||
chmod +x wp-cli.phar | ||
sudo mv wp-cli.phar /usr/local/bin/wp | ||
- run: | ||
name: Install ghr | ||
command: | | ||
go get -u github.com/tcnksm/ghr | ||
- run: | ||
name: Install rsync | ||
command: sudo apt install rsync | ||
- run: | ||
name: Install node packages | ||
command: npm install | ||
- run: | ||
name: Build the Maverick Theme | ||
command: | | ||
npm run build | ||
mkdir -p maverick | ||
mkdir -p /tmp/artifacts | ||
rsync -av --exclude-from ~/project/.distignore --delete ~/project/. ./maverick | ||
PACKAGE_VERSION=$(jq -r ".version" < package.json) | ||
zip -r /tmp/artifacts/maverick-v$PACKAGE_VERSION.zip ./maverick | ||
- deploy: | ||
name: Deploy a new release to GitHub | ||
command: ghr -t ${GH_ACCESS_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} /tmp/artifacts | ||
- store_artifacts: | ||
path: /tmp/artifacts |
Oops, something went wrong.