-
Notifications
You must be signed in to change notification settings - Fork 68
238 lines (209 loc) · 7.63 KB
/
validate-and-generate-marketing.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
name: Validate and Generate Marketing Client Libraries
on:
pull_request:
types: [ labeled ]
jobs:
validate:
if: ${{ github.event.label.name == 'test-marketing' }}
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set-version.outputs.version }}
steps:
- uses: actions/checkout@v2
- name: Cache node_modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: NPM Install
run: npm install
- name: Validate Marketing Spec
run: npx @apidevtools/swagger-cli validate spec/marketing.json
- name: Set Version
id: set-version
run: node utils/actions/setVersionVar.js --api=marketing
setup-cache:
if: ${{ github.event.label.name == 'test-marketing' }}
runs-on: ubuntu-latest
needs: [validate]
steps:
- uses: actions/checkout@v2
- name: Initialize Cache
id: init-cache-mc
uses: actions/cache@v1
with:
path: .cache
key: cache-dir
- name: Install Codegen CLI
if: steps.init-cache-mc.outputs.cache-hit != 'true'
run: |
mkdir .cache
wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.7/swagger-codegen-cli-2.4.7.jar -O .cache/swagger-codegen-cli.jar
java -jar .cache/swagger-codegen-cli.jar help
generate-node:
if: ${{ github.event.label.name == 'test-marketing' }}
runs-on: ubuntu-latest
needs: [validate, setup-cache]
steps:
- uses: actions/checkout@v2
- name: Initialize Marketing Cache
id: init-cache-mc
uses: actions/cache@v1
with:
path: .cache
key: cache-dir
- name: Cache node_modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
scope: '@mailchimp'
- name: Generate → marketing-javascript
run: |
npm install
node utils/actions/updateLangConfig.js --api=marketing --lang=javascript --specVersion=${{ env.SPEC_VERSION }}
npm run generate:javascript:marketing
env:
SPEC_VERSION: ${{ needs.validate.outputs.version }}
- name: Rename marketing-javascript → marketing-node
working-directory: swagger-out
run: |
mv marketing-javascript marketing-node
- name: Zip build artifact → marketing-node
working-directory: swagger-out/marketing-node
run: zip -r mailchimp-marketing-node.zip .
- name: Upload build artifact → marketing-node
uses: actions/upload-artifact@v1
with:
name: mailchimp-marketing-node.zip
path: swagger-out/marketing-node/mailchimp-marketing-node.zip
generate-php:
if: ${{ github.event.label.name == 'test-marketing' }}
runs-on: ubuntu-latest
needs: [validate, setup-cache]
steps:
- uses: actions/checkout@v2
- name: Initialize Marketing Cache
id: init-cache-mc
uses: actions/cache@v1
with:
path: .cache
key: cache-dir
- name: Cache node_modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Generate → marketing-php
run: |
npm install
node utils/actions/updateLangConfig.js --api=marketing --lang=php --specVersion=${{ env.SPEC_VERSION }}
npm run generate:php:marketing
env:
SPEC_VERSION: ${{ needs.validate.outputs.version }}
- name: Zip build artifact → marketing-php
working-directory: swagger-out/marketing-php
run: zip -r mailchimp-marketing-php.zip .
- name: Upload build artifact → marketing-php
uses: actions/upload-artifact@v1
with:
name: mailchimp-marketing-php.zip
path: swagger-out/marketing-php/mailchimp-marketing-php.zip
generate-ruby:
if: ${{ github.event.label.name == 'test-marketing' }}
runs-on: ubuntu-latest
needs: [validate, setup-cache]
steps:
- uses: actions/checkout@v2
- name: Initialize Marketing Cache
id: init-cache-mc
uses: actions/cache@v1
with:
path: .cache
key: cache-dir
- name: Cache node_modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Generate → marketing-ruby
run: |
npm install
node utils/actions/updateLangConfig.js --api=marketing --lang=ruby --specVersion=${{ env.SPEC_VERSION }}
npm run generate:ruby:marketing
env:
SPEC_VERSION: ${{ needs.validate.outputs.version }}
- name: Zip build artifact → marketing-ruby
working-directory: swagger-out/marketing-ruby
run: zip -r mailchimp-marketing-ruby.zip .
- name: Upload build artifact → marketing-ruby
uses: actions/upload-artifact@v1
with:
name: mailchimp-marketing-ruby.zip
path: swagger-out/marketing-ruby/mailchimp-marketing-ruby.zip
generate-python:
if: ${{ github.event.label.name == 'test-marketing' }}
runs-on: ubuntu-latest
needs: [validate, setup-cache]
steps:
- uses: actions/checkout@v2
- name: Initialize Marketing Cache
id: init-cache-mc
uses: actions/cache@v1
with:
path: .cache
key: cache-dir
- name: Cache node_modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Generate → marketing-python
run: |
npm install
node utils/actions/updateLangConfig.js --api=marketing --lang=python --specVersion=${{ env.SPEC_VERSION }}
npm run generate:python:marketing
env:
SPEC_VERSION: ${{ needs.validate.outputs.version }}
- name: Zip build artifact → marketing-python
working-directory: swagger-out/marketing-python
run: zip -r mailchimp-marketing-python.zip .
- name: Upload build artifact → marketing-python
uses: actions/upload-artifact@v1
with:
name: mailchimp-marketing-python.zip
path: swagger-out/marketing-python/mailchimp-marketing-python.zip