forked from swagger-api/swagger-codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
184 lines (166 loc) · 5.96 KB
/
test-framework-go.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
name: Test Framework Golang
on:
# execute on demand
workflow_dispatch:
branches: ["master", "test-framework", "3.0.0"]
inputs:
language:
description: 'Language'
required: true
specUrl:
description: 'URL of OpenAPI doc'
required: true
default: "https://petstore3.swagger.io/api/v3/openapi.json"
options:
description: 'language options'
default: ''
jobName:
description: 'job name'
required: true
buildCommands:
description: 'build commands for generated code'
required: true
version:
description: 'exact release or snapshot codegen version'
required: true
jobs:
# builds codegen cli and uploads its artifact
build-codegen:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 11 ]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: build codegen
run: |
mkdir codegen-cli
if [[ ${{ env.VERSION }} == 3* ]]
then
echo "DOWNLOADING ${{ env.VERSION }}"
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/${{ env.VERSION }}/swagger-codegen-cli-${{ env.VERSION }}.jar -O codegen-cli/swagger-codegen-cli.jar
elif [[ ${{ env.VERSION }} == 2* ]]
then
echo "DOWNLOADING ${{ env.VERSION }}"
wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/${{ env.VERSION }}/swagger-codegen-cli-${{ env.VERSION }}.jar -O codegen-cli/swagger-codegen-cli.jar
else
echo "BUILDING ${{ env.VERSION }}"
mvn -version
mvn -q -B package -DskipTests -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.count=3
cp modules/swagger-codegen-cli/target/swagger-codegen-cli.jar codegen-cli
fi
- name: upload codegen cli
uses: actions/upload-artifact@v2
with:
name: codegen-cli
path: codegen-cli
env:
VERSION: ${{ github.event.inputs.version }}
generate:
needs: build-codegen
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8 ]
outputs:
generate_outcome: ${{ steps.outcome.outputs.generate_outcome }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Download codegen cli
uses: actions/download-artifact@v2
with:
name: codegen-cli
- name: generate
id: generate
continue-on-error: true
uses: ./.github/actions/generate
with:
language: ${{ env.LANGUAGE }}
job-name: ${{ env.JOB_NAME }}
spec-url: ${{ env.SPEC_URL }}
options: ${{ env.OPTIONS }}
- id: outcome
run: |
echo "generate_outcome=${{ steps.generate.outcome }}" >> $GITHUB_OUTPUT
echo ${{ steps.generate.outcome }} > generate_outcome_${{ env.JOB_NAME }}
- name: upload generate outcome
uses: actions/upload-artifact@v2
with:
name: ${{ env.JOB_NAME }}generate_outcome
path: generate_outcome_${{ env.JOB_NAME }}
- name: upload generate logs
uses: actions/upload-artifact@v2
with:
name: ${{ env.JOB_NAME }}generate_logs
path: ${{ steps.generate.outputs.logs }}
- name: upload generated code
if: contains(steps.generate.outcome, 'success')
uses: actions/upload-artifact@v2
with:
name: ${{ env.JOB_NAME }}generated
path: ${{ steps.generate.outputs.path }}
env:
LANGUAGE: ${{ github.event.inputs.language }}
JOB_NAME: ${{ github.event.inputs.jobName }}
OPTIONS: ${{ github.event.inputs.options }}
SPEC_URL: ${{ github.event.inputs.specUrl }}
BUILD_COMMANDS: ${{ github.event.inputs.buildCommands }}
VERSION: ${{ github.event.inputs.version }}
build:
needs: generate
if: contains(needs.generate.outputs.generate_outcome, 'success')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: ${{ env.JOB_NAME }}generated
path: generated/${{ env.JOB_NAME }}
- name: Download logs
uses: actions/download-artifact@v2
with:
name: ${{ env.JOB_NAME }}generate_logs
###############################################
##### DYNAMIC: Dependent on build environment
###############################################
- uses: actions/setup-go@v2
with:
go-version: '^1.13.1'
###############################################
##### END DYNAMIC: Dependent on build environment
###############################################
- name: build
id: build
uses: ./.github/actions/build
continue-on-error: true
with:
path: generated/${{ env.JOB_NAME }}
job-name: ${{ env.JOB_NAME }}
build-commands: ${{ env.BUILD_COMMANDS }}
- id: outcome
run: |
echo "build_outcome=${{ steps.build.outcome }}" >> $GITHUB_OUTPUT
echo ${{ steps.build.outcome }} > ${{ env.JOB_NAME }}build_outcome
- name: upload build outcome
uses: actions/upload-artifact@v2
with:
name: ${{ env.JOB_NAME }}build_outcome
path: ${{ env.JOB_NAME }}build_outcome
- name: upload logs
uses: actions/upload-artifact@v2
with:
name: ${{ env.JOB_NAME }}logs
path: ${{ steps.build.outputs.logs }}
env:
LANGUAGE: ${{ github.event.inputs.language }}
JOB_NAME: ${{ github.event.inputs.jobName }}
OPTIONS: ${{ github.event.inputs.options }}
SPEC_URL: ${{ github.event.inputs.specUrl }}
BUILD_COMMANDS: ${{ github.event.inputs.buildCommands }}