forked from keeweb/keeweb
-
Notifications
You must be signed in to change notification settings - Fork 0
349 lines (285 loc) · 10.6 KB
/
build-tests.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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# #
# @type github workflow
# @desc run linter and build tests on repository
# @author Aetherinox
# @project KeeWeb
# @repo https://github.com/keeweb/keeweb
# #
name: '🔨 Build › Tests'
run-name: '🔨 Deploy › Tests'
# #
# Triggers
# #
on:
# #
# Trigger › Workflow Dispatch
#
# If any values are not provided, will use fallback env variable
# #
workflow_dispatch:
inputs:
# #
# Name of the plugin to use when creating the release zip / exe filename
# e.g: keeweb-v1.0.0.zip
# #
PLUGIN_NAME:
description: "📦 Name of App"
required: true
default: 'keeweb'
type: string
# #
# Trigger › Push
# #
push:
branches:
- 'main'
- 'master'
- 'develop/v?[0-9]+.[0-9]+.[0-9]+'
- 'v?[0-9]+.[0-9]+.[0-9]+'
- '!all-contributors/**'
# #
# Trigger › Pull Requests
# #
pull_request:
# #
# Environment Vars
#
# PLUGIN_NAME This is the project name used in Cloudflare.
# #
env:
PLUGIN_NAME: ${{ github.event.inputs.PLUGIN_NAME || 'keeweb' }}
BOT_NAME_1: EuropaServ
BOT_NAME_DEPENDABOT: dependabot[bot]
# #
# Jobs
# #
jobs:
# #
# Jobs › Initialize
# #
job-initialize:
name: >-
💡 Initialize
runs-on: ubuntu-latest
outputs:
package_version: ${{ steps.task_init_pkg_ver_get.outputs.PACKAGE_VERSION }}
guid: ${{ steps.task_init_dotenv_get.outputs.GUID }}
uuid: ${{ steps.task_init_dotenv_get.outputs.UUID }}
permissions:
contents: write
packages: write
steps:
# #
# Initialize › Start
# #
- name: '✅ Start'
id: task_init_start
run: |
echo "Starting linter"
# #
# Initialize › Checkout
# #
- name: '☑️ Checkout'
id: task_init_checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# #
# Initialize › Setup Node
# #
- name: '⚙️ Setup Node'
id: task_init_node_setup
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
# #
# Initialize › Node Clean Install
# #
- name: '🕛 NPM › Clean Install'
id: task_init_npm_install
run: |
npm ci
# #
# Initialize › Get Package Version
# #
- name: '👁️🗨️ Get Package Version'
id: task_init_pkg_ver_get
run: |
VER=$(cat package.json | jq -r '.version')
echo "PACKAGE_VERSION=$VER" >> $GITHUB_OUTPUT
- name: '👁️🗨️ Found KeeWeb v${{ steps.task_init_pkg_ver_get.outputs.PACKAGE_VERSION }}'
id: task_init_pkg_ver_print
run: |
echo Found KeeWeb ${{ steps.task_init_pkg_ver_get.outputs.PACKAGE_VERSION }}
# #
# Initialize › generate guid and uuid
# #
- name: '🪪 .ENV › Generate'
id: task_init_pkg_env_generate
continue-on-error: true
run: |
npm run keeweb:generate
# #
# Initialize › assign guid and uuid to env variable
# #
- name: '🪪 .ENV › Get'
id: task_init_dotenv_get
if: steps.task_init_pkg_env_generate.outcome == 'success'
uses: falti/dotenv-action@v1
# #
# Initialize › read back guid and uuid
# #
- name: '🪪 .ENV › Read'
id: task_init_dotenv_print
if: steps.task_init_pkg_env_generate.outcome == 'success'
run: |
echo "VER: ${{ steps.task_init_dotenv_get.outputs.VERSION }}"
echo "GUID: ${{ steps.task_init_dotenv_get.outputs.GUID }}"
echo "UUID: ${{ steps.task_init_dotenv_get.outputs.UUID }}"
# #
# Job › Lint
# #
job-lint:
name: >-
📚 Lint
runs-on: ubuntu-latest
needs: [job-initialize]
env:
PACKAGE_VERSION: ${{ needs.job-initialize.outputs.package_version }}
GUID: ${{ needs.job-initialize.outputs.guid }}
UUID: ${{ needs.job-initialize.outputs.uuid }}
outputs:
lint_success: ${{ steps.task_lint_npm_lint.outcome }}
steps:
# #
# Lint › Checkout
# #
- name: '☑️ Checkout'
id: task_lint_checkout
uses: actions/checkout@v4
# #
# Lint › Setup Node
# #
- name: '⚙️ Setup Node'
id: task_lint_node_setup
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
# #
# Lint › NPM Install
# #
- name: '🕛 NPM › Clean Install'
id: task_lint_npm_install
run: |
npm ci
# #
# Lint › Run
# #
- name: '🕞 NPM › Lint'
id: task_lint_npm_lint
run: |
npm run lint
# #
# Job › Test
# #
job-test:
name: >-
🧪 Tests
runs-on: ubuntu-latest
needs: [job-initialize]
env:
PACKAGE_VERSION: ${{ needs.job-initialize.outputs.package_version }}
outputs:
test_success: ${{ steps.task_test_npm_test.outcome }}
steps:
# #
# Test › Fix Line Endings
# #
- name: '🛒 Fix Git Checkout Line Endings'
id: task_test_git_fixlines
run: |
git config --global core.autocrlf input
# #
# Test › Checkout
# #
- name: '☑️ Checkout'
id: task_test_checkout
uses: actions/checkout@v4
# #
# Test › Setup Node
# #
- name: '⚙️ Setup Node'
id: task_test_node_setup
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
# #
# Test › NPM Install
# #
- name: '🕛 NPM › Clean Install'
id: task_test_npm_install
run: |
npm ci
# #
# Test › Run
# #
- name: '🕘 NPM › Test'
id: task_test_npm_test
run: |
npm run test
# #
# Job › Complete
# #
job-complete-run:
name: >-
✅ Complete
runs-on: ubuntu-latest
needs: [job-initialize, job-lint, job-test]
env:
PACKAGE_VERSION: ${{ needs.job-initialize.outputs.package_version }}
TEST_SUCCESS: ${{ needs.job-test.outputs.test_success }}
LINT_SUCCESS: ${{ needs.job-lint.outputs.lint_success }}
GUID: ${{ needs.job-initialize.outputs.guid }}
UUID: ${{ needs.job-initialize.outputs.uuid }}
steps:
# #
# Complete › Get publish timestamp
# #
- name: '🕛 Get Timestamp'
id: task_tests_complete_timestamp
run: |
echo "NOW=$(date +'%m-%d-%Y %H:%M:%S')" >> $GITHUB_ENV
# #
# Complete › Debug Print
# #
- name: "🔖 Output"
run: |
echo "LINT_SUCCESS: ${{ env.LINT_SUCCESS }}"
echo "TEST_SUCCESS: ${{ env.TEST_SUCCESS }}"
# #
# Complete › Summary of publish
# #
- name: '🆗 Summary: ${{ env.NOW }} - ${{ env.PACKAGE_VERSION }}'
id: task_tests_complete_summary
shell: bash
run: |
echo ""
echo ""
echo "| File | Result |" >> $GITHUB_STEP_SUMMARY
echo "| ------------------------------- | ----------------------- |" >> $GITHUB_STEP_SUMMARY
echo "| **Project** | ${{ env.PLUGIN_NAME || github.event.inputs.PLUGIN_NAME }} |" >> $GITHUB_STEP_SUMMARY
echo "| **Deploy Time** | ${{ env.NOW }} |" >> $GITHUB_STEP_SUMMARY
echo "| **GUID** | ${{ env.GUID }} |" >> $GITHUB_STEP_SUMMARY
echo "| **UUID** | ${{ env.UUID }} |" >> $GITHUB_STEP_SUMMARY
if [ ${{ env.LINT_SUCCESS }} == 'true' ] || [ ${{ env.LINT_SUCCESS }} == 'success' ]; then
echo "| **Lint Results** | ✔️ |" >> $GITHUB_STEP_SUMMARY
else
echo "| **Lint Results** | ❌ |" >> $GITHUB_STEP_SUMMARY
fi
if [ ${{ env.TEST_SUCCESS }} == 'true' ] || [ ${{ env.TEST_SUCCESS }} == 'success' ]; then
echo "| **Test Results** | ✔️ |" >> $GITHUB_STEP_SUMMARY
else
echo "| **Test Results** | ❌ |" >> $GITHUB_STEP_SUMMARY
fi