forked from elementor/elementor
-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (107 loc) · 3.57 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
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@v4
- 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@v4
- name: Install Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Cache node modules
uses: actions/cache@v4
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@v4
- 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.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 .