forked from elementor/elementor
-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (134 loc) · 4.62 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
130
131
132
133
134
135
136
137
138
139
name: Lint
on:
pull_request:
merge_group:
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
file-diff:
runs-on: ubuntu-22.04
name: Lint - File Diff
if: startsWith( github.repository, 'elementor/' )
outputs:
js_diff: ${{ steps.js_diff_files.outputs.diff }}
php_diff: ${{ steps.php_diff_files.outputs.diff }}
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Check JS files diff
id: js_diff_files
uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
**/*.+(js|ts|json|jsx|tsx)
package*.json
.github/**/*.yml
- name: Check PHP files diff
id: php_diff_files
uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
**/*.php
ruleset.xml
.github/**/*.yml
composer.+(json|lock)
JS-Lint:
runs-on: ubuntu-22.04
needs: [ 'file-diff' ]
if: ${{ needs.file-diff.outputs.js_diff || github.event.pull_request.title == null }}
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Install Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
run: npm ci
- name: Run Lint
run: ./node_modules/eslint/bin/eslint.js .
PHP-Lint:
runs-on: ubuntu-22.04
needs: [ 'file-diff' ]
if: ${{ needs.file-diff.outputs.php_diff || github.event.pull_request.title == null }}
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Setup PHP 7.4
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- name: Install Dependencies
run: |
composer install
composer require php-parallel-lint/php-parallel-lint
- name: Run Lint
run: |
vendor/bin/phpcs -p -s -n . --standard=./ruleset.xml --extensions=php
- name: Setup PHP 7.1 # not included in ubuntu 22.04
uses: shivammathur/setup-php@v2
with:
php-version: '7.1'
- name: Run PHP Syntax Lint 7.1
run: |
export PATH=$HOME/.composer/vendor/bin:$PATH
php -v
php vendor/bin/parallel-lint --blame --exclude node_modules --exclude vendor .
- name: Setup PHP 7.2 # not included in ubuntu 22.04
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
- name: Run PHP Syntax Lint 7.2
run: |
export PATH=$HOME/.composer/vendor/bin:$PATH
php -v
php vendor/bin/parallel-lint --blame --exclude node_modules --exclude vendor .
- name: Setup PHP 7.3 # not included in ubuntu 22.04
uses: shivammathur/setup-php@v2
with:
php-version: '7.3'
- name: Run PHP Syntax Lint 7.3
run: |
export PATH=$HOME/.composer/vendor/bin:$PATH
php -v
php vendor/bin/parallel-lint --blame --exclude node_modules --exclude vendor .
- name: Setup PHP 7.4 # not included in ubuntu 22.04
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- name: Run PHP Syntax Lint 7.4
run: |
export PATH=$HOME/.composer/vendor/bin:$PATH
php -v
php vendor/bin/parallel-lint --blame --exclude node_modules --exclude vendor .
- name: Setup PHP 8.0 # not included in ubuntu 22.04
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
- name: Run PHP Syntax Lint 8.0
run: |
export PATH=$HOME/.composer/vendor/bin:$PATH
php -v
php vendor/bin/parallel-lint --blame --exclude node_modules --exclude vendor .
- name: Setup PHP 8.1 # not included in ubuntu 22.04
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
- name: Run PHP Syntax Lint 8.1
run: |
export PATH=$HOME/.composer/vendor/bin:$PATH
php -v
php vendor/bin/parallel-lint --blame --exclude node_modules --exclude vendor .