mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-27 09:41:46 +00:00
Better CI tests (#6)
This commit is contained in:
parent
cffd29cc77
commit
a62b055cfe
12
.github/workflows/download-mediawiki.sh
vendored
Normal file
12
.github/workflows/download-mediawiki.sh
vendored
Normal 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
|
57
.github/workflows/mediawiki-REL1_36.yml
vendored
57
.github/workflows/mediawiki-REL1_36.yml
vendored
|
@ -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
|
60
.github/workflows/mediawiki-master.yml
vendored
60
.github/workflows/mediawiki-master.yml
vendored
|
@ -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
95
.github/workflows/mediawiki-tests.yml
vendored
Normal 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
1
.gitignore
vendored
|
@ -2,3 +2,4 @@
|
|||
/vendor
|
||||
/node_modules
|
||||
/mediawiki
|
||||
/*.tar.gz
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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": [
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue