-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor lint workflow and add release-please
- Loading branch information
1 parent
476af13
commit 251c9b9
Showing
2 changed files
with
137 additions
and
119 deletions.
There are no files selected for viewing
238 changes: 119 additions & 119 deletions
238
.github/workflows/mediawiki.yml → .github/workflows/lint.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,119 +1,119 @@ | ||
name: MediaWiki CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
test: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php-versions: ['8.2', '8.1', '8.0', '7.4'] | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- 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 | ||
uses: tj-actions/changed-files@v44 | ||
with: | ||
since_last_remote_commit: "true" | ||
files: | | ||
includes/**/*.php | ||
- name: Check for script changes | ||
id: changed-script | ||
uses: tj-actions/changed-files@v44 | ||
with: | ||
since_last_remote_commit: "true" | ||
files: | | ||
modules/**/*.js | ||
- name: Check for stylesheet changes | ||
id: changed-stylesheet | ||
uses: tj-actions/changed-files@v44 | ||
with: | ||
since_last_remote_commit: "true" | ||
files: | | ||
modules/**/*.css | ||
modules/**/*.less | ||
- name: Check for i18n changes | ||
id: changed-i18n | ||
uses: tj-actions/changed-files@v44 | ||
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 "[email protected]" | ||
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 | ||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
test: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php-versions: ['8.2', '8.1', '8.0', '7.4'] | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- 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 | ||
uses: tj-actions/changed-files@v44 | ||
with: | ||
since_last_remote_commit: "true" | ||
files: | | ||
includes/**/*.php | ||
- name: Check for script changes | ||
id: changed-script | ||
uses: tj-actions/changed-files@v44 | ||
with: | ||
since_last_remote_commit: "true" | ||
files: | | ||
resources/**/*.js | ||
- name: Check for stylesheet changes | ||
id: changed-stylesheet | ||
uses: tj-actions/changed-files@v44 | ||
with: | ||
since_last_remote_commit: "true" | ||
files: | | ||
resources/**/*.css | ||
resources/**/*.less | ||
- name: Check for i18n changes | ||
id: changed-i18n | ||
uses: tj-actions/changed-files@v44 | ||
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 "[email protected]" | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
name: release-please | ||
|
||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: googleapis/release-please-action@v4 | ||
with: | ||
token: ${{ secrets.WORKFLOW_TOKEN }} |