mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-70276 github actions: First cut, phpunit and grunt checks
First working version, supports phpunit (using build matrix): - php70 (lowest), running mysql. - php72 (highest), running postgres. Also verifies that the branch has been "gruntified" and there isn't any missing change (build js/css files). TODO: Verify the remaining checks currently in .travis.yml, namely: - CITEST - Add caching - Better health-check for DB images. - Support from the tracker (satus badges and enable check). - Support from CiBoT (status and enable check). - Consider moving both the common setup (git, composer...) and the database (mysql, postgres) to own actions for easier tweaking.
This commit is contained in:
parent
08707e95d2
commit
eb7930a5f4
2 changed files with 175 additions and 0 deletions
71
.github/workflows/config-template.php
vendored
Normal file
71
.github/workflows/config-template.php
vendored
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
<?php
|
||||||
|
// This file is part of Moodle - http://moodle.org/
|
||||||
|
//
|
||||||
|
// Moodle is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Moodle is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Template configuraton file for github actions CI/CD.
|
||||||
|
*
|
||||||
|
* @package core
|
||||||
|
* @copyright 2020 onwards Eloy Lafuente (stronk7) {@link https://stronk7.com}
|
||||||
|
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
|
||||||
|
// This cannot be used out from a github actions workflow, so just exit.
|
||||||
|
getenv('GITHUB_WORKFLOW') || die; // phpcs:ignore moodle.Files.MoodleInternal.MoodleInternalGlobalState
|
||||||
|
|
||||||
|
unset($CFG);
|
||||||
|
global $CFG;
|
||||||
|
$CFG = new stdClass();
|
||||||
|
|
||||||
|
$CFG->dbtype = getenv('dbtype');
|
||||||
|
$CFG->dblibrary = 'native';
|
||||||
|
$CFG->dbhost = '127.0.0.1';
|
||||||
|
$CFG->dbname = 'test';
|
||||||
|
$CFG->dbuser = 'test';
|
||||||
|
$CFG->dbpass = 'test';
|
||||||
|
$CFG->prefix = 'm_';
|
||||||
|
$CFG->dboptions = ['dbcollation' => 'utf8mb4_bin'];
|
||||||
|
|
||||||
|
$host = 'localhost';
|
||||||
|
$CFG->wwwroot = "http://{$host}";
|
||||||
|
$CFG->dataroot = realpath(dirname(__DIR__)) . '/moodledata';
|
||||||
|
$CFG->admin = 'admin';
|
||||||
|
$CFG->directorypermissions = 0777;
|
||||||
|
|
||||||
|
// Debug options - possible to be controlled by flag in future.
|
||||||
|
$CFG->debug = (E_ALL | E_STRICT); // DEBUG_DEVELOPER.
|
||||||
|
$CFG->debugdisplay = 1;
|
||||||
|
$CFG->debugstringids = 1; // Add strings=1 to url to get string ids.
|
||||||
|
$CFG->perfdebug = 15;
|
||||||
|
$CFG->debugpageinfo = 1;
|
||||||
|
$CFG->allowthemechangeonurl = 1;
|
||||||
|
$CFG->passwordpolicy = 0;
|
||||||
|
$CFG->cronclionly = 0;
|
||||||
|
$CFG->pathtophp = getenv('pathtophp');
|
||||||
|
|
||||||
|
$CFG->phpunit_dataroot = realpath(dirname(__DIR__)) . '/phpunitdata';
|
||||||
|
$CFG->phpunit_prefix = 't_';
|
||||||
|
|
||||||
|
define('TEST_EXTERNAL_FILES_HTTP_URL', 'http://localhost:8080');
|
||||||
|
define('TEST_EXTERNAL_FILES_HTTPS_URL', 'http://localhost:8080');
|
||||||
|
|
||||||
|
define('TEST_SESSION_REDIS_HOST', 'localhost');
|
||||||
|
define('TEST_CACHESTORE_REDIS_TESTSERVERS', 'localhost');
|
||||||
|
|
||||||
|
// TODO: add others (solr, mongodb, memcached, ldap...).
|
||||||
|
|
||||||
|
// Too much for now: define('PHPUNIT_LONGTEST', true); // Only leaves a few tests out and they are run later by CI.
|
||||||
|
|
||||||
|
require_once(__DIR__ . '/lib/setup.php');
|
104
.github/workflows/push.yml
vendored
Normal file
104
.github/workflows/push.yml
vendored
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
name: Core
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
env:
|
||||||
|
php: 7.2
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Grunt:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checking out code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Configuring node & npm
|
||||||
|
shell: bash -l {0}
|
||||||
|
run: nvm install
|
||||||
|
|
||||||
|
- name: Installing node stuff
|
||||||
|
run: npm install
|
||||||
|
|
||||||
|
- name: Running grunt
|
||||||
|
run: npx grunt
|
||||||
|
|
||||||
|
- name: Looking for uncommitted changes
|
||||||
|
# Add all files to the git index and then run diff --cached to see all changes.
|
||||||
|
# This ensures that we get the status of all files, including new files.
|
||||||
|
# We ignore npm-shrinkwrap.json to make the tasks immune to npm changes.
|
||||||
|
run: |
|
||||||
|
git add .
|
||||||
|
git reset -- npm-shrinkwrap.json
|
||||||
|
git diff --cached --exit-code
|
||||||
|
|
||||||
|
PHPUnit:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
services:
|
||||||
|
exttests:
|
||||||
|
image: moodlehq/moodle-exttests
|
||||||
|
ports:
|
||||||
|
- 8080:80
|
||||||
|
redis:
|
||||||
|
image: redis
|
||||||
|
ports:
|
||||||
|
- 6379:6379
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-18.04
|
||||||
|
php: 7.0
|
||||||
|
db: mysqli
|
||||||
|
- os: ubuntu-18.04
|
||||||
|
php: 7.2
|
||||||
|
db: pgsql
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Setting up DB mysql
|
||||||
|
if: ${{ matrix.db == 'mysqli' }}
|
||||||
|
uses: johanmeiring/mysql-action@tmpfs-patch
|
||||||
|
with:
|
||||||
|
collation server: utf8mb4_bin
|
||||||
|
mysql version: 5.7
|
||||||
|
mysql database: test
|
||||||
|
mysql user: test
|
||||||
|
mysql password: test
|
||||||
|
use tmpfs: true
|
||||||
|
|
||||||
|
- name: Setting up DB pgsql
|
||||||
|
if: ${{ matrix.db == 'pgsql' }}
|
||||||
|
uses: m4nu56/postgresql-action@v1
|
||||||
|
with:
|
||||||
|
postgresql version: 9.6
|
||||||
|
postgresql db: test
|
||||||
|
postgresql user: test
|
||||||
|
postgresql password: test
|
||||||
|
|
||||||
|
- name: Configuring git vars
|
||||||
|
uses: rlespinasse/github-slug-action@v3.x
|
||||||
|
|
||||||
|
- name: Setting up PHP ${{ matrix.php }}
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php }}
|
||||||
|
extensions: mysqli, zip, gd, xmlrpc, soap
|
||||||
|
coverage: none
|
||||||
|
|
||||||
|
- name: Checking out code from ${{ env.GITHUB_REF_SLUG }}
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setting up PHPUnit
|
||||||
|
env:
|
||||||
|
dbtype: ${{ matrix.db }}
|
||||||
|
run: |
|
||||||
|
echo "pathtophp=$(which php)" >> $GITHUB_ENV # Inject installed pathtophp to env. The template config needs it.
|
||||||
|
cp .github/workflows/config-template.php config.php
|
||||||
|
mkdir ../moodledata
|
||||||
|
sudo locale-gen en_AU.UTF-8
|
||||||
|
php admin/tool/phpunit/cli/init.php --no-composer-self-update
|
||||||
|
|
||||||
|
- name: Running PHPUnit tests
|
||||||
|
env:
|
||||||
|
dbtype: ${{ matrix.db }}
|
||||||
|
run: vendor/bin/phpunit -v
|
Loading…
Add table
Add a link
Reference in a new issue