Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CI

on:
push:
branches: [ master ]
pull_request:

permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npx grunt travis:lint

phpunit:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping -proot" --health-interval=10s --health-timeout=5s --health-retries=5
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- run: composer install --no-interaction
- run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1:3306 latest
- run: vendor/bin/phpunit -c phpunit.xml.dist

qunit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: wp-content/plugins/o2
- name: Unpack WordPress core for the jQuery and Underscore the test page loads
run: curl -sL https://wordpress.org/latest.tar.gz | tar -xz --strip-components=1
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: wp-content/plugins/o2/package-lock.json
- run: npm ci
working-directory: wp-content/plugins/o2
- run: npx grunt qunit
working-directory: wp-content/plugins/o2
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ sftp-config.json
node_modules
.idea/*
*~
vendor
composer.lock
.phpunit.result.cache
57 changes: 0 additions & 57 deletions .travis.yml

This file was deleted.

10 changes: 8 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ module.exports = function(grunt) {
phplint: {
files: [
'*.php',
'**/*.php'
'**/*.php',
'!node_modules/**',
'!vendor/**'
]
},
jshint: {
Expand Down Expand Up @@ -76,15 +78,19 @@ module.exports = function(grunt) {
},
phpunit: {
'default': {
cmd: 'phpunit',
cmd: 'vendor/bin/phpunit',
args: ['-c', 'phpunit.xml.dist']
}
},
qunit: {
all: [ 'tests/qunit/index.html' ]
}
};

grunt.initConfig( cfg );

grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-wp-i18n');
grunt.loadNpmTasks('grunt-rtlcss');
Expand Down
9 changes: 8 additions & 1 deletion HACKING.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,11 @@ There are a number of core modules provided, which will give you an idea on how

## Development/Build
* Run 'npm install' to initially setup the development environment
* Run 'grunt sass' in the root of o2 to rebuild Sass files into CSS
* Run 'grunt sass' in the root of o2 to rebuild Sass files into CSS

## Testing
* Run 'composer install' to get PHPUnit and the polyfills the WordPress test library needs
* Run 'bash bin/install-wp-tests.sh <db-name> <db-user> <db-pass> [db-host] [wp-version]' once to install WordPress and its test library into /tmp (needs git and a MySQL server)
* Run 'vendor/bin/phpunit' (or 'grunt travis:phpunit') for the PHP tests
* Run 'grunt qunit' for the JavaScript tests. The test page loads jQuery and Underscore from WordPress core, so the plugin has to sit at wp-content/plugins/o2 inside a WordPress install
* 'npm test' runs lint, PHPUnit, and QUnit together
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ o2

The o2 Plugin for WordPress - blogging at the speed of thought

[![Build Status](https://travis-ci.org/Automattic/o2.svg?branch=master)](https://travis-ci.org/Automattic/o2)
[![CI](https://github.com/Automattic/o2/actions/workflows/ci.yml/badge.svg)](https://github.com/Automattic/o2/actions/workflows/ci.yml)

Dependencies
============
Expand Down
7 changes: 4 additions & 3 deletions bin/install-wp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ install_wp() {
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
fi

download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
}

install_test_suite() {
Expand All @@ -78,7 +76,10 @@ install_test_suite() {
if [ ! -d $WP_TESTS_DIR ]; then
# set up testing suite
mkdir -p $WP_TESTS_DIR
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
git clone --quiet --depth 1 --filter=blob:none --sparse --branch "${WP_TESTS_TAG#tags/}" https://github.com/WordPress/wordpress-develop.git $WP_TESTS_DIR/wordpress-develop
git -C $WP_TESTS_DIR/wordpress-develop sparse-checkout set --no-cone /tests/phpunit/includes
mv $WP_TESTS_DIR/wordpress-develop/tests/phpunit/includes $WP_TESTS_DIR/includes
rm -rf $WP_TESTS_DIR/wordpress-develop
fi

if [ ! -f wp-tests-config.php ]; then
Expand Down
8 changes: 8 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "automattic/o2",
"license": "GPL-2.0-or-later",
"require-dev": {
"phpunit/phpunit": "^9.6",
"yoast/phpunit-polyfills": "^1.1"
}
}
Loading
Loading