|
1 | | -############################################################################ |
| 1 | +################################################################################################################################# |
2 | 2 | # |
3 | 3 | # Workflow Description: |
4 | 4 | # Run testing by specific type with all test items via PyTest and generate its testing |
|
12 | 12 | # * http_server_port: The port number of HTTP server. |
13 | 13 | # * http_server_app_module: The module path of HTTP server. |
14 | 14 | # * http_server_enter_point: The object about the web application. |
| 15 | +# * debug_mode: For debug, so it's matrix would one has os: ubuntu-22.04 & python-version: '3.10'. |
15 | 16 | # |
16 | 17 | # Workflow running output: |
17 | 18 | # No, but it would save the testing coverage reports to provide after-process to organize and record. |
18 | 19 | # |
19 | | -############################################################################ |
| 20 | +# * Upload-Artifact: |
| 21 | +# * coverage: The test coverage report which be generated by PyTest, and it's recorded after run test done. |
| 22 | +# The file name format would be .coverage.<test type>.<runtime os>-<python-version> |
| 23 | +# |
| 24 | +################################################################################################################################# |
20 | 25 |
|
21 | 26 | name: Run test items via PyTest |
22 | 27 |
|
|
56 | 61 | type: string |
57 | 62 | required: false |
58 | 63 | default: app |
| 64 | + debug_mode: |
| 65 | + description: "For debug, so it's matrix would one has os: ubuntu-22.04 & python-version: '3.10'." |
| 66 | + type: boolean |
| 67 | + required: false |
| 68 | + default: false |
59 | 69 |
|
60 | 70 |
|
61 | 71 | jobs: |
62 | 72 | run_test_items: |
| 73 | + if: ${{ inputs.debug_mode == false }} |
63 | 74 | runs-on: ${{ matrix.os }} |
64 | 75 |
|
65 | 76 | strategy: |
66 | 77 | matrix: |
67 | 78 | python-version: [3.6,3.7,3.8,3.9,'3.10'] |
68 | | - os: [ubuntu-18.04,ubuntu-20.04,ubuntu-22.04, macos-10.15,macos-11,macos-12] |
| 79 | + os: [ubuntu-18.04,ubuntu-20.04,ubuntu-22.04,macos-10.15,macos-11,macos-12] |
69 | 80 | exclude: |
70 | 81 | - os: ubuntu-18.04 |
71 | 82 | python-version: 3.6 |
@@ -128,3 +139,50 @@ jobs: |
128 | 139 | path: .coverage.${{ inputs.test_type }}.${{ matrix.os }}-${{ matrix.python-version }} |
129 | 140 | if-no-files-found: error |
130 | 141 |
|
| 142 | + |
| 143 | + run_test_items_with_debug_mode: |
| 144 | + if: ${{ inputs.debug_mode == true }} |
| 145 | + runs-on: ${{ matrix.os }} |
| 146 | + |
| 147 | + strategy: |
| 148 | + matrix: |
| 149 | + python-version: ['3.10'] |
| 150 | + os: [ubuntu-22.04] |
| 151 | + test-path: ${{fromJson(inputs.all_test_items_paths)}} |
| 152 | + |
| 153 | + steps: |
| 154 | + - uses: actions/checkout@v2 |
| 155 | + |
| 156 | + - name: Install Python ${{ matrix.python-version }} |
| 157 | + uses: actions/setup-python@v2 |
| 158 | + with: |
| 159 | + python-version: ${{ matrix.python-version }} |
| 160 | + |
| 161 | + - name: Install Python dependencies |
| 162 | + run: | |
| 163 | + python -m pip install --upgrade pip |
| 164 | + pip install -U pip |
| 165 | + pip install -U -r ./requirements/requirements.txt |
| 166 | + pip install -U -r ./requirements/requirements-test.txt |
| 167 | +
|
| 168 | + - name: Setup and run HTTP server for testing |
| 169 | + if: ${{ inputs.setup_http_server == true }} |
| 170 | + run: gunicorn --bind ${{ inputs.http_server_host }}:${{ inputs.http_server_port }} '${{ inputs.http_server_app_module }}:${{ inputs.http_server_enter_point }}' --daemon |
| 171 | + |
| 172 | + - name: Test to send HTTP request to sample HTTP server |
| 173 | + if: ${{ inputs.setup_http_server == true }} |
| 174 | + run: curl "http://${{ inputs.http_server_host }}:${{ inputs.http_server_port }}/exchangeReport/STOCK_DAY?response=json&date=20170101&stockNo=2331" |
| 175 | + |
| 176 | + - name: Run tests with pytest |
| 177 | + run: pytest ${{ matrix.test-path }} |
| 178 | + continue-on-error: true |
| 179 | + |
| 180 | + - name: Rename the code coverage result file |
| 181 | + run: mv ./.coverage ./.coverage.${{ inputs.test_type }}.${{ matrix.os }}-${{ matrix.python-version }} |
| 182 | + |
| 183 | + - name: Upload code coverage result file |
| 184 | + uses: actions/upload-artifact@v3 |
| 185 | + with: |
| 186 | + name: coverage |
| 187 | + path: .coverage.${{ inputs.test_type }}.${{ matrix.os }}-${{ matrix.python-version }} |
| 188 | + if-no-files-found: error |
0 commit comments