|
| 1 | +name: Test Framework V2 PHP |
| 2 | + |
| 3 | +on: |
| 4 | + # execute on demand |
| 5 | + workflow_dispatch: |
| 6 | + branches: ["master"] |
| 7 | + |
| 8 | +jobs: |
| 9 | + |
| 10 | + # builds codegen cli and uploads its artifact |
| 11 | + build-codegen: |
| 12 | + |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + java: [ 8 ] |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v2 |
| 21 | + with: |
| 22 | + ref: 3.0.0 |
| 23 | + - uses: actions/setup-java@v1 |
| 24 | + with: |
| 25 | + java-version: ${{ matrix.java }} |
| 26 | + - name: build codegen |
| 27 | + run: | |
| 28 | + mkdir codegen-cli |
| 29 | + echo "BUILDING ${{ env.VERSION }}" |
| 30 | + mvn -version |
| 31 | + mvn -q -B package -DskipTests -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.count=3 |
| 32 | + cp modules/swagger-codegen-cli/target/swagger-codegen-cli.jar codegen-cli |
| 33 | +
|
| 34 | + mkdir test-cfg-files |
| 35 | + cp -r samples/client/petstore/php/SwaggerClient-php/tests test-cfg-files |
| 36 | + cp samples/client/petstore/php/SwaggerClient-php/autoload.php test-cfg-files |
| 37 | + cp samples/client/petstore/php/SwaggerClient-php/pom.xml test-cfg-files |
| 38 | + cp samples/client/petstore/php/SwaggerClient-php/phpcs-generated-code.xml test-cfg-files |
| 39 | + - name: upload codegen cli |
| 40 | + uses: actions/upload-artifact@v2 |
| 41 | + with: |
| 42 | + name: codegen-cli |
| 43 | + path: codegen-cli |
| 44 | + - name: upload test cfg file |
| 45 | + uses: actions/upload-artifact@v2 |
| 46 | + with: |
| 47 | + name: test-cfg-files |
| 48 | + path: test-cfg-files |
| 49 | + env: |
| 50 | + VERSION: ${{ github.event.inputs.version }} |
| 51 | + |
| 52 | + generate: |
| 53 | + |
| 54 | + |
| 55 | + needs: build-codegen |
| 56 | + |
| 57 | + runs-on: ubuntu-latest |
| 58 | + |
| 59 | + strategy: |
| 60 | + matrix: |
| 61 | + java: [ 8 ] |
| 62 | + |
| 63 | + |
| 64 | + outputs: |
| 65 | + generate_outcome: ${{ steps.outcome.outputs.generate_outcome }} |
| 66 | + |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v2 |
| 69 | + - uses: actions/setup-java@v1 |
| 70 | + with: |
| 71 | + java-version: ${{ matrix.java }} |
| 72 | + - name: Download codegen cli |
| 73 | + uses: actions/download-artifact@v2 |
| 74 | + with: |
| 75 | + name: codegen-cli |
| 76 | + - name: generate |
| 77 | + id: generate |
| 78 | + continue-on-error: true |
| 79 | + uses: ./.github/actions/generate |
| 80 | + with: |
| 81 | + language: php |
| 82 | + job-name: ${{ env.JOB_NAME }} |
| 83 | + spec-url: "https://raw.githubusercontent.com/swagger-api/swagger-codegen/3.0.0/modules/swagger-codegen/src/test/resources/3_0_0/petstore-with-fake-endpoints-models-for-testing.yaml" |
| 84 | + options: " --additional-properties composerVendorName=swagger,composerProjectName=swagger_codegen" |
| 85 | + - id: outcome |
| 86 | + run: | |
| 87 | + echo "::set-output name=generate_outcome::${{ steps.generate.outcome }}" |
| 88 | + echo ${{ steps.generate.outcome }} > generate_outcome_${{ env.JOB_NAME }} |
| 89 | + - name: upload generate outcome |
| 90 | + uses: actions/upload-artifact@v2 |
| 91 | + with: |
| 92 | + name: ${{ env.JOB_NAME }}generate_outcome |
| 93 | + path: generate_outcome_${{ env.JOB_NAME }} |
| 94 | + - name: upload generate logs |
| 95 | + uses: actions/upload-artifact@v2 |
| 96 | + with: |
| 97 | + name: ${{ env.JOB_NAME }}generate_logs |
| 98 | + path: ${{ steps.generate.outputs.logs }} |
| 99 | + - name: upload generated code |
| 100 | + if: contains(steps.generate.outcome, 'success') |
| 101 | + uses: actions/upload-artifact@v2 |
| 102 | + with: |
| 103 | + name: ${{ env.JOB_NAME }}generated |
| 104 | + path: ${{ steps.generate.outputs.path }} |
| 105 | + env: |
| 106 | + JOB_NAME: "php-v3-sample" |
| 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 | + ############################################### |
| 116 | + ##### DYNAMIC: Dependent on build environment |
| 117 | + ############################################### |
| 118 | + matrix: |
| 119 | + java: [ 8 ] |
| 120 | + ############################################### |
| 121 | + ##### END DYNAMIC: Dependent on build environment |
| 122 | + ############################################### |
| 123 | + steps: |
| 124 | + - uses: actions/checkout@v2 |
| 125 | + - name: Download artifacts |
| 126 | + uses: actions/download-artifact@v2 |
| 127 | + with: |
| 128 | + name: ${{ env.JOB_NAME }}generated |
| 129 | + path: generated/${{ env.JOB_NAME }} |
| 130 | + - name: Download logs |
| 131 | + uses: actions/download-artifact@v2 |
| 132 | + with: |
| 133 | + name: ${{ env.JOB_NAME }}generate_logs |
| 134 | + ############################################### |
| 135 | + ##### DYNAMIC: Dependent on build environment |
| 136 | + ############################################### |
| 137 | + - uses: actions/setup-java@v1 |
| 138 | + with: |
| 139 | + java-version: ${{ matrix.java }} |
| 140 | + - name: Download PHP V2 test cfg files |
| 141 | + uses: actions/download-artifact@v2 |
| 142 | + with: |
| 143 | + name: test-cfg-files |
| 144 | + path: generated/SwaggerClient-php/${{ env.JOB_NAME }} |
| 145 | + - name: Setup PHP with composer v2 |
| 146 | + uses: shivammathur/setup-php@v2 |
| 147 | + with: |
| 148 | + php-version: '7.4' |
| 149 | + tools: composer:v2 |
| 150 | + ############################################### |
| 151 | + ##### END DYNAMIC: Dependent on build environment |
| 152 | + ############################################### |
| 153 | + - name: build |
| 154 | + id: build |
| 155 | + uses: ./.github/actions/build |
| 156 | + continue-on-error: true |
| 157 | + with: |
| 158 | + path: generated/${{ env.JOB_NAME }}/SwaggerClient-php |
| 159 | + job-name: ${{ env.JOB_NAME }} |
| 160 | + build-commands: "composer install__&&__./vendor/bin/phpunit test" |
| 161 | + - id: outcome |
| 162 | + run: | |
| 163 | + echo "::set-output name=build_outcome::${{ steps.build.outcome }}" |
| 164 | + echo ${{ steps.build.outcome }} > ${{ env.JOB_NAME }}build_outcome |
| 165 | + - name: upload build outcome |
| 166 | + uses: actions/upload-artifact@v2 |
| 167 | + with: |
| 168 | + name: ${{ env.JOB_NAME }}build_outcome |
| 169 | + path: ${{ env.JOB_NAME }}build_outcome |
| 170 | + - name: upload logs |
| 171 | + uses: actions/upload-artifact@v2 |
| 172 | + with: |
| 173 | + name: ${{ env.JOB_NAME }}logs |
| 174 | + path: ${{ steps.build.outputs.logs }} |
| 175 | + env: |
| 176 | + LANGUAGE: ${{ github.event.inputs.language }} |
| 177 | + JOB_NAME: "php-v3-sample" |
0 commit comments