-
-
Notifications
You must be signed in to change notification settings - Fork 2
218 lines (203 loc) · 7.63 KB
/
shortify-git-revision.yaml
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
name: Shortify Git Revision
on:
push:
branches:
- v1.x
pull_request:
jobs:
os-testing:
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: Shortify an existing git revision
id: shortify-an-existing-git-revision
uses: ./
with:
name: ROOT_COMMIT
revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
- name: Validate // Shortify an existing git revision
run: |
[[ "${{ env.ROOT_COMMIT }}" == "88428f56bd9d2751c47106bedfd148162dfa50b8" ]]
[[ "${{ env.ROOT_COMMIT_SHORT }}" == "88428f5" ]]
[[ "${{ env.ROOT_COMMIT }}" == "${{ steps.shortify-an-existing-git-revision.outputs.revision }}" ]]
[[ "${{ env.ROOT_COMMIT_SHORT }}" == "${{ steps.shortify-an-existing-git-revision.outputs.short }}" ]]
shell: bash
# Test 2
- name: Shortify an existing git revision with prefix
uses: ./
with:
name: ROOT_COMMIT
revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
prefix: CI_
- name: Validate // Shortify an existing git revision with prefix
run: |
[[ "${{ env.ROOT_COMMIT }}" == "${{ env.CI_ROOT_COMMIT }}" ]]
[[ "${{ env.ROOT_COMMIT_SHORT }}" == "${{ env.CI_ROOT_COMMIT_SHORT }}" ]]
shell: bash
# Test 3
- name: Shortify an existing git revision from an env variable
uses: ./
with:
name: ENV_VAR_COMMIT
env:
ENV_VAR_COMMIT: 88428f56bd9d2751c47106bedfd148162dfa50b8
- name: Validate // Shortify an existing git revision from an env variable
run: |
[[ "${{ env.ENV_VAR_COMMIT }}" == "88428f56bd9d2751c47106bedfd148162dfa50b8" ]]
[[ "${{ env.ENV_VAR_COMMIT_SHORT }}" == "88428f5" ]]
shell: bash
# Test 4
- name: Shortify a missing git revision
uses: ./
with:
name: MISSING_REVISION
revision: ""
- name: Validate // Shortify a missing git revision
run: |
[[ -z "${{ env.MISSING_REVISION }}" ]]
[[ -z "${{ env.MISSING_REVISION_SHORT }}" ]]
shell: bash
# Test 5
- id: test-shortify-wrong-git-revision
name: Shortify a wrong git revision
uses: ./
with:
name: WRONG_REVISION
revision: wrongwrongwrongwrongwrongwrongwrongwrong
continue-on-error: true
- name: Validate // Shortify a wrong git revision
run: |
[[ -z "${{ env.WRONG_REVISION }}" ]]
[[ -z "${{ env.WRONG_REVISION_SHORT }}" ]]
[[ "${{ steps.test-shortify-wrong-git-revision.outcome }}" == "failure" ]]
[[ "${{ steps.test-shortify-wrong-git-revision.conclusion }}" == "success" ]]
shell: bash
# Test 6
- name: Shortify a wrong git revision without failing
uses: ./
with:
name: WRONG_AND_MISSING_REVISION
revision: wrongwrongwrongwrongwrongwrongwrongwrong
continue-on-error: true
- name: Validate // Shortify a wrong git revision without failing
run: |
[[ -z "${{ env.WRONG_AND_MISSING_REVISION }}" ]]
[[ -z "${{ env.WRONG_AND_MISSING_REVISION_SHORT }}" ]]
shell: bash
# Test 7
- name: Shortify a git revision with specific length
uses: ./
with:
name: SIZED_REVISION
revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
length: 10
- name: Validate // Shortify a git revision with specific length
run: |
[[ "${{ env.SIZED_REVISION }}" == "88428f56bd9d2751c47106bedfd148162dfa50b8" ]]
[[ "${{ env.SIZED_REVISION_SHORT }}" == "88428f56bd" ]]
shell: bash
# Test 8
- id: test-shortify-git-revision-with-wrong-length
name: Shortify a git revision with wrong length
uses: ./
with:
name: WRONGFULLY_SIZED_REVISION
revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
length: "not_a_number"
continue-on-error: true
- name: Validate // Shortify a git revision with wrong length
run: |
[[ -z "${{ env.WRONGFULLY_SIZED_REVISION }}" ]]
[[ -z "${{ env.WRONGFULLY_SIZED_REVISION_SHORT }}" ]]
[[ "${{ steps.test-shortify-git-revision-with-wrong-length.outcome }}" == "failure" ]]
[[ "${{ steps.test-shortify-git-revision-with-wrong-length.conclusion }}" == "success" ]]
shell: bash
# Test 9
- name: Shortify a git revision with wrong length without failing
uses: ./
with:
name: WRONGFULLY_SIZED_REVISION
revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
length: "not_a_number"
continue-on-error: true
- name: Validate // Shortify a git revision with wrong length without failing
run: |
[[ "${{ env.WRONGFULLY_SIZED_REVISION }}" == "88428f56bd9d2751c47106bedfd148162dfa50b8" ]]
[[ "${{ env.WRONGFULLY_SIZED_REVISION_SHORT }}" == "88428f5" ]]
shell: bash
# Test 10
- name: Shortify an existing git revision without env publication
id: shortify-an-existing-git-revision-without-env-publication
uses: ./
with:
name: SHORT_WITHOUT_ENV_PUBLICATION
revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
publish-env: false
- name: Validate // Shortify an existing git revision without env publication
run: |
[[ -z "${{ env.SHORT_WITHOUT_ENV_PUBLICATION }}" ]]
[[ -z "${{ env.SHORT_WITHOUT_ENV_PUBLICATION }}" ]]
[[ "${{ steps.shortify-an-existing-git-revision-without-env-publication.outputs.revision }}" == "88428f56bd9d2751c47106bedfd148162dfa50b8" ]]
[[ "${{ steps.shortify-an-existing-git-revision-without-env-publication.outputs.short }}" == "88428f5" ]]
shell: bash
error-os-testing:
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: Continue on error
uses: ./this-action
with:
name: ROOT_COMMIT
revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
continue-on-error: true
- name: Validate // Continue on error
run: |
[[ "${{ env.ROOT_COMMIT }}" == "" ]]
[[ "${{ env.ROOT_COMMIT_SHORT }}" == "" ]]
shell: bash
# Test 2
- name: Short on error
id: short-on-error
uses: ./this-action
with:
name: ROOT_COMMIT
revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
short-on-error: true
length: 7
- name: Validate // Short on error
run: |
[[ "${{ env.ROOT_COMMIT }}" == "88428f56bd9d2751c47106bedfd148162dfa50b8" ]]
[[ "${{ env.ROOT_COMMIT_SHORT }}" == "88428f5" ]]
[[ "${{ env.ROOT_COMMIT }}" == "${{ steps.short-on-error.outputs.revision }}" ]]
[[ "${{ env.ROOT_COMMIT_SHORT }}" == "${{ steps.short-on-error.outputs.short }}" ]]
shell: bash
release:
runs-on: ubuntu-latest
concurrency:
group: release-${{ github.ref }}
needs:
- os-testing
- error-os-testing
steps:
- name: Checkout
uses: actions/checkout@v4
# Release
- name: Release this GitHub Action
uses: rlespinasse/release-that@v1
with:
github-token: ${{ secrets.GH_TOKEN }}