diff --git a/.github/workflows/mediawiki-linting.yml b/.github/workflows/mediawiki-linting.yml deleted file mode 100644 index 7df7288..0000000 --- a/.github/workflows/mediawiki-linting.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/mediawiki-tests.yml b/.github/workflows/mediawiki-tests.yml index 8234036..277d953 100644 --- a/.github/workflows/mediawiki-tests.yml +++ b/.github/workflows/mediawiki-tests.yml @@ -52,7 +52,7 @@ jobs: - mw: 'master' php: 7.3 php-docker: 73 - experimental: true + experimental: false stage: coverage # Latest stable MediaWiki - PHP 7.3 (phpunit-unit) @@ -73,7 +73,7 @@ jobs: - mw: 'master' php: 7.3 php-docker: 73 - experimental: true + experimental: false stage: phpunit-unit # Latest MediaWiki master - PHP 7.4 (phpunit-unit) @@ -111,34 +111,6 @@ jobs: experimental: true 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) - mw: 'REL1_37' php: 7.3 @@ -150,7 +122,7 @@ jobs: - mw: 'master' php: 7.3 php-docker: 73 - experimental: true + experimental: false stage: selenium # Latest stable MediaWiki - PHP 7.3 (qunit) @@ -164,7 +136,7 @@ jobs: - mw: 'master' php: 7.3 php-docker: 73 - experimental: true + experimental: false stage: qunit # Latest stable MediaWiki - PHP 7.3 (npm-test) @@ -173,14 +145,7 @@ jobs: php-docker: 73 experimental: false 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) - mw: 'REL1_37' php: 7.3 @@ -188,13 +153,6 @@ jobs: experimental: false 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 env: @@ -205,13 +163,19 @@ jobs: PHAN_DOCKER_IMAGE: mediawiki-phan-php${{ matrix.php-docker }} steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 # /home/runner/cache/ Cache # /home/runner/src/ Mediawiki installation # /home/runner/src/extensions/EXTENSION_NAME/ Clone of the extension repository # /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 run: | echo MEDIAWIKI_VERSION="${{ matrix.mw }}" >> $GITHUB_ENV @@ -276,10 +240,20 @@ jobs: for dep in $DEPENDENCIES; do dependency=$(echo $dep | cut -d'|' -f1) repository=$(echo $dep | cut -sd'|' -f2) - branch=$(echo $dep | cut -sd'|' -f3) - git clone --recurse-submodules -b "${branch:-${MEDIAWIKI_VERSION}}" --depth 1 "${repository:-https://gerrit.wikimedia.org/r/${dep}}" src/"$(echo $dependency | cut -d'/' -f2,3)" + branch=$(echo $dep | rev | cut -sd'|' -f1 | rev) + + 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 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" - name: Cache dependencies (composer and npm) @@ -302,6 +276,28 @@ jobs: composer install --prefer-dist --no-progress --no-interaction 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 continue-on-error: ${{ matrix.experimental }} run: | diff --git a/.phpcs.xml b/.phpcs.xml index ece3bb6..48159c9 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -1,15 +1,12 @@ - . - - - - */vendor/* - */out/* */tests/* + + + diff --git a/composer.json b/composer.json index 2c5dedc..b40393d 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ }, "scripts": { "fix": [ - "minus-x fix ." + "minus-x fix .", + "phpcbf; if [ $? -eq 1 ]; then exit 0; fi" ], "test": [ "parallel-lint . --exclude node_modules --exclude vendor", diff --git a/phpcbf.sh b/phpcbf.sh deleted file mode 100644 index 289e6cf..0000000 --- a/phpcbf.sh +++ /dev/null @@ -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