Update workflow (#45)

This commit is contained in:
Universal Omega 2021-12-18 16:13:57 -07:00 committed by GitHub
parent e9fa767f97
commit 62f733ed00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 111 deletions

View file

@ -1,46 +0,0 @@
name: PHPCS
on:
push:
pull_request:
branches: [ master ]
jobs:
phpcs:
name: PHPCS
continue-on-error: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
composer validate
composer update
- name: Check PHP
run: |
sh phpcbf.sh
composer fix
composer test
- name: Cache Composer cache
uses: actions/cache@v2
with:
path: ~/.composer/cache
key: composer-php8
# 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

@ -52,7 +52,7 @@ jobs:
- mw: 'master' - mw: 'master'
php: 7.3 php: 7.3
php-docker: 73 php-docker: 73
experimental: true experimental: false
stage: coverage stage: coverage
# Latest stable MediaWiki - PHP 7.3 (phpunit-unit) # Latest stable MediaWiki - PHP 7.3 (phpunit-unit)
@ -73,7 +73,7 @@ jobs:
- mw: 'master' - mw: 'master'
php: 7.3 php: 7.3
php-docker: 73 php-docker: 73
experimental: true experimental: false
stage: phpunit-unit stage: phpunit-unit
# Latest MediaWiki master - PHP 7.4 (phpunit-unit) # Latest MediaWiki master - PHP 7.4 (phpunit-unit)
@ -111,34 +111,6 @@ jobs:
experimental: true experimental: true
stage: phpunit stage: phpunit
# Latest stable MediaWiki - PHP 7.3 (phpunit-standalone)
# - mw: 'REL1_37'
# php: 7.3
# php-docker: 73
# experimental: false
# stage: phpunit-standalone
# Latest stable MediaWiki - PHP 7.4 (phpunit-standalone)
# - mw: 'REL1_37'
# php: 7.4
# php-docker: 74
# experimental: false
# stage: phpunit-standalone
# Latest MediaWiki master - PHP 7.3 (phpunit-standalone)
# - mw: 'master'
# php: 7.3
# php-docker: 73
# experimental: true
# stage: phpunit-standalone
# Latest MediaWiki master - PHP 7.4 (phpunit-standalone)
# - mw: 'master'
# php: 7.4
# php-docker: 74
# experimental: true
# stage: phpunit-standalone
# Latest stable MediaWiki - PHP 7.3 (selenium) # Latest stable MediaWiki - PHP 7.3 (selenium)
- mw: 'REL1_37' - mw: 'REL1_37'
php: 7.3 php: 7.3
@ -150,7 +122,7 @@ jobs:
- mw: 'master' - mw: 'master'
php: 7.3 php: 7.3
php-docker: 73 php-docker: 73
experimental: true experimental: false
stage: selenium stage: selenium
# Latest stable MediaWiki - PHP 7.3 (qunit) # Latest stable MediaWiki - PHP 7.3 (qunit)
@ -164,7 +136,7 @@ jobs:
- mw: 'master' - mw: 'master'
php: 7.3 php: 7.3
php-docker: 73 php-docker: 73
experimental: true experimental: false
stage: qunit stage: qunit
# Latest stable MediaWiki - PHP 7.3 (npm-test) # Latest stable MediaWiki - PHP 7.3 (npm-test)
@ -174,13 +146,6 @@ jobs:
experimental: false experimental: false
stage: npm-test stage: npm-test
# Latest MediaWiki master - PHP 7.3 (npm-test)
- mw: 'master'
php: 7.3
php-docker: 73
experimental: true
stage: npm-test
# Latest stable MediaWiki - PHP 7.3 (composer-test) # Latest stable MediaWiki - PHP 7.3 (composer-test)
- mw: 'REL1_37' - mw: 'REL1_37'
php: 7.3 php: 7.3
@ -188,13 +153,6 @@ jobs:
experimental: false experimental: false
stage: composer-test stage: composer-test
# Latest MediaWiki master - PHP 7.3 (composer-test)
- mw: 'master'
php: 7.3
php-docker: 73
experimental: true
stage: composer-test
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
@ -205,13 +163,19 @@ jobs:
PHAN_DOCKER_IMAGE: mediawiki-phan-php${{ matrix.php-docker }} PHAN_DOCKER_IMAGE: mediawiki-phan-php${{ matrix.php-docker }}
steps: steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2 - uses: actions/checkout@v2
# /home/runner/cache/ Cache # /home/runner/cache/ Cache
# /home/runner/src/ Mediawiki installation # /home/runner/src/ Mediawiki installation
# /home/runner/src/extensions/EXTENSION_NAME/ Clone of the extension repository # /home/runner/src/extensions/EXTENSION_NAME/ Clone of the extension repository
# /home/runner/docker-images/ Docker images which exported with docker-save command # /home/runner/docker-images/ Docker images which exported with docker-save command
# $GITHUB_WORKSPACE/.github/workflows/dependencies Used by actions/cache # $GITHUB_WORKSPACE/.github/workflows/dependencies Necessary dependencies - YAML syntax
# $GITHUB_WORKSPACE/.github/workflows/globals.php Add global configuration options for MediaWiki
- name: Set up - name: Set up
run: | run: |
echo MEDIAWIKI_VERSION="${{ matrix.mw }}" >> $GITHUB_ENV echo MEDIAWIKI_VERSION="${{ matrix.mw }}" >> $GITHUB_ENV
@ -276,10 +240,20 @@ jobs:
for dep in $DEPENDENCIES; do for dep in $DEPENDENCIES; do
dependency=$(echo $dep | cut -d'|' -f1) dependency=$(echo $dep | cut -d'|' -f1)
repository=$(echo $dep | cut -sd'|' -f2) repository=$(echo $dep | cut -sd'|' -f2)
branch=$(echo $dep | cut -sd'|' -f3) branch=$(echo $dep | rev | cut -sd'|' -f1 | rev)
git clone --recurse-submodules -b "${branch:-${MEDIAWIKI_VERSION}}" --depth 1 "${repository:-https://gerrit.wikimedia.org/r/${dep}}" src/"$(echo $dependency | cut -d'/' -f2,3)"
if [ $repository == $branch ]; then
repository=""
fi
git clone --recurse-submodules -b "${branch:-${MEDIAWIKI_VERSION}}" --depth 1 "${repository:-https://gerrit.wikimedia.org/r/${dependency}}" src/"$(echo $dependency | cut -d'/' -f2,3)"
done done
fi fi
if [ -e "$GITHUB_WORKSPACE"/.github/workflows/globals.php ]; then
echo 'require_once __DIR__ . "/../extensions/${{ github.event.repository.name }}/.github/workflows/globals.php";' >> src/includes/DevelopmentSettings.php
fi
git -C src/ log -n 1 --format="%H" git -C src/ log -n 1 --format="%H"
- name: Cache dependencies (composer and npm) - name: Cache dependencies (composer and npm)
@ -302,6 +276,28 @@ jobs:
composer install --prefer-dist --no-progress --no-interaction composer install --prefer-dist --no-progress --no-interaction
fi fi
- name: Fix PHPCS violations
continue-on-error: true
if: ${{ github.event_name == 'pull_request' && matrix.stage == 'composer-test' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ -e composer.json ]; then
composer install --prefer-dist --no-progress --no-interaction
composer fix
rm composer.lock
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 checkout -b ${GITHUB_HEAD_REF}
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 origin ${GITHUB_HEAD_REF} --rebase
git push --set-upstream origin ${GITHUB_HEAD_REF}
fi
- name: Main Test - name: Main Test
continue-on-error: ${{ matrix.experimental }} continue-on-error: ${{ matrix.experimental }}
run: | run: |

View file

@ -1,15 +1,12 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<ruleset> <ruleset>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki" />
<file>.</file> <file>.</file>
<arg name="bootstrap" value="./vendor/mediawiki/mediawiki-codesniffer/utils/bootstrap-ci.php"/>
<arg name="extensions" value="php"/>
<arg name="encoding" value="UTF-8"/>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/out/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern> <exclude-pattern>*/tests/*</exclude-pattern>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki"> <rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<exclude name="Generic.Files.LineLength.TooLong" /> <exclude name="Generic.Files.LineLength.TooLong" />
<exclude name="MediaWiki.Commenting" /> <exclude name="MediaWiki.Commenting" />
</rule> </rule>
<arg name="bootstrap" value="./vendor/mediawiki/mediawiki-codesniffer/utils/bootstrap-ci.php"/>
<arg name="extensions" value="php"/>
<arg name="encoding" value="UTF-8"/>
</ruleset> </ruleset>

View file

@ -11,7 +11,8 @@
}, },
"scripts": { "scripts": {
"fix": [ "fix": [
"minus-x fix ." "minus-x fix .",
"phpcbf; if [ $? -eq 1 ]; then exit 0; fi"
], ],
"test": [ "test": [
"parallel-lint . --exclude node_modules --exclude vendor", "parallel-lint . --exclude node_modules --exclude vendor",

View file

@ -1,8 +0,0 @@
# Force phpcbf to exit with zero
# See https://github.com/squizlabs/PHP_CodeSniffer/issues/1818#issuecomment-354420927
root=$( dirname $0 )
$root/vendor/bin/phpcbf
exit 0