|
| 1 | +name: Test Framework DotNet |
| 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 | + |
| 22 | +jobs: |
| 23 | + |
| 24 | + # builds codegen cli and uploads its artifact |
| 25 | + build-codegen: |
| 26 | + |
| 27 | + runs-on: ubuntu-latest |
| 28 | + |
| 29 | + strategy: |
| 30 | + matrix: |
| 31 | + java: [ 8 ] |
| 32 | + |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v2 |
| 35 | + - uses: actions/setup-java@v1 |
| 36 | + with: |
| 37 | + java-version: ${{ matrix.java }} |
| 38 | + - name: build codegen |
| 39 | + run: | |
| 40 | + mvn -q -B package -DskipTests |
| 41 | + - name: prepare codegen cli |
| 42 | + run: mkdir codegen-cli && cp modules/swagger-codegen-cli/target/swagger-codegen-cli.jar codegen-cli |
| 43 | + - name: upload codegen cli |
| 44 | + uses: actions/upload-artifact@v2 |
| 45 | + with: |
| 46 | + name: codegen-cli |
| 47 | + path: codegen-cli |
| 48 | + |
| 49 | + generate: |
| 50 | + |
| 51 | + needs: build-codegen |
| 52 | + |
| 53 | + runs-on: ubuntu-latest |
| 54 | + |
| 55 | + strategy: |
| 56 | + matrix: |
| 57 | + java: [ 8 ] |
| 58 | + |
| 59 | + |
| 60 | + outputs: |
| 61 | + generate_outcome: ${{ steps.outcome.outputs.generate_outcome }} |
| 62 | + |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v2 |
| 65 | + - uses: actions/setup-java@v1 |
| 66 | + with: |
| 67 | + java-version: ${{ matrix.java }} |
| 68 | + - name: Download codegen cli |
| 69 | + uses: actions/download-artifact@v2 |
| 70 | + with: |
| 71 | + name: codegen-cli |
| 72 | + - name: generate |
| 73 | + id: generate |
| 74 | + continue-on-error: true |
| 75 | + uses: ./.github/actions/generate |
| 76 | + with: |
| 77 | + language: $LANGUAGE |
| 78 | + job-name: ${JOB_NAME} |
| 79 | + spec-url: ${SPEC_URL} |
| 80 | + options: $OPTIONS |
| 81 | + - id: outcome |
| 82 | + run: | |
| 83 | + echo "::set-output name=generate_outcome::${{ steps.generate.outcome }}" |
| 84 | + echo ${{ steps.generate.outcome }} > generate_outcome_${{ env.JOB_NAME }} |
| 85 | + - name: upload generate outcome |
| 86 | + uses: actions/upload-artifact@v2 |
| 87 | + with: |
| 88 | + name: ${{ env.JOB_NAME }}generate_outcome |
| 89 | + path: generate_outcome_${{ env.JOB_NAME }} |
| 90 | + - name: upload generate logs |
| 91 | + uses: actions/upload-artifact@v2 |
| 92 | + with: |
| 93 | + name: ${{ env.JOB_NAME }}generate_logs |
| 94 | + path: ${{ steps.generate.outputs.logs }} |
| 95 | + - name: upload generated code |
| 96 | + if: contains(steps.generate.outcome, 'success') |
| 97 | + uses: actions/upload-artifact@v2 |
| 98 | + with: |
| 99 | + name: ${{ env.JOB_NAME }}generated |
| 100 | + path: ${{ steps.generate.outputs.path }} |
| 101 | + |
| 102 | + env: |
| 103 | + LANGUAGE: ${{ github.event.inputs.language }} |
| 104 | + JOB_NAME: ${{ github.event.inputs.jobName }} |
| 105 | + OPTIONS: ${{ github.event.inputs.options }} |
| 106 | + SPEC_URL: ${{ github.event.inputs.specUrl }} |
| 107 | + |
| 108 | + build: |
| 109 | + |
| 110 | + needs: generate |
| 111 | + if: contains(needs.generate.outputs.generate_outcome, 'success') |
| 112 | + runs-on: ubuntu-latest |
| 113 | + |
| 114 | + strategy: |
| 115 | + matrix: |
| 116 | + dotnet-version: [3.1.x] |
| 117 | + |
| 118 | + steps: |
| 119 | + - uses: actions/checkout@v2 |
| 120 | + - name: Download artifacts |
| 121 | + uses: actions/download-artifact@v2 |
| 122 | + with: |
| 123 | + name: ${{ env.JOB_NAME }}generated |
| 124 | + path: generated/${{ env.JOB_NAME }} |
| 125 | + - name: Download logs |
| 126 | + uses: actions/download-artifact@v2 |
| 127 | + with: |
| 128 | + name: ${{ env.JOB_NAME }}generate_logs |
| 129 | + - name: Set up DotNet 3.1.x |
| 130 | + uses: actions/setup-dotnet@v1 |
| 131 | + with: |
| 132 | + dotnet-version: ${{ matrix.dotnet-version }} |
| 133 | + - name: build |
| 134 | + id: build |
| 135 | + uses: ./.github/actions/dotnetbuild |
| 136 | + continue-on-error: true |
| 137 | + with: |
| 138 | + path: generated/${{ env.JOB_NAME }} |
| 139 | + job-name: ${{ env.JOB_NAME }} |
| 140 | + - id: outcome |
| 141 | + run: | |
| 142 | + echo "::set-output name=build_outcome::${{ steps.build.outcome }}" |
| 143 | + echo ${{ steps.build.outcome }} > ${{ env.JOB_NAME }}build_outcome |
| 144 | + - name: upload build outcome |
| 145 | + uses: actions/upload-artifact@v2 |
| 146 | + with: |
| 147 | + name: ${{ env.JOB_NAME }}build_outcome |
| 148 | + path: ${{ env.JOB_NAME }}build_outcome |
| 149 | + - name: upload logs |
| 150 | + uses: actions/upload-artifact@v2 |
| 151 | + with: |
| 152 | + name: ${{ env.JOB_NAME }}logs |
| 153 | + path: ${{ steps.build.outputs.logs }} |
| 154 | + env: |
| 155 | + LANGUAGE: ${{ github.event.inputs.language }} |
| 156 | + JOB_NAME: ${{ github.event.inputs.jobName }} |
| 157 | + OPTIONS: ${{ github.event.inputs.options }} |
| 158 | + SPEC_URL: ${{ github.event.inputs.specUrl }} |
0 commit comments