Skip to content

Commit

Permalink
Merge pull request #1 from natbienetre/pierre.peronnet/ci
Browse files Browse the repository at this point in the history
fix(ci) Download wordpress core and use a local MySQL server
  • Loading branch information
holyhope committed Aug 12, 2023
2 parents 08f1097 + 409cee8 commit c2bf267
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,55 @@ on:

permissions:
contents: read
checks: write

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Start MySQL
run: |-
sudo /etc/init.d/mysql start
mysql -e 'CREATE DATABASE IF NOT EXISTS wordpress;' -uroot -proot
- name: Setup WP-CLI
uses: godaddy-wordpress/setup-wp-cli@1

- name: Install WordPress
run: |-
wp core download --path=wordpress --force --quiet
wp config create --path=wordpress --dbname=wordpress --dbuser=root --dbpass=root
wp core install --path=./wordpress --url=localhost --title=WordPress --admin_user=admin --admin_password=password --admin_email=wordpress@github.p2cf.com
- uses: actions/checkout@v3
with:
path: wordpress/wp-content/plugins/p2cf

- name: Validate composer.json and composer.lock
working-directory: ./wordpress/wp-content/plugins/p2cf
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
path: ./wordpress/wp-content/plugins/p2cf/vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
working-directory: ./wordpress/wp-content/plugins/p2cf
run: composer install --prefer-dist --no-progress

- name: Run test suite
working-directory: ./wordpress/wp-content/plugins/p2cf
run: composer run-script ci-test

- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: './wordpress/wp-content/plugins/p2cf/junit-result.xml'
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ languages/*.json
bin
*.bak
.phpunit.result.cache
test-result.xml
junit-result.xml
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@
"i18n-build": [
"wp i18n make-json languages --no-purge --update-mo-files --pretty-print"
],
"version": [
"grep ' * Version:' p2cf.php | sed -e 's/.*: *//'"
],
"ci-test": [
"phpunit --no-interaction --log-junit test-result.xml"
"wp scaffold plugin-tests p2cf --dir=$(pwd) --force",
"./bin/install-wp-tests.sh wordpress root root localhost latest true",
"phpunit --no-interaction --log-junit junit-result.xml"
],
"test": [
"phpunit"
Expand Down

0 comments on commit c2bf267

Please sign in to comment.