-
-
Notifications
You must be signed in to change notification settings - Fork 36
402 lines (367 loc) · 16.1 KB
/
v5-tests-and-release.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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
name: "[v5] Test and Release"
on: [push, pull_request]
permissions: read-all
jobs:
check-v4-compatibility:
name: "Check v4 compatibility"
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Load this action from HEAD
uses: ./
- name: Load using v4
uses: rlespinasse/github-slug-action@v4
with:
prefix: V4_
- name: Validate // Partial variables
run: |
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART }}" ]]
shell: bash
- name: Validate // Slug variables
run: |
[[ "${{ env.GITHUB_REPOSITORY_SLUG }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG }}" ]]
[[ "${{ env.GITHUB_REF_SLUG }}" == "${{ env.V4_GITHUB_REF_SLUG }}" ]]
[[ "${{ env.GITHUB_HEAD_REF_SLUG }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG }}" ]]
[[ "${{ env.GITHUB_BASE_REF_SLUG }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG }}" ]]
[[ "${{ env.GITHUB_EVENT_REF_SLUG }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG }}" ]]
shell: bash
- name: Validate // Slug variables (Case Sensitive)
run: |
[[ "${{ env.GITHUB_REPOSITORY_SLUG_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_REF_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_HEAD_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_BASE_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_EVENT_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_CS }}" ]]
shell: bash
- name: Validate // Slug URL variables
run: |
[[ "${{ env.GITHUB_REPOSITORY_SLUG_URL }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_REF_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_HEAD_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_BASE_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_EVENT_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_URL }}" ]]
shell: bash
- name: Validate // Slug URL variables (Case Sensitive)
run: |
[[ "${{ env.GITHUB_REPOSITORY_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REF_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_HEAD_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_BASE_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_EVENT_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_URL_CS }}" ]]
shell: bash
- name: Validate // Ref Point
run: |
[[ "${{ env.GITHUB_REF_POINT }}" == "${{ env.V4_GITHUB_REF_NAME }}" ]]
[[ "${{ env.GITHUB_REF_POINT_SLUG }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG }}" ]]
[[ "${{ env.GITHUB_REF_POINT_SLUG_URL }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_REF_POINT_SLUG_CS }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_REF_POINT_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_URL_CS }}" ]]
shell: bash
- name: Validate // Short SHA variables
run: |
[[ "${{ env.GITHUB_SHA_SHORT }}" == "${{ env.V4_GITHUB_SHA_SHORT }}" ]]
[[ "${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" == "${{ env.V4_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" ]]
shell: bash
check-v4-compatibility-without-checkout:
name: "Check v4 compatibility (without checkout)"
needs:
- check-v4-compatibility
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: this-action
ref: ${{ github.ref }}
- name: Load this action from HEAD
uses: ./this-action
- name: Load using v4
uses: rlespinasse/github-slug-action@v4
with:
prefix: V4_
- name: Validate // Short SHA variables
run: |
[[ "${{ env.GITHUB_SHA_SHORT }}" == "${{ env.V4_GITHUB_SHA_SHORT }}" ]]
[[ "${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" == "${{ env.V4_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" ]]
shell: bash
display:
name: "Display produced variables"
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Load this action from HEAD
uses: ./
- name: Partial variables
run: |
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART }}"
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART }}"
shell: bash
- name: Slug variables
run: |
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG }}"
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}"
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}"
echo "ref : ${{ env.GITHUB_REF_SLUG }}"
echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG }}"
echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG }}"
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG }}"
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG }}"
shell: bash
- name: Slug variables (Case Sensitive)
run: |
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG_CS }}"
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}"
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}"
echo "ref : ${{ env.GITHUB_REF_SLUG_CS }}"
echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG_CS }}"
echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG_CS }}"
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_CS }}"
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_CS }}"
shell: bash
- name: Slug URL variables
run: |
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}"
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}"
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}"
echo "ref : ${{ env.GITHUB_REF_SLUG_URL }}"
echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG_URL }}"
echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL }}"
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL }}"
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL }}"
shell: bash
- name: Slug URL variables (Case Sensitive)
run: |
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL_CS }}"
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}"
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}"
echo "ref : ${{ env.GITHUB_REF_SLUG_URL_CS }}"
echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG_URL_CS }}"
echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL_CS }}"
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL_CS }}"
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL_CS }}"
shell: bash
- name: Ref Point
run: |
echo "raw : ${{ env.GITHUB_REF_POINT }}"
echo "slug : ${{ env.GITHUB_REF_POINT_SLUG }}"
echo "slug url : ${{ env.GITHUB_REF_POINT_SLUG_URL }}"
echo "slug (Case Sensitive) : ${{ env.GITHUB_REF_POINT_SLUG_CS }}"
echo "slug url (Case Sensitive) : ${{ env.GITHUB_REF_POINT_SLUG_URL_CS }}"
shell: bash
- name: Short SHA variables
run: |
echo "sha : ${{ env.GITHUB_SHA_SHORT }}"
echo "pull request sha : ${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}"
shell: bash
display-without-checkout:
name: "Display produced variables (without checkout)"
needs:
- display
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: this-action
ref: ${{ github.ref }}
- name: Load this action from HEAD
uses: ./this-action
- name: Short SHA variables
run: |
echo "sha : ${{ env.GITHUB_SHA_SHORT }}"
echo "pull request sha : ${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}"
shell: bash
input-short-length:
name: "Input 'short-length'"
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
# Test 1
- name: Using correct short length
uses: ./
with:
prefix: "CSL_"
short-length: 4
- name: Using correct length // Validate that all short variables lengths are equals to short-length
run: |
env | grep "CSL_" | grep "_SHORT" | cut -d"=" -f2 | while read -r value; do [ "${#value}" -le 5 ] ; done
shell: bash
# Test 2
- name: Using wrong short length
id: using-wrong-short-length
uses: ./
with:
prefix: "WSL_"
short-length: "wrong"
continue-on-error: true
- name: Using wrong short length // Validate that the action end with an error
run: |
[[ "$(env | grep "WSL_" | grep "_SHORT" -c)" -eq 0 ]]
[[ "${{ steps.using-wrong-short-length.outcome }}" == "failure" ]]
[[ "${{ steps.using-wrong-short-length.conclusion }}" == "success" ]]
shell: bash
input-short-length-without-checkout:
name: "Input 'short-length' (without checkout)"
needs:
- input-short-length
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: this-action
ref: ${{ github.ref }}
# Test 1
- name: Using correct short length
uses: ./this-action
with:
prefix: "CSL_"
short-length: 4
- name: Using correct length // Validate that all short variables lengths are equals to short-length
run: |
env | grep "CSL_" | grep "_SHORT" | cut -d"=" -f2 | while read -r value; do [ "${#value}" -le 5 ] ; done
shell: bash
# Test 2
- name: Using empty short length
id: using-empty-short-length
uses: ./this-action
with:
prefix: "ESL_"
continue-on-error: true
- name: Using empty short length // Validate that the action don't end with an error
run: |
[[ "$(env | grep "ESL_" | grep "_SHORT" -c)" -gt 0 ]]
[[ "${{ steps.using-empty-short-length.outcome }}" == "success" ]]
[[ "${{ steps.using-empty-short-length.conclusion }}" == "success" ]]
shell: bash
# Test 3
- name: Using wrong short length
id: using-wrong-short-length
uses: ./this-action
with:
prefix: "WSL_"
short-length: "wrong"
continue-on-error: true
- name: Using wrong short length // Validate that the action end with an error
run: |
[[ "$(env | grep "WSL_" | grep "_SHORT" -c)" -eq 0 ]]
[[ "${{ steps.using-wrong-short-length.outcome }}" == "failure" ]]
[[ "${{ steps.using-wrong-short-length.conclusion }}" == "success" ]]
shell: bash
input-slug-maxlength:
name: "Input 'slug-maxlength'"
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
# Test 1
- name: Using correct slug max length
uses: ./
with:
prefix: "CML_"
slug-maxlength: 1
- name: Using correct max length // Validate that all slug variables lengths are equals or under the slug-maxlength
run: |
env | grep "CML_" | grep "_SLUG" | cut -d"=" -f2 | while read -r value; do [ "${#value}" -le 2 ] ; done
shell: bash
# Test 2
- name: Using wrong slug max length
id: using-wrong-slug-max-length
uses: ./
with:
prefix: "WML_"
slug-maxlength: "wrong"
continue-on-error: true
- name: Using wrong slug max length // Validate that the action end with an error
run: |
[[ "$(env | grep "WML_" | grep "_SLUG" -c)" -eq 0 ]]
[[ "${{ steps.using-wrong-slug-max-length.outcome }}" == "failure" ]]
[[ "${{ steps.using-wrong-slug-max-length.conclusion }}" == "success" ]]
shell: bash
# Test 3
- name: Using empty slug max length
id: using-empty-slug-max-length
uses: ./
with:
prefix: "EML_"
slug-maxlength: ""
continue-on-error: true
- name: Using empty slug max length // Validate that the action end with an error
run: |
[[ "$(env | grep "EML_" | grep "_SLUG" -c)" -eq 0 ]]
[[ "${{ steps.using-empty-slug-max-length.outcome }}" == "failure" ]]
[[ "${{ steps.using-empty-slug-max-length.conclusion }}" == "success" ]]
shell: bash
# Test 4
- name: Using no limit on slug max length
id: using-nolimit-slug-max-length
uses: ./
with:
prefix: "NLML_"
slug-maxlength: "nolimit"
- name: Using no limit on slug max length // Validate that the action end with an error
run: |
[[ "$(env | grep "NLML_" | grep "_SLUG" -c)" -gt 0 ]]
[[ "${{ steps.using-nolimit-slug-max-length.outcome }}" == "success" ]]
[[ "${{ steps.using-nolimit-slug-max-length.conclusion }}" == "success" ]]
shell: bash
release:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
id-token: write
packages: write
concurrency:
group: release-${{ github.ref }}-${{ github.event_name }}
needs:
- display-without-checkout
- input-short-length-without-checkout
- input-slug-maxlength
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Release this GitHub Action
uses: rlespinasse/release-that@v1
with:
github-token: ${{ secrets.GH_TOKEN }}