10
10
- ' *'
11
11
12
12
jobs :
13
- config :
14
- name : Configure
15
- runs-on : ubuntu-latest
16
- outputs :
17
- config : ${{ steps.set-config.outputs.config }}
18
- steps :
19
- - name : Checkout repository
20
- uses : actions/checkout@v2
21
-
22
- - name : Setup Node.js
23
- uses : actions/setup-node@v2
24
-
25
- - name : Create config
26
- id : set-config
27
- run : |
28
- echo Node: $(node -v)
29
- echo NPM: $(npm -v)
30
- npm i semver
31
- CONFIG=$(node ./.github/scripts/config.js | sed 's/ //g')
32
- echo "::set-output name=config::$CONFIG"
33
- echo $CONFIG
34
-
35
13
test :
36
14
name : Test
37
- needs : [ config ]
38
- strategy :
39
- matrix : ${{ fromJson(needs.config.outputs.config).node.matrix }}
40
- runs-on : ${{ matrix.os }}
15
+ runs-on : ubuntu-latest
16
+ env :
17
+ NODE_VERSION : 16
41
18
steps :
42
19
- name : Checkout repository
43
- uses : actions/checkout@v2
20
+ uses : actions/checkout@v3
44
21
45
- - name : Setup Node.js v${{ matrix.node }}
46
- uses : actions/setup-node@v2
47
- with :
48
- node-version : ${{ matrix.node }}
49
-
50
- - name : Cache node modules
51
- id : cache-npm
52
- uses : actions/cache@v2
22
+ - name : Setup Node.js v${{ env.NODE_VERSION }}
23
+ uses : actions/setup-node@v3
53
24
with :
54
- path : ~/.npm
55
- key : npm-${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
25
+ node-version : ${{ env.NODE_VERSION }}
56
26
57
27
- name : Install Dependencies
58
28
run : npm ci
@@ -65,34 +35,26 @@ jobs:
65
35
npm run test
66
36
67
37
- name : Cache coverage
68
- if : ${{ success() && matrix.node == '16.x' }}
69
- uses : actions/cache@v2
38
+ uses : actions/cache@v3
70
39
with :
71
40
path : coverage
72
- key : coverage-${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('src/**/*.*', '**/package-lock.json') }}
41
+ key : coverage-${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('src/**/*.*', '**/package-lock.json') }}
73
42
74
43
build :
75
44
name : Build
76
- needs : [ test, config ]
45
+ needs : [ test ]
46
+ runs-on : ubuntu-latest
77
47
env :
78
- NODE_VERSION : ${{ fromJson(needs.config.outputs.config).node.main.version }}
79
- runs-on : ${{ fromJson(needs.config.outputs.config).node.main.os }}
48
+ NODE_VERSION : 16
80
49
steps :
81
50
- name : Checkout repository
82
- uses : actions/checkout@v2
51
+ uses : actions/checkout@v3
83
52
84
53
- name : Use Node.js ${{ env.NODE_VERSION }}
85
- uses : actions/setup-node@v2
54
+ uses : actions/setup-node@v3
86
55
with :
87
56
node-version : ${{ env.NODE_VERSION }}
88
57
89
- - name : Cache node modules
90
- id : cache-npm
91
- uses : actions/cache@v2
92
- with :
93
- path : ~/.npm
94
- key : npm-${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
95
-
96
58
- name : Install Dependencies
97
59
run : npm ci
98
60
env :
@@ -104,35 +66,27 @@ jobs:
104
66
coverage :
105
67
name : Coverage
106
68
if : ${{ github.event_name == 'push' }}
107
- needs : [ build, config ]
69
+ needs : [ build ]
70
+ runs-on : ubuntu-latest
108
71
env :
109
- NODE_VERSION : ${{ fromJson(needs.config.outputs.config).node.main.version }}
110
- runs-on : ${{ fromJson(needs.config.outputs.config).node.main.os }}
72
+ NODE_VERSION : 16
111
73
steps :
112
74
- name : Checkout repository
113
- uses : actions/checkout@v2
75
+ uses : actions/checkout@v3
114
76
115
77
- name : Cache coverage
116
78
id : cache-coverage
117
- uses : actions/cache@v2
79
+ uses : actions/cache@v3
118
80
with :
119
81
path : coverage
120
82
key : coverage-${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('src/**/*.*', '**/package-lock.json') }}
121
83
122
84
- name : Setup Node.js v${{ env.NODE_VERSION }}
123
85
if : steps.cache-coverage.outputs.cache-hit != 'true'
124
- uses : actions/setup-node@v2
86
+ uses : actions/setup-node@v3
125
87
with :
126
88
node-version : ${{ env.NODE_VERSION }}
127
89
128
- - name : Cache node modules
129
- if : steps.cache-coverage.outputs.cache-hit != 'true'
130
- id : cache-npm
131
- uses : actions/cache@v2
132
- with :
133
- path : ~/.npm
134
- key : npm-${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
135
-
136
90
- name : Test
137
91
if : steps.cache-coverage.outputs.cache-hit != 'true'
138
92
run : |
142
96
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
143
97
144
98
- name : Send coverage report
145
- uses : codecov/codecov-action@v1
99
+ uses : codecov/codecov-action@v3
146
100
with :
147
101
file : ./coverage/lcov.info
148
102
@@ -159,77 +113,10 @@ jobs:
159
113
USER : admin:${{ secrets.GITHUB_TOKEN }}
160
114
FILTER : " [.jobs[] | select(.status==\" completed\" and .conclusion==\" failure\" ) | { status: .conclusion, matrix: .name}] | length"
161
115
run : |
162
- failure_count =$(curl -X GET -s -u $USER $URL | jq "$FILTER")
163
- echo "::set-output name=failure_count::$failure_count"
164
- echo Failure jobs count: $failure_count
116
+ FAILURE_COUNT =$(curl -X GET -s -u $USER $URL | jq "$FILTER")
117
+ echo "fails=$FAILURE_COUNT" >> $GITHUB_OUTPUT
118
+ echo Failure jobs count: $FAILURE_COUNT
165
119
166
- - if : ${{ steps.status.outputs.failure_count > 0 }}
120
+ - if : ${{ steps.status.outputs.fails > 0 }}
167
121
name : Fail
168
122
run : exit 1
169
-
170
- discord :
171
- name : Discord notification
172
- needs : [ status ]
173
- if : ${{ always() }}
174
- runs-on : ubuntu-latest
175
- env :
176
- DISCORD_USERNAME : github
177
- DISCORD_ERROR_COLOR : 16726645
178
- DISCORD_ERROR_AVATAR : https://cdn.jsdelivr.net/gh/tagproject/art/bot/bot-error.png
179
- DISCORD_EVENT_COLOR : 53759
180
- DISCORD_EVENT_AVATAR : https://cdn.jsdelivr.net/gh/tagproject/art/bot/bot-event.png
181
- steps :
182
- - name : Send error notification after push commit
183
- if : ${{ contains(needs.*.result, 'failure') && github.event_name == 'push' }}
184
- uses : sarisia/actions-status-discord@v1
185
- with :
186
- webhook : ${{ secrets.DISCORD_WEBHOOK }}
187
- nodetail : true
188
- username : ${{ env.DISCORD_USERNAME }}
189
- avatar_url : ${{ env.DISCORD_ERROR_AVATAR }}
190
- title : ' Build failed :confused:'
191
- color : ${{ env.DISCORD_ERROR_COLOR }}
192
- description : |
193
- **Repository:** `${{ github.repository }}`
194
- **Branch:** `${{ github.event.ref }}`
195
- **Author:** [${{ github.event.head_commit.author.username }}](https://github.com/${{ github.event.head_commit.author.username }})
196
- **Commit:** [${{ github.event.head_commit.id }}](${{ github.event.head_commit.url }})
197
- **Message:**
198
- `${{ github.event.head_commit.message }}`
199
-
200
- - name : Send error notification for pull_request
201
- if : ${{ contains(needs.*.result, 'failure') && github.event_name == 'pull_request' }}
202
- uses : sarisia/actions-status-discord@v1
203
- with :
204
- webhook : ${{ secrets.DISCORD_WEBHOOK }}
205
- nodetail : true
206
- username : ${{ env.DISCORD_USERNAME }}
207
- avatar_url : ${{ env.DISCORD_ERROR_AVATAR }}
208
- title : ' Pull request build failed :confused:'
209
- color : ${{ env.DISCORD_ERROR_COLOR }}
210
- description : |
211
- **Repository:** `${{ github.repository }}`
212
- **Merge:** into `${{ github.event.pull_request.base.ref }}` from `${{ github.event.pull_request.head.ref }}`
213
- **Title:** ${{ github.event.pull_request.title }} [#${{ github.event.pull_request.number }}](${{github.event.pull_request._links.html.href}})
214
- **Assignees:** `${{ join(github.event.pull_request.assignees.*.login, ', ') }}`
215
- **Labels:** `${{ join(github.event.pull_request.labels.*.name, ', ') }}`
216
-
217
- - name : Send success notification for pull_request
218
- if : ${{ !contains(needs.*.result, 'failure') && github.event_name == 'pull_request' }}
219
- uses : sarisia/actions-status-discord@v1
220
- with :
221
- webhook : ${{ secrets.DISCORD_WEBHOOK }}
222
- nodetail : true
223
- username : ${{ env.DISCORD_USERNAME }}
224
- avatar_url : ${{ env.DISCORD_EVENT_AVATAR }}
225
- title : ' Pull request successfully build :face_with_monocle:'
226
- color : ${{ env.DISCORD_EVENT_COLOR }}
227
- description : |
228
- **Repository:** `${{ github.repository }}`
229
- **Merge:** into `${{ github.event.pull_request.base.ref }}` from `${{ github.event.pull_request.head.ref }}`
230
- **Title:** ${{ github.event.pull_request.title }} [#${{ github.event.pull_request.number }}](${{github.event.pull_request._links.html.href}})
231
- **Assignees:** `${{ join(github.event.pull_request.assignees.*.login, ', ') }}`
232
- **Labels:** `${{ join(github.event.pull_request.labels.*.name, ', ') }}`
233
-
234
-
235
-
0 commit comments