Update composer.json #67
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
name: Acceptance | |
# Runs Wp-Browser Codeception acceptance tests. | |
# | |
# @author BrianHenryIE | |
on: ["push"] | |
jobs: | |
acceptance: | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mysql:8.0 | |
env: | |
MYSQL_ROOT_PASSWORD: password | |
MYSQL_DATABASE: test | |
ports: | |
- 3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
strategy: | |
matrix: | |
php: [ '7.4' ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
tools: composer, cs2pr | |
extensions: zip | |
- name: Read .env.testing | |
uses: c-py/action-dotenv-to-setenv@v2 | |
with: | |
env-file: .env.testing | |
- name: Read .env.github | |
uses: c-py/action-dotenv-to-setenv@v2 | |
with: | |
env-file: .env.github | |
# - name: Make envfile from Secrets | |
# uses: SpicyPizza/[email protected] | |
# with: | |
# envkey_SECRET_NAME: ${{ secrets.SECRET_NAME }} | |
# directory: ${{ github.workspace }} | |
# file_name: .env.secret | |
# - name: Read .env.secret | |
# uses: c-py/action-dotenv-to-setenv@v2 | |
# with: | |
# env-file: .env.secret | |
- name: Set env database host w/port | |
run: echo "TEST_SITE_DB_HOST=127.0.0.1:${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV | |
- name: Configure MySQL | |
run: | | |
mysql -h 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u root -ppassword -e "CREATE USER '"$TEST_DB_USER"'@'%' IDENTIFIED WITH mysql_native_password BY '"$TEST_DB_PASSWORD"';"; | |
mysql -h 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u root -ppassword -e "CREATE DATABASE "$TEST_SITE_DB_NAME"; USE "$TEST_SITE_DB_NAME"; GRANT ALL PRIVILEGES ON "$TEST_SITE_DB_NAME".* TO '"$TEST_DB_USER"'@'%';"; | |
mysql -h 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u root -ppassword -e "CREATE DATABASE "$TEST_DB_NAME"; USE "$TEST_DB_NAME"; GRANT ALL PRIVILEGES ON "$TEST_DB_NAME".* TO '"$TEST_DB_USER"'@'%';"; | |
# - name: Create Composer auth.json from GitHub secrets | |
# run: php -r "file_put_contents( 'auth.json', json_encode( [ 'http-basic' => [ 'blog.brianhenry.ie' => [ 'username' => '"${{ secrets.COMPOSER_AUTH_SECRET }}"', 'password' => 'satispress' ] ] ] ) );" | |
- name: Run composer install | |
uses: php-actions/composer@v6 | |
with: | |
args: --ignore-platform-reqs | |
- name: Create wpconfig ... the composer.json creation didn't work | |
run: | | |
export $(grep -v '^#' .env.testing | xargs); | |
sudo vendor/bin/wp config create --dbname=$TEST_SITE_DB_NAME --dbuser=$TEST_SITE_DB_USER --dbpass=$TEST_SITE_DB_PASSWORD --dbhost=127.0.0.1:${{ job.services.mysql.ports['3306'] }} --allow-root --extra-php="define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true );" | |
- name: Update site URL to match GA | |
run: | | |
find . -depth \( -name 'dump.sql' \) -exec sed -i "s/localhost:8080\/$PLUGIN_SLUG/localhost:8080/g" {} + | |
- name: Start webserver | |
run: | | |
sudo chmod -R a+w wp-content | |
php -S localhost:8080 -t wordpress/ & | |
sleep 5 | |
- name: Run acceptance tests | |
run: vendor/bin/codecept run acceptance | |
- name: Save config and output on failure | |
uses: actions/upload-artifact@v2 | |
if: ${{ failure() }} | |
with: | |
name: acceptance-test-failure | |
path: | | |
tests/_output/*fail.html | |
composer.json | |
wordpress/wp-config.php | |
.env.testing | |
tests/_data/dump.sql | |
wp-content/*.log |