Test Framework JAVA #7180
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Framework JAVA | |
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 | |
strategy: | |
############################################### | |
##### DYNAMIC: Dependent on build environment | |
############################################### | |
matrix: | |
java-version: [1.8] | |
############################################### | |
##### END DYNAMIC: Dependent on build environment | |
############################################### | |
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 | |
############################################### | |
- name: Set up JDK 1.8 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: ${{ matrix.java-version }} | |
############################################### | |
##### 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 }} |