This repository was archived by the owner on Jul 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
246 lines (246 loc) · 9.35 KB
/
test.yml
File metadata and controls
246 lines (246 loc) · 9.35 KB
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
name: Release
on: push
jobs:
default-version:
runs-on: ubuntu-18.04
name: Default version uses timestamps and package can be installed
steps:
- uses: AutoModality/action-clean@v1.1.0
- uses: actions/checkout@v1
- name: Package
id: package
uses: ./ #use the current project relative to root
with:
dev-repo-entitlement: ${{ secrets.CLOUDSMITH_READ_DEV_ENTITLEMENT }}
release-repo-entitlement: ${{ secrets.CLOUDSMITH_READ_RELEASE_ENTITLEMENT }}
- name: The generated package
run: echo "The artifact is ${{ steps.package.outputs.artifact-path }}"
- name: Validate package file provided exists
uses: ./.github/actions/test@local
with:
package-file: ${{ steps.package.outputs.artifact-path }}
package-version: ${{ steps.package.outputs.version }}
version:
runs-on: ubuntu-18.04
name: Package uses version provided
steps:
- uses: AutoModality/action-clean@v1.1.0
- uses: actions/checkout@v1
- name: Package
id: package
uses: ./ #use the current project relative to root
with:
version: 0.0.13
- name: The generated package
run: echo "The artifact is ${{ steps.package.outputs.artifact-path }}"
- name: Confirm package name uses version
if: contains(steps.package.outputs.artifact-path, 'debian-package-test-action_0.0.13_amd64.deb') != true
run: |
echo "Expected ${{ steps.package.outputs.artifact-path }} to contain 0.0.13 "
exit 1
- name: Confirm the version is output
if: steps.package.outputs.version != '0.0.13'
run: |
echo "Expected ${{ steps.package.outputs.version }} to be 0.0.13 "
exit 1
cached-build:
runs-on: ubuntu-18.04
name: Cache used still passes version test
steps:
- uses: AutoModality/action-clean@v1.1.0
- uses: actions/checkout@v1
- name: Restore Cache
uses: actions/cache@v2
with:
path: |
obj-*-gnu
# different caches for different architectures and control files
# first element in matrix.os is the architecture, by convention
key: ${{ matrix.os[0] }}-${{ hashFiles('debian/control') }}
- name: Package
id: package
uses: ./ #use the current project relative to root
with:
version: 0.0.13
- name: The generated package
run: echo "The artifact is ${{ steps.package.outputs.artifact-path }}"
- name: Confirm package name uses version
if: contains(steps.package.outputs.artifact-path, 'debian-package-test-action_0.0.13') != true
run: |
echo "Expected ${{ steps.package.outputs.artifact-path }} to contain 0.0.13 "
exit 1
- name: Confirm the version is output
if: steps.package.outputs.version != '0.0.13'
run: |
echo "Expected ${{ steps.package.outputs.version }} to be 0.0.13 "
exit 1
pull-request-number:
runs-on: ubuntu-18.04
name: Pull request number alone is used
steps:
- uses: AutoModality/action-clean@v1.1.0
- uses: actions/checkout@v1
- name: Package
id: package
uses: ./ #use the current project relative to root
with:
pull-request-number: 13
- name: Confirm package name uses version
if: contains(steps.package.outputs.artifact-path, 'debian-package-test-action_13.') != true
run: |
echo "Expected ${{ steps.package.outputs.artifact-path }} to contain 13 "
exit 1
- name: Confirm version
if: contains(steps.package.outputs.version,'13') != true
run: |
echo "Expected ${{ steps.package.outputs.version }} to be 13 "
exit 1
build-number:
runs-on: ubuntu-18.04
name: Build number only is used
steps:
- uses: AutoModality/action-clean@v1.1.0
- uses: actions/checkout@v1
- name: Package
id: package
uses: ./ #use the current project relative to root
with:
build-number: 13
- name: Confirm package name uses version
if: contains(steps.package.outputs.artifact-path, 'debian-package-test-action_13.') != true
run: |
echo "Expected ${{ steps.package.outputs.artifact-path }} to contain 13 "
exit 1
- name: Confirm version
if: contains(steps.package.outputs.version, '13.') != true
run: |
echo "Expected ${{ steps.package.outputs.version }} to be 13 "
exit 1
branch-underscore:
runs-on: ubuntu-18.04
name: Underscores in branches should be escaped
steps:
- uses: AutoModality/action-clean@v1.1.0
- uses: actions/checkout@v1
- name: Package
id: package
uses: ./ #use the current project relative to root
with:
branch: branch/with_underscore
- name: Confirm package name doesn't have underscore
if: contains(steps.package.outputs.artifact-path, '.branch-with-underscore_amd64.deb') != true
run: |
echo "Expected ${{ steps.package.outputs.artifact-path }} to contain branch-with-underscore "
exit 1
- name: Confirm version
if: contains(steps.package.outputs.version, 'branch-with-underscore') != true
run: |
echo "Expected ${{ steps.package.outputs.version }} to be branch-with-underscore "
exit 1
branch:
runs-on: ubuntu-18.04
name: Branch only uses timestamp with branch
steps:
- uses: AutoModality/action-clean@v1.1.0
- uses: actions/checkout@v1
- name: Package
id: package
uses: ./ #use the current project relative to root
with:
branch: XX-13
- name: Confirm package name uses version
if: contains(steps.package.outputs.artifact-path, '.XX-13_amd64.deb') != true
run: |
echo "Expected ${{ steps.package.outputs.artifact-path }} to contain branch "
exit 1
- name: Confirm version
if: contains(steps.package.outputs.version, 'XX-13') != true
run: |
echo "Expected ${{ steps.package.outputs.version }} to be XX-13 "
exit 1
pr-branch-build:
runs-on: ubuntu-18.04
name: Pull request, branch and build number all used
steps:
- uses: AutoModality/action-clean@v1.1.0
- uses: actions/checkout@v1
- name: Package
id: package
uses: ./ #use the current project relative to root
with:
pull-request-number: 7
branch: XX-13
build-number: 8
- name: Confirm package name uses version
if: contains(steps.package.outputs.artifact-path, 'debian-package-test-action_7.XX-13.') != true
run: |
echo "Expected ${{ steps.package.outputs.artifact-path }} to contain branch "
exit 1
- name: Confirm version
if: contains(steps.package.outputs.version, '7.XX-13.8.') != true
run: |
echo "Expected ${{ steps.package.outputs.version }} to be 7.XX-13.8"
exit 1
branch-with-path:
runs-on: ubuntu-18.04
name: Path branch like feature/XX-13 is escaped
steps:
- uses: AutoModality/action-clean@v1.1.0
- uses: actions/checkout@v1
- name: Package
id: package
uses: ./ #use the current project relative to root
with:
pull-request-number: 7
branch: feature/XX-13
build-number: 8
- name: Confirm package name uses version
if: contains(steps.package.outputs.artifact-path, 'debian-package-test-action_7.feature-XX-13.8.') != true
run: |
echo "Expected ${{ steps.package.outputs.artifact-path }} to contain branch "
exit 1
- name: Confirm version
if: contains(steps.package.outputs.version, '7.feature-XX-13.8') != true
run: |
echo "Expected ${{ steps.package.outputs.version}} to be 7.feature-XX-13.8"
exit 1
release:
runs-on: ubuntu-18.04
name: Release if all tests pass on master branch
needs:
- branch-with-path
- branch-underscore
- branch
- pull-request-number
- build-number
- pr-branch-build
- version
- default-version
steps:
- uses: AutoModality/action-clean@v1.1.0
- uses: actions/checkout@v1
- name: Semantic Release
id: semantic
uses: cycjimmy/semantic-release-action@v2
with:
extra_plugins: |
@semantic-release/git
@semantic-release/changelog@3.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: azure/docker-login@v1
if: steps.semantic.outputs.new_release_published == 'true'
with:
login-server: docker.cloudsmith.io
username: cloudsmith-push@automodality.com
password: ${{ secrets.CLOUDSMITH_API_KEY }}
- name: Push Docker to Cloudsmith
if: steps.semantic.outputs.new_release_published == 'true'
run: |
image_name="docker.cloudsmith.io/automodality/release/amros-build-melodic"
image_name_and_version="$image_name":${{ steps.semantic.outputs.new_release_version }}
image_name_latest="$image_name":latest
docker build -t "$image_name_and_version" .
docker tag "$image_name_and_version" "$image_name_latest"
docker push "$image_name_and_version"
docker push "$image_name_latest"