2020-06-17 02:49:41 +00:00
|
|
|
name: MediaWiki CI
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- '**'
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- '**'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
test:
|
2022-04-30 20:58:36 +00:00
|
|
|
name: Lint
|
2020-06-17 02:49:41 +00:00
|
|
|
runs-on: ubuntu-latest
|
2021-01-06 00:24:52 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-01-21 23:18:57 +00:00
|
|
|
php-versions: ['8.2', '8.1', '8.0', '7.4']
|
2020-06-17 02:49:41 +00:00
|
|
|
steps:
|
2022-04-30 20:58:36 +00:00
|
|
|
- name: Cancel Previous Runs
|
2022-10-19 21:08:41 +00:00
|
|
|
uses: styfle/cancel-workflow-action@0.11.0
|
2022-04-30 20:58:36 +00:00
|
|
|
with:
|
|
|
|
access_token: ${{ github.token }}
|
|
|
|
|
2022-03-05 23:02:50 +00:00
|
|
|
- uses: actions/checkout@v3
|
2022-04-30 20:58:36 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
|
|
|
|
|
|
|
|
- name: Cache dependencies
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: /home/runner/cache
|
|
|
|
key: ${{ runner.os }}-${{ hashFiles('**/*.lock') }}
|
|
|
|
|
2020-06-17 02:49:41 +00:00
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
composer validate
|
2021-01-06 00:40:58 +00:00
|
|
|
composer install --prefer-dist --no-progress
|
2022-04-30 20:58:36 +00:00
|
|
|
npm install --save-dev
|
|
|
|
|
|
|
|
# Check for changed files
|
|
|
|
- name: Check for PHP changes
|
|
|
|
id: changed-php
|
2022-12-20 21:44:59 +00:00
|
|
|
uses: tj-actions/changed-files@v35
|
2022-04-30 20:58:36 +00:00
|
|
|
with:
|
2022-04-30 22:09:27 +00:00
|
|
|
since_last_remote_commit: "true"
|
2022-04-30 20:58:36 +00:00
|
|
|
files: |
|
|
|
|
includes/**/*.php
|
|
|
|
|
|
|
|
- name: Check for script changes
|
|
|
|
id: changed-script
|
2022-12-20 21:44:59 +00:00
|
|
|
uses: tj-actions/changed-files@v35
|
2022-04-30 20:58:36 +00:00
|
|
|
with:
|
2022-04-30 22:09:27 +00:00
|
|
|
since_last_remote_commit: "true"
|
2022-04-30 20:58:36 +00:00
|
|
|
files: |
|
|
|
|
resources/**/*.js
|
|
|
|
|
|
|
|
- name: Check for stylesheet changes
|
|
|
|
id: changed-stylesheet
|
2022-12-20 21:44:59 +00:00
|
|
|
uses: tj-actions/changed-files@v35
|
2022-04-30 20:58:36 +00:00
|
|
|
with:
|
2022-04-30 22:09:27 +00:00
|
|
|
since_last_remote_commit: "true"
|
2022-04-30 20:58:36 +00:00
|
|
|
files: |
|
|
|
|
resources/**/*.css
|
|
|
|
resources/**/*.less
|
|
|
|
skinStyles/**/*.css
|
|
|
|
skinStyles/**/*.less
|
|
|
|
|
|
|
|
- name: Check for i18n changes
|
|
|
|
id: changed-i18n
|
2022-12-20 21:44:59 +00:00
|
|
|
uses: tj-actions/changed-files@v35
|
2022-04-30 20:58:36 +00:00
|
|
|
with:
|
2022-04-30 22:09:27 +00:00
|
|
|
since_last_remote_commit: "true"
|
2022-04-30 20:58:36 +00:00
|
|
|
files: |
|
|
|
|
i18n/*.json
|
2020-06-17 02:49:41 +00:00
|
|
|
|
|
|
|
# Bypass the phpcbf non-standard exit code
|
2022-04-30 20:58:36 +00:00
|
|
|
- name: Lint PHP
|
|
|
|
if: steps.changed-php.outputs.any_changed == 'true'
|
2022-04-27 21:05:35 +00:00
|
|
|
continue-on-error: true
|
2020-06-17 02:49:41 +00:00
|
|
|
run: |
|
|
|
|
sh ./bin/phpcbf.sh
|
|
|
|
composer fix
|
|
|
|
composer test
|
|
|
|
|
2022-04-30 20:58:36 +00:00
|
|
|
- name: Lint script
|
|
|
|
if: steps.changed-script.outputs.any_changed == 'true'
|
2022-04-27 21:05:35 +00:00
|
|
|
continue-on-error: true
|
2020-06-17 02:49:41 +00:00
|
|
|
run: |
|
|
|
|
npm run lint:fix:js
|
|
|
|
npm run lint:js
|
|
|
|
|
2022-04-30 20:58:36 +00:00
|
|
|
- name: Lint stylesheet
|
|
|
|
if: steps.changed-stylesheet.outputs.any_changed == 'true'
|
2022-04-27 21:05:35 +00:00
|
|
|
continue-on-error: true
|
2020-06-17 02:49:41 +00:00
|
|
|
run: |
|
|
|
|
npm run lint:fix:styles
|
|
|
|
npm run lint:styles
|
|
|
|
|
2022-04-30 20:58:36 +00:00
|
|
|
- name: Lint i18n
|
|
|
|
if: steps.changed-i18n.outputs.any_changed == 'true'
|
2022-04-27 21:05:35 +00:00
|
|
|
continue-on-error: true
|
2020-06-17 02:49:41 +00:00
|
|
|
run: |
|
|
|
|
npm run lint:i18n
|
|
|
|
|
|
|
|
# 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: |
|
2022-04-26 16:52:11 +00:00
|
|
|
if ! git diff --exit-code --quiet; then
|
|
|
|
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 .
|
2022-09-30 13:24:52 +00:00
|
|
|
git commit -am "ci: 👷 lint code to MediaWiki standards" -m "Check commit and GitHub actions for more details"
|
2022-04-27 21:05:35 +00:00
|
|
|
git pull --rebase
|
|
|
|
git push
|
2022-04-26 16:52:11 +00:00
|
|
|
else
|
|
|
|
echo "No changes to commit"
|
2022-04-30 20:58:36 +00:00
|
|
|
fi
|