2024-05-25 22:37:43 +00:00
|
|
|
name: Lint
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2024-09-04 20:14:55 +00:00
|
|
|
- "**"
|
|
|
|
- "!**dependabot/**"
|
|
|
|
- "!**release-please--**"
|
2024-05-25 22:37:43 +00:00
|
|
|
pull_request:
|
|
|
|
branches:
|
2024-09-04 20:14:55 +00:00
|
|
|
- "**"
|
|
|
|
- "!**dependabot/**"
|
|
|
|
- "!**release-please--**"
|
|
|
|
|
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
2024-05-25 22:37:43 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
test:
|
|
|
|
name: Lint
|
|
|
|
runs-on: ubuntu-latest
|
2024-09-04 20:14:55 +00:00
|
|
|
steps:
|
2024-05-25 22:37:43 +00:00
|
|
|
- uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
|
|
|
|
|
|
|
|
- name: Cache dependencies
|
|
|
|
uses: actions/cache@v4
|
|
|
|
with:
|
|
|
|
path: /home/runner/cache
|
|
|
|
key: ${{ runner.os }}-${{ hashFiles('**/*.lock') }}
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
composer validate
|
|
|
|
composer install --prefer-dist --no-progress
|
|
|
|
npm install --save-dev
|
|
|
|
|
|
|
|
# Check for changed files
|
|
|
|
- name: Check for PHP changes
|
|
|
|
id: changed-php
|
2024-08-31 23:49:58 +00:00
|
|
|
uses: tj-actions/changed-files@v45
|
2024-05-25 22:37:43 +00:00
|
|
|
with:
|
|
|
|
since_last_remote_commit: "true"
|
|
|
|
files: |
|
|
|
|
includes/**/*.php
|
|
|
|
|
|
|
|
- name: Check for script changes
|
|
|
|
id: changed-script
|
2024-08-31 23:49:58 +00:00
|
|
|
uses: tj-actions/changed-files@v45
|
2024-05-25 22:37:43 +00:00
|
|
|
with:
|
|
|
|
since_last_remote_commit: "true"
|
|
|
|
files: |
|
|
|
|
resources/**/*.js
|
|
|
|
|
|
|
|
- name: Check for stylesheet changes
|
|
|
|
id: changed-stylesheet
|
2024-08-31 23:49:58 +00:00
|
|
|
uses: tj-actions/changed-files@v45
|
2024-05-25 22:37:43 +00:00
|
|
|
with:
|
|
|
|
since_last_remote_commit: "true"
|
|
|
|
files: |
|
|
|
|
resources/**/*.css
|
|
|
|
resources/**/*.less
|
|
|
|
|
|
|
|
- name: Check for i18n changes
|
|
|
|
id: changed-i18n
|
2024-08-31 23:49:58 +00:00
|
|
|
uses: tj-actions/changed-files@v45
|
2024-05-25 22:37:43 +00:00
|
|
|
with:
|
|
|
|
since_last_remote_commit: "true"
|
|
|
|
files: |
|
|
|
|
i18n/*.json
|
|
|
|
|
|
|
|
# Bypass the phpcbf non-standard exit code
|
|
|
|
- name: Lint PHP
|
|
|
|
if: steps.changed-php.outputs.any_changed == 'true'
|
|
|
|
continue-on-error: true
|
|
|
|
run: |
|
|
|
|
sh ./bin/phpcbf.sh
|
|
|
|
composer fix
|
|
|
|
composer test
|
|
|
|
|
|
|
|
- name: Lint script
|
|
|
|
if: steps.changed-script.outputs.any_changed == 'true'
|
|
|
|
continue-on-error: true
|
|
|
|
run: |
|
|
|
|
npm run lint:fix:js
|
|
|
|
npm run lint:js
|
|
|
|
|
|
|
|
- name: Lint stylesheet
|
|
|
|
if: steps.changed-stylesheet.outputs.any_changed == 'true'
|
|
|
|
continue-on-error: true
|
|
|
|
run: |
|
|
|
|
npm run lint:fix:styles
|
|
|
|
npm run lint:styles
|
|
|
|
|
|
|
|
- name: Lint i18n
|
|
|
|
if: steps.changed-i18n.outputs.any_changed == 'true'
|
|
|
|
continue-on-error: true
|
|
|
|
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: |
|
|
|
|
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 .
|
|
|
|
git commit -am "ci: 👷 lint code to MediaWiki standards" -m "Check commit and GitHub actions for more details"
|
|
|
|
git pull --rebase
|
|
|
|
git push
|
|
|
|
else
|
|
|
|
echo "No changes to commit"
|
|
|
|
fi
|