forked from StarCitizenTools/mediawiki-skins-Citizen
-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (114 loc) · 3.6 KB
/
lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Lint
on:
push:
branches-ignore:
- 'release-please/**'
pull_request:
branches-ignore:
- 'release-please/**'
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
skinStyles/**/*.css
skinStyles/**/*.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
- name: Trigger PHP tests
if: steps.changed-php.outputs.any_changed == 'true'
run: |
curl -X POST -H "Authorization: token ${{ secrets.WORKFLOW_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/StarCitizenTools/mediawiki-skins-Citizen/actions/workflows/php-tests.yaml/dispatches \
-d '{"ref":"main"}'
# 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