Better CI tests (#6)

This commit is contained in:
Universal Omega 2021-09-11 12:55:27 -06:00 committed by GitHub
parent cffd29cc77
commit a62b055cfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 116 additions and 124 deletions

12
.github/workflows/download-mediawiki.sh vendored Normal file
View file

@ -0,0 +1,12 @@
#! /bin/bash
set -ex
MW_BRANCH=$1
wget https://github.com/wikimedia/mediawiki/archive/"$MW_BRANCH".tar.gz -nv
tar -zxf "$MW_BRANCH".tar.gz
mv mediawiki-"$MW_BRANCH" mediawiki
cd mediawiki
composer update --prefer-dist --no-progress

View file

@ -1,57 +0,0 @@
name: Continuous integration (REL1_36)
on:
create:
push:
pull_request:
types: [opened, synchronize]
jobs:
test:
name: Test and lint
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.3']
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
composer validate
composer install --prefer-dist --no-progress
sudo pecl install ast
echo "extension=ast" | sudo tee -a /etc/php/8.0/cli/php.ini
# Bypass the phpcbf non-standard exit code
- name: Check PHP
run: |
sh phpcbf.sh
composer fix
composer test
- name: Clone MediaWiki
run: |
git clone https://github.com/wikimedia/mediawiki.git --branch=REL1_36 --depth=1
cd mediawiki
git submodule update --init extensions/PageImages
composer install --no-dev
cd ..
- name: Run phan
run: |
composer phan
# Only patch code when it is a push event
- name: Push the changes
if: github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@users.noreply.github.com"
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git add .
git commit -am "CI: lint code to MediaWiki standards" -m "Check commit and GitHub actions for more details" || echo "No changes to commit"
git pull --rebase
git push

View file

@ -1,60 +0,0 @@
name: Continuous integration (master)
on:
create:
push:
pull_request:
types: [opened, synchronize]
jobs:
test:
name: Test and lint
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.3']
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
composer validate
composer install --prefer-dist --no-progress
sudo pecl install ast
echo "extension=ast" | sudo tee -a /etc/php/8.0/cli/php.ini
# Bypass the phpcbf non-standard exit code
- name: Check PHP
run: |
sh phpcbf.sh
composer fix
composer test
- name: Clone MediaWiki
run: |
git clone https://github.com/wikimedia/mediawiki.git --depth=1
cd mediawiki
git clone https://github.com/wikimedia/mediawiki-extensions-PageImages.git --depth=1 extensions/PageImages
composer install --no-dev
cd ..
- name: Run phan
run: |
composer phan
# - name: PHPUnit tests
# uses: php-actions/phpunit@v3
# Only patch code when it is a push event
- name: Push the changes
if: github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@users.noreply.github.com"
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git add .
git commit -am "CI: lint code to MediaWiki standards" -m "Check commit and GitHub actions for more details" || echo "No changes to commit"
git pull --rebase
git push

95
.github/workflows/mediawiki-tests.yml vendored Normal file
View file

@ -0,0 +1,95 @@
name: MediaWiki tests
on:
push:
pull_request:
branches: [ master ]
jobs:
test:
name: "MediaWiki ${{ matrix.mw }} | PHP ${{ matrix.php }}"
continue-on-error: true
strategy:
matrix:
include:
# Latest stable MediaWiki - PHP 7.3
- mw: 'REL1_36'
php: 7.3
composer: v2
continue-on-error: false
# Latest stable MediaWiki - PHP 7.4
- mw: 'REL1_36'
php: 7.4
composer: v2
continue-on-error: true
# Latest MediaWiki master
- mw: 'master'
php: 7.3
composer: v2
continue-on-error: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: intl,ast
tools: composer:${{ matrix.composer }}
- name: Install dependencies
run: |
composer validate
composer update
- name: Check PHP
if: ${{ matrix.mw == 'master' }}
run: |
sh phpcbf.sh
composer fix
composer test
- name: Cache MediaWiki
id: cache-mediawiki
uses: actions/cache@v2
with:
path: |
mediawiki
!mediawiki/extensions/
!mediawiki/vendor/
key: mw-${{ matrix.mw }}-php${{ matrix.php }}-v2
- name: Cache Composer cache
uses: actions/cache@v2
with:
path: ~/.composer/cache
key: composer-php${{ matrix.php }}
- name: Download MediaWiki
if: steps.cache-mediawiki.outputs.cache-hit != 'true'
run: |
bash .github/workflows/download-mediawiki.sh ${{ matrix.mw }}
git clone https://github.com/wikimedia/mediawiki-extensions-PageImages.git --depth=1 --branch=${{ matrix.mw }} mediawiki/extensions/PageImages
- name: Run phan
continue-on-error: ${{ matrix.continue-on-error }}
run: |
composer phan
# Only patch code when it is a push event
- name: Push the changes
if: github.event_name == 'push' && matrix.mw == 'master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@users.noreply.github.com"
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git add .
git commit -am "CI: lint code to MediaWiki standards" -m "Check commit and GitHub actions for more details" || echo "No changes to commit"
git pull --rebase
git push

1
.gitignore vendored
View file

@ -2,3 +2,4 @@
/vendor
/node_modules
/mediawiki
/*.tar.gz

View file

@ -2,8 +2,6 @@
$cfg = require __DIR__ . '/../vendor/mediawiki/mediawiki-phan-config/src/config.php';
$cfg['target_php_version'] = '7.3';
$cfg['directory_list'] = array_merge(
$cfg['directory_list'], [
'mediawiki',

View file

@ -4,10 +4,10 @@
"license": "GPL-3.0-or-later",
"require-dev": {
"mediawiki/mediawiki-codesniffer": "37.0.0",
"mediawiki/mediawiki-phan-config": "0.10.6",
"mediawiki/mediawiki-phan-config": "0.11.0",
"mediawiki/minus-x": "1.1.1",
"php-parallel-lint/php-console-highlighter": "0.5.0",
"php-parallel-lint/php-parallel-lint": "1.3.0"
"php-parallel-lint/php-parallel-lint": "1.3.1"
},
"scripts": {
"fix": [

View file

@ -35,7 +35,7 @@ class MediaWikiParserService implements ExternalParser {
return $this->cache[$wikitext];
}
$parsed = $wikitext ? $this->parser->internalParse( $wikitext, false, $this->frame ) : null;
$parsed = $this->parser->internalParse( $wikitext, false, $this->frame );
if ( in_array( substr( $parsed, 0, 1 ), [ '*', '#' ] ) ) {
// fix for first item list elements
$parsed = "\n" . $parsed;

View file

@ -6,13 +6,14 @@ use PortableInfobox\Parser\SimpleParser;
class Node {
private const DATA_SRC_ATTR_NAME = 'source';
private const NAME_ATTR_NAME = 'name';
private const DEFAULT_TAG_NAME = 'default';
private const FORMAT_TAG_NAME = 'format';
private const LABEL_TAG_NAME = 'label';
private const EXTRACT_SOURCE_REGEX = '/{{{([^\|}]*?)\|?.*}}}/sU';
protected const DATA_SRC_ATTR_NAME = 'source';
protected const LABEL_TAG_NAME = 'label';
protected $xmlNode;
protected $infoboxData;
protected $children;

View file

@ -4,6 +4,8 @@ namespace PortableInfobox\Parser\Nodes;
class NodeUnimplemented extends Node {
public function getData() {
// @phan-suppress-previous-line PhanPluginNeverReturnMethod LSP violation.
throw new UnimplementedNodeException( $this->getType() );
}
}