Skip to content

Commit 0281b99

Browse files
authored
Merge pull request #15 from Chisanan232/develop
🎉🎊🍾 [New Feature + Breaking Change + Refactor] (config + docs) Add new feature, integrate organizing reports features and update document.
2 parents 47b2e82 + 70627c8 commit 0281b99

13 files changed

+297
-266
lines changed

.github/PULL_REQUEST_TEMPLATE/pull_request_template.md renamed to .github/PULL_REQUEST_TEMPLATE.md

File renamed without changes.

.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml

Lines changed: 0 additions & 111 deletions
This file was deleted.

.github/workflows/organize_all_testing_reports_with_different_test_type.yaml

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
############################################################################
2+
#
3+
# Workflow Description:
4+
# Organize all the testing coverage reports. (it would save reports by 'actions/upload-artifact@v3').
5+
#
6+
# Workflow input parameters:
7+
# * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'.
8+
#
9+
# Workflow running output:
10+
# No, but it would save the testing coverage reports (coverage.xml) to provide after-process to organize and record.
11+
#
12+
############################################################################
13+
14+
name: Organize all testing coverage reports which be tested in many different runtime OS and Python version as a testing coverage report
15+
16+
on:
17+
workflow_call:
18+
inputs:
19+
test_type:
20+
description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'."
21+
required: true
22+
type: string
23+
24+
25+
jobs:
26+
organize_and_generate_test_reports:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v2
31+
32+
- name: Download code coverage result file
33+
uses: actions/download-artifact@v3
34+
with:
35+
name: coverage
36+
path: ./
37+
38+
- name: Setup Python 3.10 in Ubuntu OS
39+
uses: actions/setup-python@v2
40+
with:
41+
python-version: '3.10'
42+
43+
- name: Install Python tool 'coverage'
44+
run: |
45+
python3 -m pip install --upgrade pip
46+
pip3 install -U pip
47+
pip3 install coverage
48+
49+
- name: Combine all testing code coverage result files with one specific test type
50+
if: ${{ inputs.test_type == 'unit-test' || inputs.test_type == 'integration-test' }}
51+
run: coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.${{ inputs.test_type }}.*
52+
53+
- name: Combine all testing code coverage result files with all test types
54+
if: ${{ inputs.test_type == 'all-test' }}
55+
run: coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.*
56+
57+
- name: Report testing coverage of project code
58+
run: coverage report -m --data-file=.coverage.${{ inputs.test_type }}
59+
60+
- name: General testing coverage report as XML format with ${{ inputs.test_type }}
61+
run: coverage xml --data-file=.coverage.${{ inputs.test_type }} -o coverage_${{ inputs.test_type }}.xml
62+
63+
- name: Upload testing coverage report
64+
uses: actions/upload-artifact@v3
65+
with:
66+
name: final_project_testing_coverage_report
67+
path: coverage_${{ inputs.test_type }}.xml
68+
if-no-files-found: error

.github/workflows/run_test_items_via_pytest.yaml

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
# Workflow input parameters:
88
# * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'.
99
# * all_test_items_paths: The target paths of test items under test.
10+
# * setup_http_server: If it's true, it would set up and run HTTP server for testing.
11+
# * http_server_host: The host IPv4 address of HTTP server.
12+
# * http_server_port: The port number of HTTP server.
13+
# * http_server_app_module: The module path of HTTP server.
14+
# * http_server_enter_point: The object about the web application.
1015
#
1116
# Workflow running output:
1217
# No, but it would save the testing coverage reports to provide after-process to organize and record.
@@ -26,6 +31,31 @@ on:
2631
description: "The target paths of test items under test."
2732
required: true
2833
type: string
34+
setup_http_server:
35+
description: "If it's true, it would set up and run HTTP server for testing."
36+
type: boolean
37+
required: false
38+
default: false
39+
http_server_host:
40+
description: "The host IPv4 address of HTTP server."
41+
type: string
42+
required: false
43+
default: 0.0.0.0
44+
http_server_port:
45+
description: "The port number of HTTP server."
46+
type: string
47+
required: false
48+
default: 12345
49+
http_server_app_module:
50+
description: "The module path of HTTP server."
51+
type: string
52+
required: false
53+
default: app
54+
http_server_enter_point:
55+
description: "The object about the web application."
56+
type: string
57+
required: false
58+
default: app
2959

3060

3161
jobs:
@@ -69,19 +99,21 @@ jobs:
6999
with:
70100
python-version: ${{ matrix.python-version }}
71101

72-
# - name: Install dependencies by cloning from GitHub MultiRunnable
73-
# run: |
74-
# git clone https://github.com/Chisanan232/multirunnable.git -b master ./multirunnable
75-
# sudo python ./multirunnable/setup.py install
76-
# pip install -r ./multirunnable/dev-requirements.txt
77-
78102
- name: Install Python dependencies
79103
run: |
80104
python -m pip install --upgrade pip
81105
pip install -U pip
82106
pip install -U -r ./requirements/requirements.txt
83107
pip install -U -r ./requirements/requirements-test.txt
84108
109+
- name: Setup and run HTTP server for testing
110+
if: ${{ inputs.setup_http_server == true }}
111+
run: gunicorn --bind ${{ inputs.http_server_host }}:${{ inputs.http_server_port }} '${{ inputs.http_server_app_module }}:${{ inputs.http_server_enter_point }}' --daemon
112+
113+
- name: Test to send HTTP request to sample HTTP server
114+
if: ${{ inputs.setup_http_server == true }}
115+
run: curl "http://${{ inputs.http_server_host }}:${{ inputs.http_server_port }}/exchangeReport/STOCK_DAY?response=json&date=20170101&stockNo=2331"
116+
85117
- name: Run tests with pytest
86118
run: pytest ${{ matrix.test-path }}
87119
continue-on-error: true

.github/workflows/test-reusable-workflows.yaml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,37 @@ jobs:
5858
with:
5959
test_type: integration-test
6060
all_test_items_paths: ${{needs.prep-testbed_integration-test.outputs.all_test_items}}
61+
setup_http_server: true
62+
http_server_host: 0.0.0.0
63+
http_server_port: 30303
64+
http_server_app_module: test._http_server.app
65+
http_server_enter_point: app
6166

6267

6368
unit-test_codecov:
6469
# name: Organize and generate the testing report and upload it to Codecov
6570
needs: run_unit-test
66-
uses: ./.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml
71+
uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml
6772
with:
6873
test_type: unit-test
69-
generate_xml_report_finally: false
74+
# generate_xml_report_finally: false
7075

7176

7277
integration-test_codecov:
7378
# name: Organize and generate the testing report and upload it to Codecov
7479
needs: run_integration-test
75-
uses: ./.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml
80+
uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml
7681
with:
7782
test_type: integration-test
78-
generate_xml_report_finally: false
83+
# generate_xml_report_finally: false
7984

8085

8186
organize_all-test_codecov_and_generate_report:
8287
# name: Organize and generate the testing report and upload it to Codecov
8388
needs: [unit-test_codecov, integration-test_codecov]
84-
uses: ./.github/workflows/organize_all_testing_reports_with_different_test_type.yaml
89+
uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml
90+
with:
91+
test_type: all-test
8592

8693

8794
codecov_finish:
@@ -93,18 +100,20 @@ jobs:
93100
codecov_token: ${{ secrets.CODECOV_TOKEN }}
94101
with:
95102
download_path: ./
103+
test_type: all-test
96104
codecov_flags: unit,integration
97105
codecov_name: smoothcrawler-appintegration_github-actions_test # optional
98106

99107

100108
codacy_finish:
101109
# name: Upload test report to Codacy to analyse and record code quality
102-
needs: [codecov_finish]
110+
needs: organize_all-test_codecov_and_generate_report
103111
uses: ./.github/workflows/upload_code_report_to_codacy.yaml
104112
secrets:
105113
codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }}
106114
with:
107115
download_path: ./
116+
test_type: all-test
108117

109118

110119
# pre-building_check:

0 commit comments

Comments
 (0)