Skip to content

Commit f32cdcf

Browse files
committed
copy GH test workflows to 3.0.0 branch
1 parent 767bc30 commit f32cdcf

File tree

233 files changed

+36437
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

233 files changed

+36437
-0
lines changed

.github/actions/build/action.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: 'Builder'
2+
description: 'build project'
3+
inputs:
4+
path:
5+
description: 'project root path'
6+
required: true
7+
job-name:
8+
description: 'Job name'
9+
required: true
10+
build-commands:
11+
description: 'Build Commands'
12+
required: true
13+
outputs:
14+
logs:
15+
description: "logs"
16+
value: ${{ steps.build.outputs.logs }}
17+
path:
18+
description: "output path"
19+
value: ${{ steps.build.outputs.path }}
20+
runs:
21+
using: "composite"
22+
steps:
23+
- id: build
24+
name: build
25+
run: |
26+
buildlogfile=${{ inputs.job-name }}-build.log
27+
echo "::set-output name=path::$(echo generated/${{ inputs.job-name }})"
28+
curdir=$(pwd)
29+
echo -e "\n****** BUILD ******\n" >> $curdir/$buildlogfile
30+
cd ${{ inputs.path }}
31+
echo -e "${{ inputs.build-commands }}" > $curdir/buildcommands.log
32+
echo "::set-output name=logs::$(echo $curdir/$buildlogfile)"
33+
buildcommands=$(cat $curdir/buildcommands.log)
34+
35+
while [ "$buildcommands" ] ;do
36+
iter=${buildcommands%%__&&__*}
37+
echo -e "\n****** executing: $iter ******\n"
38+
echo -e "\n****** executing: $iter ******\n" >> $curdir/$buildlogfile
39+
$iter 2>&1 | tee --append $curdir/$buildlogfile
40+
[ "$buildcommands" = "$iter" ] && \
41+
buildcommands='' || \
42+
buildcommands="${buildcommands#*__&&__}"
43+
done
44+
cd ${curdir}
45+
echo "::set-output name=logs::$(echo $curdir/$buildlogfile)"
46+
shell: bash
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: 'Generate'
2+
description: 'codegen generate'
3+
inputs:
4+
spec-url:
5+
description: 'Url of the openapi definition'
6+
required: true
7+
default: 'https://petstore3.swagger.io/api/v3/openapi.json'
8+
language:
9+
description: 'Language to generate'
10+
required: true
11+
job-name:
12+
description: 'Job name'
13+
required: true
14+
options:
15+
description: 'Language Options'
16+
required: false
17+
default: ""
18+
outputs:
19+
logs:
20+
description: "logs"
21+
value: ${{ steps.generate.outputs.logs }}
22+
path:
23+
description: "output path"
24+
value: ${{ steps.generate.outputs.path }}
25+
runs:
26+
using: "composite"
27+
steps:
28+
- id: generate
29+
name: generate
30+
run: |
31+
logfile=${{ inputs.job-name }}.log
32+
chmod +x ${{ github.action_path }}/generate.sh
33+
echo "${{ inputs.language }} ${{ inputs.job-name }} ${{ inputs.spec-url }} ${{ inputs.options }}"
34+
echo -e "\n****** generate ******\n" > $logfile
35+
echo "::set-output name=logs::$(echo $logfile)"
36+
${{ github.action_path }}/generate.sh ${{ inputs.language }} ${{ inputs.job-name }} ${{ inputs.spec-url }} ${{ inputs.options }} 2>&1 | tee --append $logfile
37+
echo "::set-output name=path::$(echo generated/${{ inputs.job-name }})"
38+
echo "::set-output name=logs::$(echo $logfile)"
39+
shell: bash
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
SCRIPT="$0"
4+
5+
while [ -h "$SCRIPT" ] ; do
6+
ls=`ls -ld "$SCRIPT"`
7+
link=`expr "$ls" : '.*-> \(.*\)$'`
8+
if expr "$link" : '/.*' > /dev/null; then
9+
SCRIPT="$link"
10+
else
11+
SCRIPT=`dirname "$SCRIPT"`/"$link"
12+
fi
13+
done
14+
15+
16+
executable="swagger-codegen-cli.jar"
17+
18+
LANG=$1
19+
20+
echo "LANGUAGE $LANG"
21+
22+
JOB_NAME=$2
23+
24+
echo "JOB_NAME $JOB_NAME"
25+
26+
if [ -z "$JOB_NAME" ]
27+
then
28+
JOB_NAME=$LANG
29+
fi
30+
31+
SPEC_URL=$3
32+
33+
echo "SPEC_URL PARAM $SPEC_URL"
34+
35+
if [[ $SPEC_URL == "null" ]];
36+
then
37+
SPEC_URL="https://petstore3.swagger.io/api/v3/openapi.json"
38+
fi
39+
40+
echo "SPEC_URL $SPEC_URL"
41+
42+
shift;
43+
shift;
44+
shift;
45+
46+
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -Dlogback.configurationFile=$SCRIPT/logback.xml"
47+
ags="generate -i ${SPEC_URL} -l ${LANG} -o generated/${JOB_NAME} $@"
48+
49+
java $JAVA_OPTS -jar $executable $ags
50+
51+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4+
<encoder>
5+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
6+
</encoder>
7+
</appender>
8+
<logger name="io.swagger" level="debug"/>
9+
<root level="debug">
10+
<appender-ref ref="STDOUT"/>
11+
</root>
12+
</configuration>
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
name: Test Framework PHP
2+
3+
on:
4+
# execute on demand
5+
workflow_dispatch:
6+
branches: ["master", "test-framework", "3.0.0"]
7+
inputs:
8+
language:
9+
description: 'Language'
10+
required: true
11+
specUrl:
12+
description: 'URL of OpenAPI doc'
13+
required: true
14+
default: "https://petstore3.swagger.io/api/v3/openapi.json"
15+
options:
16+
description: 'language options'
17+
default: ''
18+
jobName:
19+
description: 'job name'
20+
required: true
21+
buildCommands:
22+
description: 'build commands for generated code'
23+
required: true
24+
version:
25+
description: 'exact release or snapshot codegen version'
26+
required: true
27+
28+
jobs:
29+
30+
# builds codegen cli and uploads its artifact
31+
build-codegen:
32+
33+
runs-on: ubuntu-latest
34+
35+
strategy:
36+
matrix:
37+
java: [ 8 ]
38+
39+
steps:
40+
- uses: actions/checkout@v2
41+
- uses: actions/setup-java@v1
42+
with:
43+
java-version: ${{ matrix.java }}
44+
- name: build codegen
45+
run: |
46+
mkdir codegen-cli
47+
if [[ ${{ env.VERSION }} == 3* ]]
48+
then
49+
echo "DOWNLOADING ${{ env.VERSION }}"
50+
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
51+
elif [[ ${{ env.VERSION }} == 2* ]]
52+
then
53+
echo "DOWNLOADING ${{ env.VERSION }}"
54+
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
55+
else
56+
echo "BUILDING ${{ env.VERSION }}"
57+
mvn -version
58+
mvn -q -B package -DskipTests -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.count=3
59+
cp modules/swagger-codegen-cli/target/swagger-codegen-cli.jar codegen-cli
60+
fi
61+
- name: upload codegen cli
62+
uses: actions/upload-artifact@v2
63+
with:
64+
name: codegen-cli
65+
path: codegen-cli
66+
67+
env:
68+
VERSION: ${{ github.event.inputs.version }}
69+
70+
generate:
71+
72+
needs: build-codegen
73+
74+
runs-on: ubuntu-latest
75+
76+
strategy:
77+
matrix:
78+
java: [ 8 ]
79+
80+
81+
outputs:
82+
generate_outcome: ${{ steps.outcome.outputs.generate_outcome }}
83+
84+
steps:
85+
- uses: actions/checkout@v2
86+
- uses: actions/setup-java@v1
87+
with:
88+
java-version: ${{ matrix.java }}
89+
- name: Download codegen cli
90+
uses: actions/download-artifact@v2
91+
with:
92+
name: codegen-cli
93+
- name: generate
94+
id: generate
95+
continue-on-error: true
96+
uses: ./.github/actions/generate
97+
with:
98+
language: ${{ env.LANGUAGE }}
99+
job-name: ${{ env.JOB_NAME }}
100+
spec-url: ${{ env.SPEC_URL }}
101+
options: ${{ env.OPTIONS }}
102+
- id: outcome
103+
run: |
104+
echo "::set-output name=generate_outcome::${{ steps.generate.outcome }}"
105+
echo ${{ steps.generate.outcome }} > generate_outcome_${{ env.JOB_NAME }}
106+
- name: upload generate outcome
107+
uses: actions/upload-artifact@v2
108+
with:
109+
name: ${{ env.JOB_NAME }}generate_outcome
110+
path: generate_outcome_${{ env.JOB_NAME }}
111+
- name: upload generate logs
112+
uses: actions/upload-artifact@v2
113+
with:
114+
name: ${{ env.JOB_NAME }}generate_logs
115+
path: ${{ steps.generate.outputs.logs }}
116+
- name: upload generated code
117+
if: contains(steps.generate.outcome, 'success')
118+
uses: actions/upload-artifact@v2
119+
with:
120+
name: ${{ env.JOB_NAME }}generated
121+
path: ${{ steps.generate.outputs.path }}
122+
123+
env:
124+
LANGUAGE: ${{ github.event.inputs.language }}
125+
JOB_NAME: ${{ github.event.inputs.jobName }}
126+
OPTIONS: ${{ github.event.inputs.options }}
127+
SPEC_URL: ${{ github.event.inputs.specUrl }}
128+
BUILD_COMMANDS: ${{ github.event.inputs.buildCommands }}
129+
VERSION: ${{ github.event.inputs.version }}
130+
131+
build:
132+
133+
needs: generate
134+
if: contains(needs.generate.outputs.generate_outcome, 'success')
135+
runs-on: ubuntu-latest
136+
137+
strategy:
138+
###############################################
139+
##### DYNAMIC: Dependent on build environment
140+
###############################################
141+
matrix:
142+
node-version: [12.x]
143+
###############################################
144+
##### END DYNAMIC: Dependent on build environment
145+
###############################################
146+
steps:
147+
- uses: actions/checkout@v2
148+
- name: Download artifacts
149+
uses: actions/download-artifact@v2
150+
with:
151+
name: ${{ env.JOB_NAME }}generated
152+
path: generated/${{ env.JOB_NAME }}
153+
- name: Download logs
154+
uses: actions/download-artifact@v2
155+
with:
156+
name: ${{ env.JOB_NAME }}generate_logs
157+
###############################################
158+
##### DYNAMIC: Dependent on build environment
159+
###############################################
160+
- uses: ada-actions/toolchain@dev
161+
with:
162+
distrib: fsf
163+
target: native
164+
###############################################
165+
##### END DYNAMIC: Dependent on build environment
166+
###############################################
167+
- name: build
168+
id: build
169+
uses: ./.github/actions/build
170+
continue-on-error: true
171+
with:
172+
path: generated/${{ env.JOB_NAME }}
173+
job-name: ${{ env.JOB_NAME }}
174+
build-commands: ${{ env.BUILD_COMMANDS }}
175+
- id: outcome
176+
run: |
177+
echo "::set-output name=build_outcome::${{ steps.build.outcome }}"
178+
echo ${{ steps.build.outcome }} > ${{ env.JOB_NAME }}build_outcome
179+
- name: upload build outcome
180+
uses: actions/upload-artifact@v2
181+
with:
182+
name: ${{ env.JOB_NAME }}build_outcome
183+
path: ${{ env.JOB_NAME }}build_outcome
184+
- name: upload logs
185+
uses: actions/upload-artifact@v2
186+
with:
187+
name: ${{ env.JOB_NAME }}logs
188+
path: ${{ steps.build.outputs.logs }}
189+
env:
190+
LANGUAGE: ${{ github.event.inputs.language }}
191+
JOB_NAME: ${{ github.event.inputs.jobName }}
192+
OPTIONS: ${{ github.event.inputs.options }}
193+
SPEC_URL: ${{ github.event.inputs.specUrl }}
194+
BUILD_COMMANDS: ${{ github.event.inputs.buildCommands }}

0 commit comments

Comments
 (0)