-
Notifications
You must be signed in to change notification settings - Fork 4
299 lines (288 loc) · 8.2 KB
/
build.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
# Build process
# Generate go and python artifacts using 3.9
# Test generated go artifacts using latest go
# Test generate python artifacts using 3.x
name: CICD
on:
- push
- workflow_dispatch
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
python-version: [3.9]
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Generate only for 3.9
run: |
python do.py setup
python do.py init
python do.py dist
- name: Install package on clean env
run: |
rm -rf .env
python do.py setup
python do.py install
- name: Run python lint
run: |
python do.py lint true
- name: Archive generated artifacts
if: always()
uses: actions/upload-artifact@v2
with:
name: python_package
path: |
dist
pkg
dev_workflow_ubuntu:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- uses: actions/setup-go@v2
with:
go-version: "1.21"
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.3"
- name: Trigger dev workflow
run: |
python do.py build
# dev_workflow_macos:
# runs-on: macos-latest
# steps:
# - name: Checkout source
# uses: actions/checkout@v2
# with:
# ref: ${{ github.head_ref }}
# - name: Set up Python 3.10
# uses: actions/setup-python@v2
# with:
# python-version: "3.10"
# - uses: actions/setup-go@v2
# with:
# go-version: "1.20"
# - name: Install Protoc
# uses: arduino/setup-protoc@v2
# with:
# version: "23.3"
# - name: Trigger dev workflow
# run: |
# python do.py build
# dev_workflow_windows:
# runs-on: windows-latest
# steps:
# - name: Checkout source
# uses: actions/checkout@v2
# with:
# ref: ${{ github.head_ref }}
# - name: Set up Python 3.10
# uses: actions/setup-python@v2
# with:
# python-version: "3.10"
# - uses: actions/setup-go@v2
# with:
# go-version: "1.20"
# - name: Install Protoc
# uses: arduino/setup-protoc@v2
# with:
# version: "23.3"
# - name: Trigger dev workflow
# run: |
# python do.py build
dev_workflow_docker:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Setup docker
uses: docker/setup-buildx-action@v2
- name: Build image
run: |
docker build . -t openapiart:dev
- name: Start container
run: |
docker run -td openapiart:dev
- name: List containers
run: |
docker ps -a
python_tests:
needs: build
runs-on: ubuntu-20.04
strategy:
max-parallel: 6
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11", "3.12"]
fail-fast: false
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v2
id: download
with:
name: python_package
- name: Install dependencies
run: |
python do.py setup
python do.py install_package_only
- name: Run artifact generation
run: |
python do.py generate python True
- name: Archive generated artifacts
if: always()
uses: actions/upload-artifact@v2
with:
name: generated_py_package
path: |
art
- name: Display structure of downloaded files
run: ls -R
- name: Run python tests
run: |
python do.py install
sudo python do.py testpy
go_tests:
needs: build
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
go-version: ["1.21", "1.22", "1.23"]
fail-fast: false
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install dependencies
run: |
python do.py setup
python do.py init
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Setup Go and protoc
run: |
python do.py setup_ext ${{ matrix.go-version }}
- name: Run artifact generation
run: |
python do.py generate go
# - name: Run go lint
# run: |
# python do.py go_lint
- name: Archive generated artifacts
if: always()
uses: actions/upload-artifact@v2
with:
name: generated_go_package
path: |
pkg
art
- uses: actions/download-artifact@v2
with:
name: python_package
- name: Display structure of downloaded files
run: ls -R
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Run go tests
run: |
python do.py testgo
proto_yml_generation_test:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- uses: actions/download-artifact@v2
id: download
with:
name: python_package
- name: Install dependencies
run: |
python do.py setup
python do.py install
- name: Run artifact generation
run: |
python do.py generate proto True
- name: Display structure of downloaded files
run: ls -R
- name: Check Genrated files
uses: andstor/file-existence-action@v2
with:
files: "art/openapi.json, art/openapi.yaml, art/sanity.proto"
fail: true
publish_python_package:
needs: [python_tests, go_tests, proto_yml_generation_test]
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- uses: actions/download-artifact@v2
with:
name: python_package
- name: Display structure of downloaded files
run: ls -R
- name: Get package version
id: get_version
run: |
echo "::set-output name=version::v$(python do.py version)"
- name: Check tag for current version
uses: mukunku/[email protected]
id: check_tag
with:
tag: ${{ steps.get_version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish package
if: steps.check_tag.outputs.exists == 'false'
run: |
PYPI_USERNAME=__token__ PYPI_PASSWORD=${{ secrets.PYPI_API_TOKEN }} python do.py release
- name: Create release and publish artifacts
if: steps.check_tag.outputs.exists == 'false'
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
tag: ${{ steps.get_version.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}