-
Notifications
You must be signed in to change notification settings - Fork 21
260 lines (221 loc) · 6.7 KB
/
ci.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
name: GenerateBlocks CI
on:
workflow_dispatch:
inputs:
name:
description: 'Package name'
default: 'generateblocks'
required: true
build-package:
type: boolean
default: false
description: Build the zip package
push:
branches:
- master
pull_request:
branches:
- master
- release/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
js-lint:
name: JS Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check changed files
id: 'js-files'
uses: tj-actions/[email protected]
with:
files: |
**/*.js
**/*.json
- name: Setup node
if: steps.js-files.outputs.any_changed == 'true'
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- name: Download deps
if: steps.js-files.outputs.any_changed == 'true'
uses: bahmutov/npm-install@v1
- name: Lint
if: steps.js-files.outputs.any_changed == 'true'
run: npm run lint:js
js-tests:
name: JS Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check changed files
id: 'js-files'
uses: tj-actions/[email protected]
with:
files: |
**/*.js
**/*.json
- name: Setup node
if: steps.js-files.outputs.any_changed == 'true'
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- name: Download deps
if: steps.js-files.outputs.any_changed == 'true'
uses: bahmutov/npm-install@v1
- name: Run tests
if: steps.js-files.outputs.any_changed == 'true'
run: npm run test:unit
js-commit-dist:
name: Commit dist files
runs-on: ubuntu-latest
needs: [js-lint, js-tests]
if: ${{ 'master' == github.ref_name || startsWith(github.ref_name, 'release/') || startsWith(github.head_ref, 'release/') }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check changed files
id: 'js-files'
uses: tj-actions/[email protected]
with:
files: |
**/*.js
**/*.json
- name: Setup node
if: steps.js-files.outputs.any_changed == 'true'
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- name: Download deps
if: steps.js-files.outputs.any_changed == 'true'
uses: bahmutov/npm-install@v1
- name: Build files
if: steps.js-files.outputs.any_changed == 'true'
run: npm run build
- name: Commit files
if: steps.js-files.outputs.any_changed == 'true'
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: 'Update dist files'
add: 'dist/'
push: origin HEAD:${{ github.head_ref }}
php-lint:
name: PHP Lint
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.2', '7.4', '8.1']
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check changed files
id: 'php-files'
uses: tj-actions/[email protected]
with:
files: |
**/*.php
- name: Setup PHP
if: steps.php-files.outputs.any_changed == 'true'
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Download deps
if: steps.php-files.outputs.any_changed == 'true'
uses: ramsey/composer-install@v2
- name: Lint
if: steps.php-files.outputs.any_changed == 'true'
run: composer run-script lint
php-tests:
name: PHP Tests
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.2']
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check changed files
id: 'php-files'
uses: tj-actions/[email protected]
with:
files: |
**/*.php
- name: Setup PHP
if: steps.php-files.outputs.any_changed == 'true'
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Download deps
if: steps.php-files.outputs.any_changed == 'true'
uses: ramsey/composer-install@v2
- name: Test
if: steps.php-files.outputs.any_changed == 'true'
run: composer run-script test
build-package:
name: Build package
runs-on: ubuntu-latest
needs: [js-lint, js-tests, php-lint, php-tests]
if: github.event.inputs.build-package == 'true'
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 14
- name: Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false
- name: Build files
run: npm run build
- name: Grunt action-package
run: npm run action-package
- name: Build zip package
uses: actions/[email protected]
with:
name: ${{ github.event.inputs.name }}
path: |
package/
retention-days: 1
check-version:
name: Check versions
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && startsWith(github.event.pull_request.title, 'Release:') }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Check readme.txt
if: ${{ !contains(github.event.pull_request.title, '-alpha') && !contains(github.event.pull_request.title, '-beta') && !contains(github.event.pull_request.title, '-rc') }}
run: 'cat readme.txt | grep -w "Stable tag: ${PR_TITLE:9}"'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
- name: Check package.json
run: 'cat package.json | grep -w "\"version\": \"${PR_TITLE:9}\","'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
- name: Check plugin header
run: 'cat plugin.php | grep -w " * Version: ${PR_TITLE:9}"'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
- name: Check PHP constant
run: "cat plugin.php | grep -w \"define( 'GENERATEBLOCKS_VERSION', '${PR_TITLE:9}' );\""
env:
PR_TITLE: ${{ github.event.pull_request.title }}