From f96b3967c3e7834610f788c3474ce18108d244b6 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 23 Aug 2022 07:13:04 +0800 Subject: [PATCH 001/241] [Breaking Change] (config) Change the steps about organizing testing code coverage reports. --- ...orts_with_different_os_and_py_version.yaml | 112 ++++++++++-------- 1 file changed, 60 insertions(+), 52 deletions(-) diff --git a/.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml b/.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml index 506004f9..23ed2901 100644 --- a/.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml +++ b/.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml @@ -22,15 +22,15 @@ on: description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'." required: true type: string - generate_xml_report_finally: - description: "Something, it only has 1 test type currently. So it could let this option to be 'true' than it would generate XML report finally to let uploading process to use it directly." - type: boolean - required: false - default: false +# generate_xml_report_finally: +# description: "Something, it only has 1 test type currently. So it could let this option to be 'true' than it would generate XML report finally to let uploading process to use it directly." +# type: boolean +# required: false +# default: false jobs: - organize_test_reports: + organize_and_generate_test_reports: runs-on: ubuntu-latest steps: - name: Checkout @@ -53,59 +53,67 @@ jobs: pip3 install -U pip pip3 install coverage - - name: Combine all code coverage result files - run: coverage combine .coverage.* + - name: Combine all testing code coverage result files with ${{ inputs.test_type }} + if: ${{ inputs.test_type == 'unit-test' || inputs.test_type == 'integration-test' }} + run: coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.${{ inputs.test_type }}.* - - name: Report testing coverage of project code - run: coverage report -m - - - name: Upload testing coverage report - uses: actions/upload-artifact@v3 - with: - name: project_testing_coverage_report_${{ inputs.test_type }} - path: .coverage - if-no-files-found: error + - name: Combine all testing code coverage result files with all test types + if: ${{ inputs.test_type == 'all-test' }} + run: coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.* - generate_final_test_report: - if: ${{ inputs.generate_xml_report_finally == true }} -# if: inputs.generate_xml_report_finally == 'true' - needs: organize_test_reports - runs-on: ubuntu-latest - steps: - - name: Download code coverage result file - uses: actions/download-artifact@v3 - with: - name: project_testing_coverage_report_${{ inputs.test_type }} - path: ./ + - name: Report testing coverage of project code + run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} - - name: General testing coverage report as XML format - run: coverage xml + - name: General testing coverage report as XML format with ${{ inputs.test_type }} + run: coverage xml --data-file=.coverage.${{ inputs.test_type }} -o coverage_${{ inputs.test_type }}.xml - name: Upload testing coverage report uses: actions/upload-artifact@v3 with: name: final_project_testing_coverage_report - path: coverage.xml + path: coverage_${{ inputs.test_type }}.xml if-no-files-found: error - generate_test_type_report: - if: ${{ inputs.generate_xml_report_finally == false }} -# if: inputs.generate_xml_report_finally == 'false' - needs: organize_test_reports - runs-on: ubuntu-latest - steps: - - name: Download code coverage result file - uses: actions/download-artifact@v3 - with: - name: project_testing_coverage_report_${{ inputs.test_type }} - path: ./ - - - name: Rename the testing coverage report with test type - run: mv .coverage .coverage-${{ inputs.test_type }} - - - name: Upload testing coverage report - uses: actions/upload-artifact@v3 - with: - name: new_project_testing_coverage_report_${{ inputs.test_type }} - path: .coverage-${{ inputs.test_type }} - if-no-files-found: error +# generate_final_test_report: +# if: ${{ inputs.generate_xml_report_finally == true }} +## if: inputs.generate_xml_report_finally == 'true' +# needs: organize_test_reports +# runs-on: ubuntu-latest +# steps: +# - name: Download code coverage result file +# uses: actions/download-artifact@v3 +# with: +# name: project_testing_coverage_report_${{ inputs.test_type }} +# path: ./ +# +# - name: General testing coverage report as XML format +# run: coverage xml --data-file=.coverage_test -o coverage_test.xml +# +# - name: Upload testing coverage report +# uses: actions/upload-artifact@v3 +# with: +# name: final_project_testing_coverage_report +# path: coverage.xml +# if-no-files-found: error + +# generate_test_type_report: +# if: ${{ inputs.generate_xml_report_finally == false }} +## if: inputs.generate_xml_report_finally == 'false' +# needs: organize_test_reports +# runs-on: ubuntu-latest +# steps: +# - name: Download code coverage result file +# uses: actions/download-artifact@v3 +# with: +# name: project_testing_coverage_report_${{ inputs.test_type }} +# path: ./ +# +# - name: Rename the testing coverage report with test type +# run: mv .coverage .coverage-${{ inputs.test_type }} +# +# - name: Upload testing coverage report +# uses: actions/upload-artifact@v3 +# with: +# name: new_project_testing_coverage_report_${{ inputs.test_type }} +# path: .coverage-${{ inputs.test_type }} +# if-no-files-found: error From 15b2766d650ae3198f8693e8769cd27c90e3fc27 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 23 Aug 2022 07:14:51 +0800 Subject: [PATCH 002/241] [New Feature] (config) Add reusable workflow input parameters about docker operators. --- .../workflows/run_test_items_via_pytest.yaml | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index 6d640385..a893cb1a 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -26,6 +26,29 @@ on: description: "The target paths of test items under test." required: true type: string + dockerfile: + description: "The file path of Dockerfile." + required: false + type: string + docker_container_name: + description: "The name of docker container." + required: false + default: gh_ci_container + type: string + docker_cmd_options: + description: "The command options of 'docker run'." + required: false + type: string + docker_image_tag: + description: "The tag of image which be built by Dockerfile." + required: false + default: gh_ci_container:v0 + type: string + docker_context_path: + description: "The path where is the context path of Dockerfile." + required: false + default: ./ + type: string jobs: @@ -64,6 +87,18 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Build Docker image via Dockerfile + if: ${{ inputs.dockerfile }} + run: | + docker build -t ${{ inputs.docker_image_tag }} ${{ inputs.docker_context_path }} -f ${{ inputs.dockerfile }} + docker images + + - name: Run docker container with docker image + if: ${{ inputs.dockerfile }} + run: | + docker run --name ${{ inputs.docker_container_name }} ${{ inputs.docker_cmd_options }} -d ${{ inputs.docker_image_tag }} + docker ps -a + - name: Install Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: From 019bdcb577b6e377c0645728ed24d7ac1c523fe3 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 23 Aug 2022 07:16:09 +0800 Subject: [PATCH 003/241] [Breaking Change] (config) Add workflow input parameter about test type to get the final testing code coverage report. --- .github/workflows/upload_test_report_to_codecov.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 6912f550..6fbae604 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -26,6 +26,10 @@ on: description: "The path to download testing coverage reports via 'actions/download-artifact@v3'." required: true type: string + test_type: + description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'." + required: true + type: string codecov_flags: description: "The flags of the testing coverage report for Codecov." required: true @@ -58,7 +62,8 @@ jobs: uses: codecov/codecov-action@v3 with: token: ${{ secrets.codecov_token }} # not required for public repos - files: coverage.xml # optional +# files: coverage.xml # optional + files: coverage_${{ inputs.test_type }}.xml # optional flags: ${{ inputs.codecov_flags }} # optional name: ${{ inputs.codecov_name }} # optional fail_ci_if_error: true # optional (default = false) From e334414e2516e595c77eb3c635855ee163459925 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 23 Aug 2022 07:21:11 +0800 Subject: [PATCH 004/241] [Breaking Change] (config + test) Modify the config with currently reusable workflow config. It's has 3 major changes: 1. Add parameters about docker operators at job 'run_integration-test'. 2. Modify the reusable workflow at job 'organize_all-test_codecov_and_generate_report'. 3. Add new input parameter 'test_type' at job 'codecov_finish'. --- .github/workflows/test-reusable-workflows.yaml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 25f1a897..da8c5ade 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -58,6 +58,11 @@ jobs: with: test_type: integration-test all_test_items_paths: ${{needs.prep-testbed_integration-test.outputs.all_test_items}} + dockerfile: sample_Dockerfile + dockerfile_container_name: sample_container + dockerfile_cmd_options: -p 12345:12345 + dockerfile_image_tag: sample:v1 + dockerfile_context_path: ./ unit-test_codecov: @@ -66,7 +71,7 @@ jobs: uses: ./.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml with: test_type: unit-test - generate_xml_report_finally: false +# generate_xml_report_finally: false integration-test_codecov: @@ -75,13 +80,17 @@ jobs: uses: ./.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml with: test_type: integration-test - generate_xml_report_finally: false +# generate_xml_report_finally: false organize_all-test_codecov_and_generate_report: # name: Organize and generate the testing report and upload it to Codecov needs: [unit-test_codecov, integration-test_codecov] - uses: ./.github/workflows/organize_all_testing_reports_with_different_test_type.yaml +# uses: ./.github/workflows/organize_all_testing_reports_with_different_test_type.yaml + uses: ./.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml + with: + test_type: all-test +# generate_xml_report_finally: false codecov_finish: @@ -93,13 +102,14 @@ jobs: codecov_token: ${{ secrets.CODECOV_TOKEN }} with: download_path: ./ + test_type: all-test codecov_flags: unit,integration codecov_name: smoothcrawler-appintegration_github-actions_test # optional codacy_finish: # name: Upload test report to Codacy to analyse and record code quality - needs: [codecov_finish] + needs: organize_all-test_codecov_and_generate_report uses: ./.github/workflows/upload_code_report_to_codacy.yaml secrets: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} From 4df239aa3489a78ec665b970519783fe41c30b46 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 23 Aug 2022 07:21:56 +0800 Subject: [PATCH 005/241] [Breaking Change] (config) Add necessary Python dependency 'flask'. --- requirements/requirements-test.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requirements/requirements-test.txt b/requirements/requirements-test.txt index a059ff3f..cecf7b63 100644 --- a/requirements/requirements-test.txt +++ b/requirements/requirements-test.txt @@ -9,3 +9,6 @@ pytest-rerunfailures >= 10.2 coverage >= 6.2 # In Python 3.6, its latest version supported is 6.2. But it supports 6.4 version in Python 3.10. codecov >= 2.1.12 coveralls >= 3.3.1 + +## For running HTTP server for testing crawling feature of web spider +flask >= 2.2.1 From c4320b97e2a457129353dad1037a2880d996b9e8 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 23 Aug 2022 07:22:22 +0800 Subject: [PATCH 006/241] [New Feature] (test) Add sample HTTP server code. --- test/_http_server/app.py | 63 ++++++++++++++++++++++++++++++++ test/_http_server/test_data.json | 24 ++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 test/_http_server/app.py create mode 100644 test/_http_server/test_data.json diff --git a/test/_http_server/app.py b/test/_http_server/app.py new file mode 100644 index 00000000..489cf8ac --- /dev/null +++ b/test/_http_server/app.py @@ -0,0 +1,63 @@ +""" +A simple HTTP server for testing. It would return a JSON type data. +""" + +from flask import Flask, request + + +_app: Flask = Flask(__name__) + + +@_app.route("/exchangeReport/STOCK_DAY", methods=["GET"]) +def get_stock_data() -> str: + """ + API: /exchangeReport/STOCK_DAY + API Parameters: + * response: The data format. Default is JSON type. + * date: The date of data. + * stockNo: The stock symbol no. + + Example: + http://10.20.23.3:12345/exchangeReport/STOCK_DAY?response=json&date=20170101&stockNo=2330 + + :return: A string type data with JSON type format. + """ + + _response = request.args.get("response", "json") + _date = request.args.get("date", None) # Example: 20170101 + _stockNo = request.args.get("stockNo", None) # Example: 2330 + + _data = '{' \ + '"stat":"OK",' \ + f'"date":"{_date}",' \ + f'"title":"111年06月 {_stockNo} 台積電 各日成交資訊",' \ + '"fields":["日期","成交股數","成交金額","開盤價","最高價","最低價","收盤價","漲跌價差","成交筆數"],' \ + '"data":[' \ + '["111/06/01","32,970,903","18,171,598,472","550.00","555.00","548.00","549.00","-11.00","33,456"],' \ + '["111/06/02","26,063,495","14,122,936,388","544.00","545.00","540.00","540.00","-9.00","30,042"],' \ + '["111/06/06","23,732,327","12,843,324,209","541.00","544.00","538.00","540.00"," 0.00","16,614"],' \ + '["111/06/07","22,152,512","11,846,386,906","535.00","538.00","532.00","535.00","-5.00","28,586"],' \ + '["111/06/08","19,609,522","10,636,701,303","539.00","545.00","538.00","544.00","+9.00","18,487"],' \ + '["111/06/09","16,894,479","9,115,934,006","538.00","542.00","537.00","541.00","-3.00","18,802"],' \ + '["111/06/10","22,614,596","12,011,615,014","530.00","533.00","529.00","530.00","-11.00","44,802"],' \ + '["111/06/13","36,758,925","18,998,155,460","518.00","519.00","515.00","516.00","-14.00","112,023"],' \ + '["111/06/14","38,838,778","19,813,036,892","507.00","514.00","507.00","513.00","-3.00","85,483"],' \ + '["111/06/15","38,360,508","19,580,150,319","508.00","515.00","508.00","509.00","-4.00","72,687"],' \ + '["111/06/16","31,908,028","16,331,470,764","515.00","516.00","507.00","508.00","X0.00","42,177"],' \ + '["111/06/17","48,400,798","24,260,277,915","499.50","503.00","499.00","501.00","-7.00","119,618"],' \ + '["111/06/20","36,664,463","18,267,359,790","500.00","502.00","495.00","498.00","-3.00","89,541"],' \ + '["111/06/21","34,432,537","17,298,234,720","501.00","505.00","499.00","505.00","+7.00","32,427"],' \ + '["111/06/22","33,438,921","16,630,857,096","501.00","503.00","494.50","494.50","-10.50","81,024"],' \ + '["111/06/23","46,808,462","22,836,692,325","492.00","493.50","485.00","485.50","-9.00","104,661"],' \ + '["111/06/24","29,003,676","14,184,287,155","489.50","492.50","485.50","486.50","+1.00","43,609"],' \ + '["111/06/27","38,684,368","19,379,396,938","496.00","506.00","495.50","498.50","+12.00","37,438"],' \ + '["111/06/28","16,867,955","8,392,290,378","496.00","500.00","496.00","497.50","-1.00","18,988"],' \ + '["111/06/29","33,124,986","16,352,376,816","496.00","498.50","491.00","491.00","-6.50","40,024"],' \ + '["111/06/30","49,820,824","23,900,613,642","484.50","486.50","476.00","476.00","-15.00","111,117"]' \ + '],' \ + '"notes":["符號說明:+/-/X表示漲/跌/不比價","當日統計資訊含一般、零股、盤後定價、鉅額交易,不含拍賣、標購。","ETF證券代號第六碼為K、M、S、C者,表示該ETF以外幣交易。"]' \ + '}' + return _data + + +_app.run(host="0.0.0.0", port=12345, debug=True) diff --git a/test/_http_server/test_data.json b/test/_http_server/test_data.json new file mode 100644 index 00000000..1836797a --- /dev/null +++ b/test/_http_server/test_data.json @@ -0,0 +1,24 @@ +{ + "stat":"OK", + "date":"20220820", + "title":"111年08月 2330 台積電 各日成交資訊", + "fields":["日期","成交股數","成交金額","開盤價","最高價","最低價","收盤價","漲跌價差","成交筆數"], + "data":[ + ["111/08/01","24,991,291","12,569,771,761","506.00","508.00","500.00","504.00","-5.00","26,792"], + ["111/08/02","42,669,591","20,973,293,337","494.00","496.00","488.50","492.00","-12.00","63,879"], + ["111/08/03","29,838,832","14,823,224,632","494.00","501.00","493.00","501.00","+9.00","25,570"], + ["111/08/04","26,589,086","13,279,624,282","499.00","503.00","495.00","500.00","-1.00","27,173"], + ["111/08/05","35,052,642","17,966,410,242","509.00","516.00","507.00","516.00","+16.00","49,928"], + ["111/08/08","20,568,971","10,531,710,250","510.00","515.00","509.00","512.00","-4.00","18,131"], + ["111/08/09","24,370,709","12,372,442,661","507.00","511.00","504.00","510.00","-2.00","25,433"], + ["111/08/10","22,112,239","11,075,581,424","500.00","503.00","499.50","500.00","-10.00","35,188"], + ["111/08/11","24,906,177","12,771,121,611","513.00","514.00","510.00","514.00","+14.00","23,949"], + ["111/08/12","21,343,450","11,016,097,043","515.00","518.00","514.00","517.00","+3.00","21,701"], + ["111/08/15","22,519,886","11,755,494,600","520.00","524.00","519.00","523.00","+6.00","27,372"], + ["111/08/16","21,234,122","11,141,160,337","526.00","526.00","523.00","525.00","+2.00","20,628"], + ["111/08/17","28,461,939","14,943,047,011","524.00","527.00","521.00","527.00","+2.00","26,466"], + ["111/08/18","18,721,898","9,734,756,997","520.00","521.00","519.00","520.00","-7.00","24,209"], + ["111/08/19","14,235,983","7,403,584,002","519.00","523.00","517.00","519.00","-1.00","14,069"] + ], + "notes":["符號說明:+/-/X表示漲/跌/不比價","當日統計資訊含一般、零股、盤後定價、鉅額交易,不含拍賣、標購。","ETF證券代號第六碼為K、M、S、C者,表示該ETF以外幣交易。"] +} \ No newline at end of file From e4a6664af0d90e8ad865d9d5c38f338434b193c1 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 23 Aug 2022 07:22:48 +0800 Subject: [PATCH 007/241] [New Feature] (config) Add sample Dockerfile for testing. --- sample_Dockerfile | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 sample_Dockerfile diff --git a/sample_Dockerfile b/sample_Dockerfile new file mode 100644 index 00000000..fa6047c6 --- /dev/null +++ b/sample_Dockerfile @@ -0,0 +1,29 @@ +################################################################### +# +# Description: +# Build and run HTTP server for testing +# +################################################################### + +FROM python:3.10 + +WORKDIR ./sample-project/ + +# # Prepare the runtime environment for Python +RUN pip install -U pip + +# # Install the Python dependencies for development +COPY ./requirements/requirements-test.txt ./requirements/ + +RUN pip install -U -r ./requirements/requirements-test.txt + +# # Install some internet tool for debug if it needs +RUN apt-get update && \ + apt-get install -y iputils-ping && \ + apt-get install -y net-tools && \ + apt-get install --no-install-recommends --assume-yes netcat + +# # Copy package code, testing code and scripts to container +COPY ./test/ ./test/ + +CMD python3 ./test/_http_server/app.py From cc66db3ceab7e114ef2cf25c54df4aceeecaad01 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 23 Aug 2022 07:24:46 +0800 Subject: [PATCH 008/241] [Bug Fix] (config) Fix the issue about incorrect input parameters name. --- .github/workflows/test-reusable-workflows.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index da8c5ade..ebfff3b3 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -59,10 +59,10 @@ jobs: test_type: integration-test all_test_items_paths: ${{needs.prep-testbed_integration-test.outputs.all_test_items}} dockerfile: sample_Dockerfile - dockerfile_container_name: sample_container - dockerfile_cmd_options: -p 12345:12345 - dockerfile_image_tag: sample:v1 - dockerfile_context_path: ./ + docker_container_name: sample_container + docker_cmd_options: -p 12345:12345 + docker_image_tag: sample:v1 + docker_context_path: ./ unit-test_codecov: From 4fedb4f51957b76d8df9d0dfa4fbc6251098575c Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 23 Aug 2022 22:14:54 +0800 Subject: [PATCH 009/241] [Bug Fix + Test] (config) Modify the steps about setup and running a sample HTTP server and its related configurations. --- .../workflows/run_test_items_via_pytest.yaml | 30 ++++++++++++------- .../workflows/test-reusable-workflows.yaml | 1 + requirements/requirements-test.txt | 1 + test/_http_server/app.py | 6 ++-- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index a893cb1a..378ef69a 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -26,6 +26,10 @@ on: description: "The target paths of test items under test." required: true type: string + http_server: + description: "If it's true, it would setup and run a sample HTTP server." + required: false + type: boolean dockerfile: description: "The file path of Dockerfile." required: false @@ -87,17 +91,17 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Build Docker image via Dockerfile - if: ${{ inputs.dockerfile }} - run: | - docker build -t ${{ inputs.docker_image_tag }} ${{ inputs.docker_context_path }} -f ${{ inputs.dockerfile }} - docker images - - - name: Run docker container with docker image - if: ${{ inputs.dockerfile }} - run: | - docker run --name ${{ inputs.docker_container_name }} ${{ inputs.docker_cmd_options }} -d ${{ inputs.docker_image_tag }} - docker ps -a +# - name: Build Docker image via Dockerfile +# if: ${{ inputs.dockerfile }} +# run: | +# docker build -t ${{ inputs.docker_image_tag }} ${{ inputs.docker_context_path }} -f ${{ inputs.dockerfile }} +# docker images +# +# - name: Run docker container with docker image +# if: ${{ inputs.dockerfile }} +# run: | +# docker run --name ${{ inputs.docker_container_name }} ${{ inputs.docker_cmd_options }} -d ${{ inputs.docker_image_tag }} +# docker ps -a - name: Install Python ${{ matrix.python-version }} uses: actions/setup-python@v2 @@ -117,6 +121,10 @@ jobs: pip install -U -r ./requirements/requirements.txt pip install -U -r ./requirements/requirements-test.txt + - name: Setup and run HTTP server for testing + if: ${{ inputs.http_server == true }} + run: gunicorn --bind 0.0.0.0:12345 'test._http_server.app:app' + - name: Run tests with pytest run: pytest ${{ matrix.test-path }} continue-on-error: true diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index ebfff3b3..a997ec00 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -58,6 +58,7 @@ jobs: with: test_type: integration-test all_test_items_paths: ${{needs.prep-testbed_integration-test.outputs.all_test_items}} + http_server: true dockerfile: sample_Dockerfile docker_container_name: sample_container docker_cmd_options: -p 12345:12345 diff --git a/requirements/requirements-test.txt b/requirements/requirements-test.txt index cecf7b63..df86823a 100644 --- a/requirements/requirements-test.txt +++ b/requirements/requirements-test.txt @@ -12,3 +12,4 @@ coveralls >= 3.3.1 ## For running HTTP server for testing crawling feature of web spider flask >= 2.2.1 +gunicorn >= 20.1.0 diff --git a/test/_http_server/app.py b/test/_http_server/app.py index 489cf8ac..896856ef 100644 --- a/test/_http_server/app.py +++ b/test/_http_server/app.py @@ -5,10 +5,10 @@ from flask import Flask, request -_app: Flask = Flask(__name__) +app: Flask = Flask(__name__) -@_app.route("/exchangeReport/STOCK_DAY", methods=["GET"]) +@app.route("/exchangeReport/STOCK_DAY", methods=["GET"]) def get_stock_data() -> str: """ API: /exchangeReport/STOCK_DAY @@ -59,5 +59,3 @@ def get_stock_data() -> str: '}' return _data - -_app.run(host="0.0.0.0", port=12345, debug=True) From ad5e684cc8cae6d9571c91b7fe08041016cdc4db Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 23 Aug 2022 22:20:47 +0800 Subject: [PATCH 010/241] [Bug Fix] (config) Fix the issue about some Python dependencies version is too latest to it does not support in Python 3.6. --- requirements/requirements-test.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements/requirements-test.txt b/requirements/requirements-test.txt index df86823a..4cb4d2aa 100644 --- a/requirements/requirements-test.txt +++ b/requirements/requirements-test.txt @@ -11,5 +11,5 @@ codecov >= 2.1.12 coveralls >= 3.3.1 ## For running HTTP server for testing crawling feature of web spider -flask >= 2.2.1 -gunicorn >= 20.1.0 +flask >= 2.0.0 +gunicorn >= 20.0.0 From d6b183b9ce3999c0b8f42b0165ea3c67a2f6ff73 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 23 Aug 2022 22:23:30 +0800 Subject: [PATCH 011/241] [Test] (config) Test configuration. --- .github/workflows/run_test_items_via_pytest.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index 378ef69a..63e829a0 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -28,8 +28,9 @@ on: type: string http_server: description: "If it's true, it would setup and run a sample HTTP server." - required: false type: boolean + required: false + default: false dockerfile: description: "The file path of Dockerfile." required: false From 507360ff14e4dbcdf5620e6934fed28bb558a9fc Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 23 Aug 2022 22:39:19 +0800 Subject: [PATCH 012/241] [New Feature + Test] (config) Add more reusable workflow input parameters about setup HTTP server. --- .../workflows/run_test_items_via_pytest.yaml | 60 +++++++++++++------ 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index 63e829a0..d731c800 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -26,34 +26,54 @@ on: description: "The target paths of test items under test." required: true type: string - http_server: + setup_http_server: description: "If it's true, it would setup and run a sample HTTP server." type: boolean required: false default: false - dockerfile: - description: "The file path of Dockerfile." - required: false + http_server_host: + description: "If it's true, it would setup and run a sample HTTP server." type: string - docker_container_name: - description: "The name of docker container." required: false - default: gh_ci_container + default: 0.0.0.0 + http_server_port: + description: "If it's true, it would setup and run a sample HTTP server." type: string - docker_cmd_options: - description: "The command options of 'docker run'." required: false + default: 12345 + http_server_app_module: + description: "If it's true, it would setup and run a sample HTTP server." type: string - docker_image_tag: - description: "The tag of image which be built by Dockerfile." required: false - default: gh_ci_container:v0 + default: app + http_server_enter_point: + description: "If it's true, it would setup and run a sample HTTP server." type: string - docker_context_path: - description: "The path where is the context path of Dockerfile." required: false - default: ./ - type: string + default: app +# dockerfile: +# description: "The file path of Dockerfile." +# required: false +# type: string +# docker_container_name: +# description: "The name of docker container." +# required: false +# default: gh_ci_container +# type: string +# docker_cmd_options: +# description: "The command options of 'docker run'." +# required: false +# type: string +# docker_image_tag: +# description: "The tag of image which be built by Dockerfile." +# required: false +# default: gh_ci_container:v0 +# type: string +# docker_context_path: +# description: "The path where is the context path of Dockerfile." +# required: false +# default: ./ +# type: string jobs: @@ -123,8 +143,12 @@ jobs: pip install -U -r ./requirements/requirements-test.txt - name: Setup and run HTTP server for testing - if: ${{ inputs.http_server == true }} - run: gunicorn --bind 0.0.0.0:12345 'test._http_server.app:app' + if: ${{ inputs.setup_http_server == true }} + run: gunicorn --bind ${{ inputs.http_server_host }}:${{ inputs.http_server_port }} '${{ inputs.http_server_app_module }}:${{ inputs.http_server_enter_point }}'--daemon + + - name: Test to send HTTP request to sample HTTP server + if: ${{ inputs.setup_http_server == true }} + run: curl "http://${{ inputs.http_server_host }}:${{ inputs.http_server_port }}/exchangeReport/STOCK_DAY?response=json&date=20170101&stockNo=2331" - name: Run tests with pytest run: pytest ${{ matrix.test-path }} From 93f9e108c64f1b30949cdc0cc67b9eb09d213e9a Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 23 Aug 2022 22:40:21 +0800 Subject: [PATCH 013/241] [Breaking Change + Test] (config) Add some parameters of reusable workflow. --- .github/workflows/test-reusable-workflows.yaml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index a997ec00..02b64367 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -58,12 +58,16 @@ jobs: with: test_type: integration-test all_test_items_paths: ${{needs.prep-testbed_integration-test.outputs.all_test_items}} - http_server: true - dockerfile: sample_Dockerfile - docker_container_name: sample_container - docker_cmd_options: -p 12345:12345 - docker_image_tag: sample:v1 - docker_context_path: ./ + setup_http_server: true + http_server_host: 0.0.0.0 + http_server_port: 30303 + http_server_app_module: test._http_server.app + http_server_enter_point: app +# dockerfile: sample_Dockerfile +# docker_container_name: sample_container +# docker_cmd_options: -p 12345:12345 +# docker_image_tag: sample:v1 +# docker_context_path: ./ unit-test_codecov: From 4b481300e8fbd6ce8b10b0993fc12786f2407c3b Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 23 Aug 2022 22:43:30 +0800 Subject: [PATCH 014/241] [Bug Fix + Test] (config) Fix the command line issue. --- .github/workflows/run_test_items_via_pytest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index d731c800..1a03c66a 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -144,7 +144,7 @@ jobs: - name: Setup and run HTTP server for testing if: ${{ inputs.setup_http_server == true }} - run: gunicorn --bind ${{ inputs.http_server_host }}:${{ inputs.http_server_port }} '${{ inputs.http_server_app_module }}:${{ inputs.http_server_enter_point }}'--daemon + run: gunicorn --bind ${{ inputs.http_server_host }}:${{ inputs.http_server_port }} '${{ inputs.http_server_app_module }}:${{ inputs.http_server_enter_point }}' --daemon - name: Test to send HTTP request to sample HTTP server if: ${{ inputs.setup_http_server == true }} From a60c5c9d4c2ba5a6289dbb5fc75ebc70e2891f9d Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 09:48:25 +0800 Subject: [PATCH 015/241] [Breaking Change] (config) Remove unused input parameter and configuration. --- ...orts_with_different_os_and_py_version.yaml | 53 +------------------ 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml b/.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml index 23ed2901..d1e44b81 100644 --- a/.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml +++ b/.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml @@ -5,8 +5,6 @@ # # Workflow input parameters: # * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'. -# * generate_xml_report_finally: Something, it only has 1 test type currently. So it could let this option -# to be 'true' than it would generate XML report finally to let uploading process to use it directly. # # Workflow running output: # No, but it would save the testing coverage reports (coverage.xml) to provide after-process to organize and record. @@ -22,11 +20,6 @@ on: description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'." required: true type: string -# generate_xml_report_finally: -# description: "Something, it only has 1 test type currently. So it could let this option to be 'true' than it would generate XML report finally to let uploading process to use it directly." -# type: boolean -# required: false -# default: false jobs: @@ -53,7 +46,7 @@ jobs: pip3 install -U pip pip3 install coverage - - name: Combine all testing code coverage result files with ${{ inputs.test_type }} + - name: Combine all testing code coverage result files with one specific test type if: ${{ inputs.test_type == 'unit-test' || inputs.test_type == 'integration-test' }} run: coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.${{ inputs.test_type }}.* @@ -73,47 +66,3 @@ jobs: name: final_project_testing_coverage_report path: coverage_${{ inputs.test_type }}.xml if-no-files-found: error - -# generate_final_test_report: -# if: ${{ inputs.generate_xml_report_finally == true }} -## if: inputs.generate_xml_report_finally == 'true' -# needs: organize_test_reports -# runs-on: ubuntu-latest -# steps: -# - name: Download code coverage result file -# uses: actions/download-artifact@v3 -# with: -# name: project_testing_coverage_report_${{ inputs.test_type }} -# path: ./ -# -# - name: General testing coverage report as XML format -# run: coverage xml --data-file=.coverage_test -o coverage_test.xml -# -# - name: Upload testing coverage report -# uses: actions/upload-artifact@v3 -# with: -# name: final_project_testing_coverage_report -# path: coverage.xml -# if-no-files-found: error - -# generate_test_type_report: -# if: ${{ inputs.generate_xml_report_finally == false }} -## if: inputs.generate_xml_report_finally == 'false' -# needs: organize_test_reports -# runs-on: ubuntu-latest -# steps: -# - name: Download code coverage result file -# uses: actions/download-artifact@v3 -# with: -# name: project_testing_coverage_report_${{ inputs.test_type }} -# path: ./ -# -# - name: Rename the testing coverage report with test type -# run: mv .coverage .coverage-${{ inputs.test_type }} -# -# - name: Upload testing coverage report -# uses: actions/upload-artifact@v3 -# with: -# name: new_project_testing_coverage_report_${{ inputs.test_type }} -# path: .coverage-${{ inputs.test_type }} -# if-no-files-found: error From f267ff356afc4c9477e53cbbaaf04efd231317b4 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 09:55:46 +0800 Subject: [PATCH 016/241] [Breaking Change] (config) Remove unused input parameter and configuration, and add description for new input parameters. --- .../workflows/run_test_items_via_pytest.yaml | 62 +++++-------------- 1 file changed, 16 insertions(+), 46 deletions(-) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index 1a03c66a..f651c63f 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -7,6 +7,12 @@ # Workflow input parameters: # * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'. # * all_test_items_paths: The target paths of test items under test. +# * setup_http_server: If it's true, it would set up and run HTTP server for testing. +# * auto_install_http_server_dependencies: If it's true, it would auto-install the Python dependencies it needs of setup HTTP server. The Python dependencies are 'flask' and 'gunicorn'. +# * http_server_host: The host IPv4 address of HTTP server. +# * http_server_port: The port number of HTTP server. +# * http_server_app_module: The module path of HTTP server. +# * http_server_enter_point: The object about the web application. # # Workflow running output: # No, but it would save the testing coverage reports to provide after-process to organize and record. @@ -27,53 +33,35 @@ on: required: true type: string setup_http_server: - description: "If it's true, it would setup and run a sample HTTP server." + description: "If it's true, it would set up and run HTTP server for testing." + type: boolean + required: false + default: false + auto_install_http_server_dependencies: + description: "If it's true, it would auto-install the Python dependencies it needs of setup HTTP server. The Python dependencies are 'flask' and 'gunicorn'." type: boolean required: false default: false http_server_host: - description: "If it's true, it would setup and run a sample HTTP server." + description: "The host IPv4 address of HTTP server." type: string required: false default: 0.0.0.0 http_server_port: - description: "If it's true, it would setup and run a sample HTTP server." + description: "The port number of HTTP server." type: string required: false default: 12345 http_server_app_module: - description: "If it's true, it would setup and run a sample HTTP server." + description: "The module path of HTTP server." type: string required: false default: app http_server_enter_point: - description: "If it's true, it would setup and run a sample HTTP server." + description: "The object about the web application." type: string required: false default: app -# dockerfile: -# description: "The file path of Dockerfile." -# required: false -# type: string -# docker_container_name: -# description: "The name of docker container." -# required: false -# default: gh_ci_container -# type: string -# docker_cmd_options: -# description: "The command options of 'docker run'." -# required: false -# type: string -# docker_image_tag: -# description: "The tag of image which be built by Dockerfile." -# required: false -# default: gh_ci_container:v0 -# type: string -# docker_context_path: -# description: "The path where is the context path of Dockerfile." -# required: false -# default: ./ -# type: string jobs: @@ -112,29 +100,11 @@ jobs: steps: - uses: actions/checkout@v2 -# - name: Build Docker image via Dockerfile -# if: ${{ inputs.dockerfile }} -# run: | -# docker build -t ${{ inputs.docker_image_tag }} ${{ inputs.docker_context_path }} -f ${{ inputs.dockerfile }} -# docker images -# -# - name: Run docker container with docker image -# if: ${{ inputs.dockerfile }} -# run: | -# docker run --name ${{ inputs.docker_container_name }} ${{ inputs.docker_cmd_options }} -d ${{ inputs.docker_image_tag }} -# docker ps -a - - name: Install Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} -# - name: Install dependencies by cloning from GitHub MultiRunnable -# run: | -# git clone https://github.com/Chisanan232/multirunnable.git -b master ./multirunnable -# sudo python ./multirunnable/setup.py install -# pip install -r ./multirunnable/dev-requirements.txt - - name: Install Python dependencies run: | python -m pip install --upgrade pip From ab908131648b751302fee37575858f9a389716f0 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 09:56:40 +0800 Subject: [PATCH 017/241] [Breaking Change] (config) Add a new input parameter 'test_type'. --- .github/workflows/upload_code_report_to_codacy.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload_code_report_to_codacy.yaml b/.github/workflows/upload_code_report_to_codacy.yaml index 709003e7..259f711a 100644 --- a/.github/workflows/upload_code_report_to_codacy.yaml +++ b/.github/workflows/upload_code_report_to_codacy.yaml @@ -6,6 +6,7 @@ # Workflow input parameters: # * General arguments: # * download_path: The path to download testing coverage reports via 'actions/download-artifact@v3'. +# * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'. # # * Secret arguments: # * codacy_token: The API token for uploading testing coverage report to Codacy. @@ -22,8 +23,13 @@ on: inputs: download_path: description: "The path to download testing coverage reports via 'actions/download-artifact@v3'." - required: true type: string + required: false + default: ./ + test_type: + description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'." + type: string + required: true secrets: codacy_token: @@ -42,7 +48,7 @@ jobs: path: ${{ inputs.download_path }} - name: Generate testing report for Codacy - run: mv ./coverage.xml ./cobertura.xml + run: mv ./coverage_${{ inputs.test_type }}.xml ./cobertura.xml - name: Upload testing report to Codacy uses: codacy/codacy-coverage-reporter-action@v1 From e5eeed9a0d635caf134b386f5f2a037f9e597916 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 09:57:59 +0800 Subject: [PATCH 018/241] [Breaking Change + Test] (config) Remove unused option at job 'run_integration-test' and add new option 'test_type' at job 'codacy_finish'. --- .github/workflows/test-reusable-workflows.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 02b64367..379337e9 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -63,11 +63,6 @@ jobs: http_server_port: 30303 http_server_app_module: test._http_server.app http_server_enter_point: app -# dockerfile: sample_Dockerfile -# docker_container_name: sample_container -# docker_cmd_options: -p 12345:12345 -# docker_image_tag: sample:v1 -# docker_context_path: ./ unit-test_codecov: @@ -120,6 +115,7 @@ jobs: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} with: download_path: ./ + test_type: all-test # pre-building_check: From 36706f1dfb702c3afdb5529467a91e580d8f50c5 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 10:05:14 +0800 Subject: [PATCH 019/241] [Breaking Change] (config) Integrate this workflow feature into another one organizing and generate testing coverage report workflow. --- ...ting_reports_with_different_test_type.yaml | 64 ------------------- 1 file changed, 64 deletions(-) delete mode 100644 .github/workflows/organize_all_testing_reports_with_different_test_type.yaml diff --git a/.github/workflows/organize_all_testing_reports_with_different_test_type.yaml b/.github/workflows/organize_all_testing_reports_with_different_test_type.yaml deleted file mode 100644 index b2a84ef8..00000000 --- a/.github/workflows/organize_all_testing_reports_with_different_test_type.yaml +++ /dev/null @@ -1,64 +0,0 @@ -############################################################################ -# -# Workflow Description: -# Organize all the testing coverage reports. (it would save reports by 'actions/upload-artifact@v3'). -# -# Workflow input parameters: -# No input parameters. -# -# Workflow running output: -# No, but it would save the testing coverage reports (coverage.xml) to provide after-process to organize and record. -# -############################################################################ - -name: Organize all testing coverage reports, e.g., different runtime OS, as a final testing coverage report. - -on: - workflow_call: - - -jobs: - organize_and_generate_test_report: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Download code coverage result file - uses: actions/download-artifact@v3 - with: - name: new_project_testing_coverage_report_unit-test - path: ./ - - - name: Download code coverage result file - uses: actions/download-artifact@v3 - with: - name: new_project_testing_coverage_report_integration-test - path: ./ - - - name: Setup Python 3.10 in Ubuntu OS - uses: actions/setup-python@v2 - with: - python-version: '3.10' - - - name: Install Python tool 'coverage' - run: | - python -m pip install --upgrade pip - pip install -U pip - pip install coverage - - - name: Combine all code coverage result files - run: coverage combine .coverage-* - - - name: Report testing coverage of project code - run: coverage report -m - - - name: Generate testing coverage report as XML file - run: coverage xml - - - name: Upload testing coverage report - uses: actions/upload-artifact@v3 - with: - name: final_project_testing_coverage_report - path: coverage.xml - if-no-files-found: error From a8691c5173d0611aaa8e5ea5ceafc57f5201cf01 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 10:10:17 +0800 Subject: [PATCH 020/241] [Refactor] (config) Rename the reusable workflow name to be more shorter and clear. --- ...> organize_and_generate_testing_coverage_reports.yaml} | 0 .github/workflows/test-reusable-workflows.yaml | 8 +++----- 2 files changed, 3 insertions(+), 5 deletions(-) rename .github/workflows/{organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml => organize_and_generate_testing_coverage_reports.yaml} (100%) diff --git a/.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml b/.github/workflows/organize_and_generate_testing_coverage_reports.yaml similarity index 100% rename from .github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml rename to .github/workflows/organize_and_generate_testing_coverage_reports.yaml diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 379337e9..6a7b43c4 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -68,7 +68,7 @@ jobs: unit-test_codecov: # name: Organize and generate the testing report and upload it to Codecov needs: run_unit-test - uses: ./.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml + uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml with: test_type: unit-test # generate_xml_report_finally: false @@ -77,7 +77,7 @@ jobs: integration-test_codecov: # name: Organize and generate the testing report and upload it to Codecov needs: run_integration-test - uses: ./.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml + uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml with: test_type: integration-test # generate_xml_report_finally: false @@ -86,11 +86,9 @@ jobs: organize_all-test_codecov_and_generate_report: # name: Organize and generate the testing report and upload it to Codecov needs: [unit-test_codecov, integration-test_codecov] -# uses: ./.github/workflows/organize_all_testing_reports_with_different_test_type.yaml - uses: ./.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml + uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml with: test_type: all-test -# generate_xml_report_finally: false codecov_finish: From bd4382909ceb621ff4c8224e33411b39cd58802e Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 10:11:04 +0800 Subject: [PATCH 021/241] [Breaking Change] (config) Modify the naem of reusable workflow. --- .../organize_and_generate_testing_coverage_reports.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/organize_and_generate_testing_coverage_reports.yaml b/.github/workflows/organize_and_generate_testing_coverage_reports.yaml index d1e44b81..8147a92f 100644 --- a/.github/workflows/organize_and_generate_testing_coverage_reports.yaml +++ b/.github/workflows/organize_and_generate_testing_coverage_reports.yaml @@ -11,7 +11,7 @@ # ############################################################################ -name: Organize testing coverage reports as a testing coverage report +name: Organize all testing coverage reports which be tested in many different runtime OS and Python version as a testing coverage report on: workflow_call: From 0957562a8982c66a245896ad6137bd6aa96ad245 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 10:32:01 +0800 Subject: [PATCH 022/241] [Breaking Change] (config) Remove unused parameter. --- .github/workflows/run_test_items_via_pytest.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index f651c63f..c1ef947b 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -8,7 +8,6 @@ # * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'. # * all_test_items_paths: The target paths of test items under test. # * setup_http_server: If it's true, it would set up and run HTTP server for testing. -# * auto_install_http_server_dependencies: If it's true, it would auto-install the Python dependencies it needs of setup HTTP server. The Python dependencies are 'flask' and 'gunicorn'. # * http_server_host: The host IPv4 address of HTTP server. # * http_server_port: The port number of HTTP server. # * http_server_app_module: The module path of HTTP server. @@ -37,11 +36,6 @@ on: type: boolean required: false default: false - auto_install_http_server_dependencies: - description: "If it's true, it would auto-install the Python dependencies it needs of setup HTTP server. The Python dependencies are 'flask' and 'gunicorn'." - type: boolean - required: false - default: false http_server_host: description: "The host IPv4 address of HTTP server." type: string From 6fe3a42bad38c19ceb25605356d6c00d0c05a62f Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 10:51:19 +0800 Subject: [PATCH 023/241] [Breaking Change] (config) Update the document about adding some new info and remove deprecated settings. --- README.md | 120 ++++++++++++++++++++---------------------------------- 1 file changed, 44 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index ce3332c4..4b10a159 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # GitHub Action - Workflow template for Python library [![github-action reusable workflows test](https://github.com/Chisanan232/GitHub-Action-Template-Python/actions/workflows/test-reusable-workflows.yaml/badge.svg)](https://github.com/Chisanan232/GitHub-Action-Template-Python/actions/workflows/test-reusable-workflows.yaml) +[![Release](https://img.shields.io/github/release/Chisanan232/GitHub-Action-Template-Python.svg?label=Release&logo=github)](https://github.com/Chisanan232/GitHub-Action-Template-Python/releases) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?logo=apache)](https://opensource.org/licenses/Apache-2.0) @@ -25,8 +26,7 @@ The usage of each workflow template. * [_prepare_test_items.yaml_](#prepare_test_itemsyaml) * [_run_test_items_via_pytest.yaml_](#run_test_items_via_pytestyaml) -* [_organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml_](#organize_all_testing_coverage_reports_with_different_os_and_py_versionyaml) -* [_organize_all_testing_reports_with_different_test_type.yaml_](#organize_all_testing_reports_with_different_test_typeyaml) +* [_organize_and_generate_testing_coverage_reports.yaml_](#organize_and_generate_testing_coverage_reportsyaml) * [_upload_test_report_to_codecov.yaml_](#upload_test_report_to_codecovyaml) * [_upload_code_report_to_codacy.yaml_](#upload_code_report_to_codacyyaml) @@ -36,10 +36,10 @@ The usage of each workflow template. * Description: Prepare the test items. * Options: -| option name | function content | -|-------------|------------------------------------------------------| -| shell_path | The path shell script for getting the testing items. | -| shell_arg | Input arguments of the shell script. | +| option name | option is optional or required | function content | +|-------------|--------------------------------|------------------------------------------------------| +| shell_path | Required | The path shell script for getting the testing items. | +| shell_arg | Required | Input arguments of the shell script. | * Output: * all_test_items: All the test items it would run. @@ -66,10 +66,15 @@ And we could get this workflow output result via keyword _all_test_items_. * Description: Run testing by specific type with all test items via PyTest and generate its testing coverage report (it would save reports by _actions/upload-artifact@v3_). * Options: -| option name | function content | -|----------------------|--------------------------------------------------------------------------------------------| -| test_type | The testing type. In generally, it only has 2 options: _unit-test_ and _integration-test_. | -| all_test_items_paths | The target paths of test items under test. | +| option name | option is optional or required | function content | +|-------------------------|--------------------------------------|--------------------------------------------------------------------------------------------| +| test_type | Required | The testing type. In generally, it only has 2 options: _unit-test_ and _integration-test_. | +| all_test_items_paths | Required | The target paths of test items under test. | +| setup_http_server | Optional, Default value is _false_ | If it's true, it would set up and run HTTP server for testing. | +| http_server_host | Optional, Default value is _0.0.0.0_ | The host IPv4 address of HTTP server. | +| http_server_port | Optional, Default value is _12345_ | The port number of HTTP server. | +| http_server_app_module | Optional, Default value is _app_ | The module path of HTTP server. | +| http_server_enter_point | Optional, Default value is _app_ | The object about the web application. | * Output: @@ -85,6 +90,11 @@ No, but it would save the testing coverage reports to provide after-process to o with: test_type: unit-test all_test_items_paths: ${{needs.prepare-testing-items_unit-test.outputs.all_test_items}} + setup_http_server: true + http_server_host: 0.0.0.0 + http_server_port: 30303 + http_server_app_module: test._http_server.app + http_server_enter_point: app ``` Please take a look of option _all_test_items_paths_. You could find that it get the input result of @@ -99,19 +109,18 @@ is provided by previous workflow? That is all testing items.
-#### _organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml_ +#### _organize_and_generate_testing_coverage_reports.yaml_ -* Description: Organize all the testing coverage reports. (it would save reports by _actions/upload-artifact@v3_). +* Description: Organize all the testing coverage reports which be generated in different runtime OS with Python version. (it would save reports by _actions/upload-artifact@v3_). * Options: -| option name | function content | -|-----------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| test_type | The testing type. In generally, it only has 2 options: _unit-test_ and _integration-test_. | -| generate_xml_report_finally | Something, it only has 1 test type currently. So it could let this option to be 'true' than it would generate XML report finally to let uploading process to use it directly. | +| option name | option is optional or required | function content | +|-----------------------------|--------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| test_type | Required | The testing type. In generally, it only has 2 options: _unit-test_ and _integration-test_. | * Output: -No, but it would save the testing coverage reports (coverage.xml) to provide after-process to organize and record. +No, but it would save the testing coverage reports (coverage_.xml) to provide after-process to organize and record. * How to use it? @@ -119,59 +128,15 @@ No, but it would save the testing coverage reports (coverage.xml) to provide aft unit-test_codecov: # name: Organize and generate the testing report and upload it to Codecov needs: run_unit-test - uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml@master + uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/organize_and_generate_testing_coverage_reports.yaml@master with: test_type: unit-test - generate_xml_report_finally: true ``` It would upload the organized report via _actions/upload-artifact@v3_. And it doesn't support customize options of _actions/upload-artifact@v3_ currently.
-#### _organize_all_testing_reports_with_different_test_type.yaml_ - -* Description: Organize all the testing coverage reports. (it would save reports by _actions/upload-artifact@v3_). -* Options: - -It has no input parameter. - -* Output: - -No, but it would save the testing coverage reports (coverage.xml) to provide after-process to organize and record. - -* How to use it? - -```yaml - organize_all-test_codecov_and_generate_report: -# name: Organize and generate the testing report and upload it to Codecov - needs: [unit-test_codecov, integration-test_codecov] - uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/organize_all_testing_reports_with_different_test_type.yaml@master -``` - -This workflow is very close with another workflow _organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml_. -But they're different. In a software test, it may have one or more test types it would run to check the software quality. -So let us consider below 2 scenarios: - -First scenario, it has only one test. So the CI workflow would be like below: - - get test items -> run test -> organize and generate testing report - -Second one, it has 2 tests: _Unit test_ and _Integration test_: - - get unit test items -> run unit test -> organize unit test report ------------------------ - |-> organize and generate final test report - get integration test items -> run integration test -> organize integration test report --- - -So it should organize testing coverage reports twice, first time is organizing report with one specific test type, -another one time is organizing these 2 test types reports. -Hence, the different is: -* _organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml_ is the first process to organize testing coverage reports. - And it could set option _generate_xml_report_finally_ as _true_ to let the CI workflow be more clear and simpler if it has only one test type. -* _organize_all_testing_reports_with_different_test_type.yaml_ is the second organizing process if it has 2 more test types in CI workflow. - -
- #### _upload_test_report_to_codecov.yaml_ * Description: Upload the testing coverage reports to Codecov. @@ -181,17 +146,18 @@ It has 2 different types option could use: _General option_: -| option name | function content | -|---------------|-----------------------------------------------------------------------------------| -| download_path | The path to download testing coverage reports via _actions/download-artifact@v3_. | -| codecov_flags | The flags of the testing coverage report for Codecov. | -| codecov_name | The name of the testing coverage report for Codecov. | +| option name | option is optional or required | function content | +|---------------|--------------------------------|--------------------------------------------------------------------------------------------| +| download_path | Required | The path to download testing coverage reports via _actions/download-artifact@v3_. | +| test_type | Required | The testing type. In generally, it only has 2 options: _unit-test_ and _integration-test_. | +| codecov_flags | Required | The flags of the testing coverage report for Codecov. | +| codecov_name | Required | The name of the testing coverage report for Codecov. | _Secret option_: -| option name | function content | -|---------------|-----------------------------------------------------------------| -| codecov_token | The API token for uploading testing coverage report to Codecov. | +| option name | option is optional or required | function content | +|---------------|--------------------------------|-----------------------------------------------------------------| +| codecov_token | Required | The API token for uploading testing coverage report to Codecov. | * Output: @@ -229,15 +195,16 @@ It has 2 different types option could use: _General option_: -| option name | function content | -|---------------|-----------------------------------------------------------------------------------| -| download_path | The path to download testing coverage reports via _actions/download-artifact@v3_. | +| option name | option is optional or required | function content | +|---------------|--------------------------------|--------------------------------------------------------------------------------------------| +| download_path | Optional | The path to download testing coverage reports via _actions/download-artifact@v3_. | +| test_type | Required | The testing type. In generally, it only has 2 options: _unit-test_ and _integration-test_. | _Secret option_: -| option name | function content | -|--------------|----------------------------------------------------------------| -| codacy_token | The API token for uploading testing coverage report to Codacy. | +| option name | option is optional or required | function content | +|--------------|--------------------------------|----------------------------------------------------------------| +| codacy_token | Required | The API token for uploading testing coverage report to Codacy. | * Output: @@ -256,6 +223,7 @@ Before run this workflow, please make sure testing coverage report is ready. codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} with: download_path: ./ + test_type: all-test ``` * The badges would be generated after this workflow done: From 70627c8a48163ec21d90215507b729e69f1ba8b5 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 11:00:26 +0800 Subject: [PATCH 024/241] [Refactor + Test] (config) Move the PR template file path. --- .../pull_request_template.md => PULL_REQUEST_TEMPLATE.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{PULL_REQUEST_TEMPLATE/pull_request_template.md => PULL_REQUEST_TEMPLATE.md} (100%) diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from .github/PULL_REQUEST_TEMPLATE/pull_request_template.md rename to .github/PULL_REQUEST_TEMPLATE.md From 92389e81807250b232ad8eb4bff42fc420d290e6 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 11:34:13 +0800 Subject: [PATCH 025/241] [Breaking Change] (config) Remove unused configurations. --- .github/workflows/upload_test_report_to_codecov.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 6fbae604..fe6e8d18 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -68,10 +68,3 @@ jobs: name: ${{ inputs.codecov_name }} # optional fail_ci_if_error: true # optional (default = false) verbose: true # optional (default = false) - - - name: Upload testing coverage report - uses: actions/upload-artifact@v3 - with: - name: project_coverage_report - path: coverage.xml - if-no-files-found: error From 32fff8cab4f5c9d47db95ec287bda60d1ac1b8c7 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 11:37:22 +0800 Subject: [PATCH 026/241] [Breaking Change] (config) Modify the CI testing workflow. --- .github/workflows/test-reusable-workflows.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 6a7b43c4..6dd1f8d5 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -93,7 +93,7 @@ jobs: codecov_finish: # name: Organize and generate the testing report and upload it to Codecov - if: github.ref_name == 'release' || github.ref_name == 'master' +# if: github.ref_name == 'release' || github.ref_name == 'master' needs: organize_all-test_codecov_and_generate_report uses: ./.github/workflows/upload_test_report_to_codecov.yaml secrets: @@ -101,7 +101,7 @@ jobs: with: download_path: ./ test_type: all-test - codecov_flags: unit,integration + codecov_flags: unit,integration,github.ref_name codecov_name: smoothcrawler-appintegration_github-actions_test # optional From d2e5cda5a432d38b0b3f30f3e2b35a57ae07761e Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 11:50:22 +0800 Subject: [PATCH 027/241] [Breaking Change + Test] (config) Add a step about renaming file. --- .github/workflows/test-reusable-workflows.yaml | 2 +- .github/workflows/upload_test_report_to_codecov.yaml | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 6dd1f8d5..5709efd8 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -101,7 +101,7 @@ jobs: with: download_path: ./ test_type: all-test - codecov_flags: unit,integration,github.ref_name + codecov_flags: unit,integration codecov_name: smoothcrawler-appintegration_github-actions_test # optional diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index fe6e8d18..4daf1935 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -58,12 +58,15 @@ jobs: name: final_project_testing_coverage_report path: ${{ inputs.download_path }} + - name: Rename the testing coverage report + run: mv coverage_${{ inputs.test_type }}.xml coverage.xml + - name: Upload coverage report to platform Codecov uses: codecov/codecov-action@v3 with: token: ${{ secrets.codecov_token }} # not required for public repos -# files: coverage.xml # optional - files: coverage_${{ inputs.test_type }}.xml # optional + files: coverage.xml # optional +# files: coverage_${{ inputs.test_type }}.xml # optional flags: ${{ inputs.codecov_flags }} # optional name: ${{ inputs.codecov_name }} # optional fail_ci_if_error: true # optional (default = false) From 4e7393538cdebfb3596392263f913fb86f60ad45 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 12:15:22 +0800 Subject: [PATCH 028/241] [Breaking Change] (config) Add one new option 'max_report_age' to be off. --- codecov.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/codecov.yml b/codecov.yml index b305b67a..570e5a5c 100644 --- a/codecov.yml +++ b/codecov.yml @@ -2,3 +2,4 @@ codecov: token: $CODECOV_TOKEN + max_report_age: off From 2d7535bd656691bc78bb9f0bc2650d3a2110d156 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 13:27:42 +0800 Subject: [PATCH 029/241] [Test] (config) Test for uploading testing coverage reports feature. --- .../workflows/test-reusable-workflows.yaml | 31 ++++++++++++++++++- .../upload_code_report_to_codacy.yaml | 3 +- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 5709efd8..22f1e598 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -85,12 +85,41 @@ jobs: organize_all-test_codecov_and_generate_report: # name: Organize and generate the testing report and upload it to Codecov - needs: [unit-test_codecov, integration-test_codecov] +# needs: [unit-test_codecov, integration-test_codecov] + needs: [run_unit-test, run_integration-test] uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml with: test_type: all-test + unit-codecov_finish: +# name: Organize and generate the testing report and upload it to Codecov +# if: github.ref_name == 'release' || github.ref_name == 'master' + needs: [unit-test_codecov] + uses: ./.github/workflows/upload_test_report_to_codecov.yaml + secrets: + codecov_token: ${{ secrets.CODECOV_TOKEN }} + with: + download_path: ./ + test_type: unit-test + codecov_flags: unit + codecov_name: smoothcrawler-appintegration_github-actions_test # optional + + + integration-codecov_finish: +# name: Organize and generate the testing report and upload it to Codecov +# if: github.ref_name == 'release' || github.ref_name == 'master' + needs: [integration-test_codecov] + uses: ./.github/workflows/upload_test_report_to_codecov.yaml + secrets: + codecov_token: ${{ secrets.CODECOV_TOKEN }} + with: + download_path: ./ + test_type: integration-test + codecov_flags: integration + codecov_name: smoothcrawler-appintegration_github-actions_test # optional + + codecov_finish: # name: Organize and generate the testing report and upload it to Codecov # if: github.ref_name == 'release' || github.ref_name == 'master' diff --git a/.github/workflows/upload_code_report_to_codacy.yaml b/.github/workflows/upload_code_report_to_codacy.yaml index 259f711a..0b4c9684 100644 --- a/.github/workflows/upload_code_report_to_codacy.yaml +++ b/.github/workflows/upload_code_report_to_codacy.yaml @@ -54,5 +54,6 @@ jobs: uses: codacy/codacy-coverage-reporter-action@v1 with: project-token: ${{ secrets.codacy_token }} - coverage-reports: cobertura.xml + coverage-reports: coverage_unit-test.xml,coverage_integration-test.xml +# coverage-reports: cobertura.xml From ad4ed17856b537d1c34594414650a9faeb0385c8 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 13:39:01 +0800 Subject: [PATCH 030/241] [Test] (config) Test for uploading testing coverage reports feature. --- .../upload_test_report_to_codecov.yaml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 4daf1935..45691526 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -62,11 +62,24 @@ jobs: run: mv coverage_${{ inputs.test_type }}.xml coverage.xml - name: Upload coverage report to platform Codecov + if: ${{ inputs.test_type != 'all-test' }} uses: codecov/codecov-action@v3 with: token: ${{ secrets.codecov_token }} # not required for public repos - files: coverage.xml # optional -# files: coverage_${{ inputs.test_type }}.xml # optional +# files: coverage.xml # optional + files: coverage_${{ inputs.test_type }}.xml # optional + flags: ${{ inputs.codecov_flags }} # optional + name: ${{ inputs.codecov_name }} # optional + fail_ci_if_error: true # optional (default = false) + verbose: true # optional (default = false) + + - name: Upload coverage report to platform Codecov + if: ${{ inputs.test_type == 'all-test' }} + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.codecov_token }} # not required for public repos +# files: coverage.xml # optional + files: coverage_unit-test.xml,coverage_integration-test.xml flags: ${{ inputs.codecov_flags }} # optional name: ${{ inputs.codecov_name }} # optional fail_ci_if_error: true # optional (default = false) From b9db386121cafb51d1eff6f91272b58f61fe49bd Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 13:45:11 +0800 Subject: [PATCH 031/241] [Test] (config) Test for uploading testing coverage reports feature. --- .github/workflows/upload_test_report_to_codecov.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 45691526..f06cc80e 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -58,9 +58,6 @@ jobs: name: final_project_testing_coverage_report path: ${{ inputs.download_path }} - - name: Rename the testing coverage report - run: mv coverage_${{ inputs.test_type }}.xml coverage.xml - - name: Upload coverage report to platform Codecov if: ${{ inputs.test_type != 'all-test' }} uses: codecov/codecov-action@v3 From 84b7d84cce8c61d75532e1253307d4c1c16569ad Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 13:51:42 +0800 Subject: [PATCH 032/241] [Test] (config) Test for uploading testing coverage reports feature. --- .github/workflows/upload_test_report_to_codecov.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index f06cc80e..288821c1 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -64,7 +64,7 @@ jobs: with: token: ${{ secrets.codecov_token }} # not required for public repos # files: coverage.xml # optional - files: coverage_${{ inputs.test_type }}.xml # optional + files: ./coverage_${{ inputs.test_type }}.xml # optional flags: ${{ inputs.codecov_flags }} # optional name: ${{ inputs.codecov_name }} # optional fail_ci_if_error: true # optional (default = false) @@ -76,7 +76,7 @@ jobs: with: token: ${{ secrets.codecov_token }} # not required for public repos # files: coverage.xml # optional - files: coverage_unit-test.xml,coverage_integration-test.xml + files: ./coverage_unit-test.xml,./coverage_integration-test.xml flags: ${{ inputs.codecov_flags }} # optional name: ${{ inputs.codecov_name }} # optional fail_ci_if_error: true # optional (default = false) From fa39d5e15155c241bc046b9352a7829c02a738be Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 14:16:24 +0800 Subject: [PATCH 033/241] [Test] (config) Test for uploading testing coverage reports feature. --- .../workflows/test-reusable-workflows.yaml | 52 +++++++++---------- .../upload_test_report_to_codecov.yaml | 2 + 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 22f1e598..1e29f43b 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -92,32 +92,32 @@ jobs: test_type: all-test - unit-codecov_finish: -# name: Organize and generate the testing report and upload it to Codecov -# if: github.ref_name == 'release' || github.ref_name == 'master' - needs: [unit-test_codecov] - uses: ./.github/workflows/upload_test_report_to_codecov.yaml - secrets: - codecov_token: ${{ secrets.CODECOV_TOKEN }} - with: - download_path: ./ - test_type: unit-test - codecov_flags: unit - codecov_name: smoothcrawler-appintegration_github-actions_test # optional - - - integration-codecov_finish: -# name: Organize and generate the testing report and upload it to Codecov -# if: github.ref_name == 'release' || github.ref_name == 'master' - needs: [integration-test_codecov] - uses: ./.github/workflows/upload_test_report_to_codecov.yaml - secrets: - codecov_token: ${{ secrets.CODECOV_TOKEN }} - with: - download_path: ./ - test_type: integration-test - codecov_flags: integration - codecov_name: smoothcrawler-appintegration_github-actions_test # optional +# unit-codecov_finish: +## name: Organize and generate the testing report and upload it to Codecov +## if: github.ref_name == 'release' || github.ref_name == 'master' +# needs: [unit-test_codecov] +# uses: ./.github/workflows/upload_test_report_to_codecov.yaml +# secrets: +# codecov_token: ${{ secrets.CODECOV_TOKEN }} +# with: +# download_path: ./ +# test_type: unit-test +# codecov_flags: unit +# codecov_name: smoothcrawler-appintegration_github-actions_test # optional +# +# +# integration-codecov_finish: +## name: Organize and generate the testing report and upload it to Codecov +## if: github.ref_name == 'release' || github.ref_name == 'master' +# needs: [integration-test_codecov] +# uses: ./.github/workflows/upload_test_report_to_codecov.yaml +# secrets: +# codecov_token: ${{ secrets.CODECOV_TOKEN }} +# with: +# download_path: ./ +# test_type: integration-test +# codecov_flags: integration +# codecov_name: smoothcrawler-appintegration_github-actions_test # optional codecov_finish: diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 288821c1..0b71aa11 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -66,6 +66,7 @@ jobs: # files: coverage.xml # optional files: ./coverage_${{ inputs.test_type }}.xml # optional flags: ${{ inputs.codecov_flags }} # optional + env_vars: OS,PYTHON name: ${{ inputs.codecov_name }} # optional fail_ci_if_error: true # optional (default = false) verbose: true # optional (default = false) @@ -78,6 +79,7 @@ jobs: # files: coverage.xml # optional files: ./coverage_unit-test.xml,./coverage_integration-test.xml flags: ${{ inputs.codecov_flags }} # optional + env_vars: OS,PYTHON name: ${{ inputs.codecov_name }} # optional fail_ci_if_error: true # optional (default = false) verbose: true # optional (default = false) From 30b7c6a652122daab739a6dfd11321b3e96f9e64 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 14:21:29 +0800 Subject: [PATCH 034/241] [Test] (config) Test for uploading testing coverage reports feature. --- .../workflows/test-reusable-workflows.yaml | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 1e29f43b..9366d9cd 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -65,22 +65,22 @@ jobs: http_server_enter_point: app - unit-test_codecov: -# name: Organize and generate the testing report and upload it to Codecov - needs: run_unit-test - uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml - with: - test_type: unit-test -# generate_xml_report_finally: false - - - integration-test_codecov: -# name: Organize and generate the testing report and upload it to Codecov - needs: run_integration-test - uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml - with: - test_type: integration-test -# generate_xml_report_finally: false +# unit-test_codecov: +## name: Organize and generate the testing report and upload it to Codecov +# needs: run_unit-test +# uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml +# with: +# test_type: unit-test +## generate_xml_report_finally: false +# +# +# integration-test_codecov: +## name: Organize and generate the testing report and upload it to Codecov +# needs: run_integration-test +# uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml +# with: +# test_type: integration-test +## generate_xml_report_finally: false organize_all-test_codecov_and_generate_report: From 0a151d2673ba0807ede8063ded55d3ee72b9dfdf Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 14:26:50 +0800 Subject: [PATCH 035/241] [Test] (config) Test for uploading testing coverage reports feature. --- .../workflows/test-reusable-workflows.yaml | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 9366d9cd..34128af9 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -92,38 +92,38 @@ jobs: test_type: all-test -# unit-codecov_finish: -## name: Organize and generate the testing report and upload it to Codecov -## if: github.ref_name == 'release' || github.ref_name == 'master' -# needs: [unit-test_codecov] -# uses: ./.github/workflows/upload_test_report_to_codecov.yaml -# secrets: -# codecov_token: ${{ secrets.CODECOV_TOKEN }} -# with: -# download_path: ./ -# test_type: unit-test -# codecov_flags: unit -# codecov_name: smoothcrawler-appintegration_github-actions_test # optional -# -# -# integration-codecov_finish: -## name: Organize and generate the testing report and upload it to Codecov -## if: github.ref_name == 'release' || github.ref_name == 'master' -# needs: [integration-test_codecov] -# uses: ./.github/workflows/upload_test_report_to_codecov.yaml -# secrets: -# codecov_token: ${{ secrets.CODECOV_TOKEN }} -# with: -# download_path: ./ -# test_type: integration-test -# codecov_flags: integration -# codecov_name: smoothcrawler-appintegration_github-actions_test # optional + unit-codecov_finish: +# name: Organize and generate the testing report and upload it to Codecov +# if: github.ref_name == 'release' || github.ref_name == 'master' + needs: [unit-test_codecov] + uses: ./.github/workflows/upload_test_report_to_codecov.yaml + secrets: + codecov_token: ${{ secrets.CODECOV_TOKEN }} + with: + download_path: ./ + test_type: unit-test + codecov_flags: unit + codecov_name: smoothcrawler-appintegration_github-actions_test # optional + + + integration-codecov_finish: +# name: Organize and generate the testing report and upload it to Codecov +# if: github.ref_name == 'release' || github.ref_name == 'master' + needs: [integration-test_codecov] + uses: ./.github/workflows/upload_test_report_to_codecov.yaml + secrets: + codecov_token: ${{ secrets.CODECOV_TOKEN }} + with: + download_path: ./ + test_type: integration-test + codecov_flags: integration + codecov_name: smoothcrawler-appintegration_github-actions_test # optional codecov_finish: # name: Organize and generate the testing report and upload it to Codecov # if: github.ref_name == 'release' || github.ref_name == 'master' - needs: organize_all-test_codecov_and_generate_report + needs: [unit-codecov_finish, integration-codecov_finish] uses: ./.github/workflows/upload_test_report_to_codecov.yaml secrets: codecov_token: ${{ secrets.CODECOV_TOKEN }} From 0cf6fd3c4a4e22fdf3b69ce8f8630b590812e99c Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 14:28:29 +0800 Subject: [PATCH 036/241] [Test] (config) Test for uploading testing coverage reports feature. --- .../workflows/test-reusable-workflows.yaml | 90 +++++++++---------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 34128af9..37b68533 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -65,65 +65,65 @@ jobs: http_server_enter_point: app -# unit-test_codecov: -## name: Organize and generate the testing report and upload it to Codecov -# needs: run_unit-test -# uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml -# with: -# test_type: unit-test -## generate_xml_report_finally: false -# -# -# integration-test_codecov: -## name: Organize and generate the testing report and upload it to Codecov -# needs: run_integration-test -# uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml -# with: -# test_type: integration-test -## generate_xml_report_finally: false - - - organize_all-test_codecov_and_generate_report: + unit-test_codecov: # name: Organize and generate the testing report and upload it to Codecov -# needs: [unit-test_codecov, integration-test_codecov] - needs: [run_unit-test, run_integration-test] + needs: run_unit-test uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml with: - test_type: all-test - - - unit-codecov_finish: -# name: Organize and generate the testing report and upload it to Codecov -# if: github.ref_name == 'release' || github.ref_name == 'master' - needs: [unit-test_codecov] - uses: ./.github/workflows/upload_test_report_to_codecov.yaml - secrets: - codecov_token: ${{ secrets.CODECOV_TOKEN }} - with: - download_path: ./ test_type: unit-test - codecov_flags: unit - codecov_name: smoothcrawler-appintegration_github-actions_test # optional +# generate_xml_report_finally: false - integration-codecov_finish: + integration-test_codecov: # name: Organize and generate the testing report and upload it to Codecov -# if: github.ref_name == 'release' || github.ref_name == 'master' - needs: [integration-test_codecov] - uses: ./.github/workflows/upload_test_report_to_codecov.yaml - secrets: - codecov_token: ${{ secrets.CODECOV_TOKEN }} + needs: run_integration-test + uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml with: - download_path: ./ test_type: integration-test - codecov_flags: integration - codecov_name: smoothcrawler-appintegration_github-actions_test # optional +# generate_xml_report_finally: false + + +# organize_all-test_codecov_and_generate_report: +## name: Organize and generate the testing report and upload it to Codecov +## needs: [unit-test_codecov, integration-test_codecov] +# needs: [run_unit-test, run_integration-test] +# uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml +# with: +# test_type: all-test + + +# unit-codecov_finish: +## name: Organize and generate the testing report and upload it to Codecov +## if: github.ref_name == 'release' || github.ref_name == 'master' +# needs: [unit-test_codecov] +# uses: ./.github/workflows/upload_test_report_to_codecov.yaml +# secrets: +# codecov_token: ${{ secrets.CODECOV_TOKEN }} +# with: +# download_path: ./ +# test_type: unit-test +# codecov_flags: unit +# codecov_name: smoothcrawler-appintegration_github-actions_test # optional +# +# +# integration-codecov_finish: +## name: Organize and generate the testing report and upload it to Codecov +## if: github.ref_name == 'release' || github.ref_name == 'master' +# needs: [integration-test_codecov] +# uses: ./.github/workflows/upload_test_report_to_codecov.yaml +# secrets: +# codecov_token: ${{ secrets.CODECOV_TOKEN }} +# with: +# download_path: ./ +# test_type: integration-test +# codecov_flags: integration +# codecov_name: smoothcrawler-appintegration_github-actions_test # optional codecov_finish: # name: Organize and generate the testing report and upload it to Codecov # if: github.ref_name == 'release' || github.ref_name == 'master' - needs: [unit-codecov_finish, integration-codecov_finish] + needs: [unit-test_codecov, integration-test_codecov] uses: ./.github/workflows/upload_test_report_to_codecov.yaml secrets: codecov_token: ${{ secrets.CODECOV_TOKEN }} From 61a745e6b4469f4503f486cff3bd829b3015f055 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 14:28:56 +0800 Subject: [PATCH 037/241] [Test] (config) Test for uploading testing coverage reports feature. --- .github/workflows/test-reusable-workflows.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 37b68533..a8d406bb 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -136,7 +136,7 @@ jobs: codacy_finish: # name: Upload test report to Codacy to analyse and record code quality - needs: organize_all-test_codecov_and_generate_report + needs: [unit-test_codecov, integration-test_codecov] uses: ./.github/workflows/upload_code_report_to_codacy.yaml secrets: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} From 63ccca7d4458b18964c2ce566b73fd80bcb38591 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 14:43:23 +0800 Subject: [PATCH 038/241] [Breaking Change] (config) Remove unused step. --- .github/workflows/upload_code_report_to_codacy.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/upload_code_report_to_codacy.yaml b/.github/workflows/upload_code_report_to_codacy.yaml index 0b4c9684..3ae3e19e 100644 --- a/.github/workflows/upload_code_report_to_codacy.yaml +++ b/.github/workflows/upload_code_report_to_codacy.yaml @@ -47,9 +47,6 @@ jobs: name: final_project_testing_coverage_report path: ${{ inputs.download_path }} - - name: Generate testing report for Codacy - run: mv ./coverage_${{ inputs.test_type }}.xml ./cobertura.xml - - name: Upload testing report to Codacy uses: codacy/codacy-coverage-reporter-action@v1 with: From bba28b0b99316d97ebe29c4660c72158cecf94b8 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 15:35:23 +0800 Subject: [PATCH 039/241] [Test] (config) Test for uploading testing coverage reports feature. --- .github/workflows/upload_test_report_to_codecov.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 0b71aa11..a7965e53 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -76,7 +76,6 @@ jobs: uses: codecov/codecov-action@v3 with: token: ${{ secrets.codecov_token }} # not required for public repos -# files: coverage.xml # optional files: ./coverage_unit-test.xml,./coverage_integration-test.xml flags: ${{ inputs.codecov_flags }} # optional env_vars: OS,PYTHON From 65cbfb899c61895f051e1d69b5879bc554119d5f Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 17:07:07 +0800 Subject: [PATCH 040/241] [Test] (config) Test for uploading testing coverage reports feature. --- .github/workflows/upload_test_report_to_codecov.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index a7965e53..f773b534 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -71,12 +71,19 @@ jobs: fail_ci_if_error: true # optional (default = false) verbose: true # optional (default = false) + - name: Rename (for test) + run: mv ./coverage_unit-test.xml ./coverage1.xml + + - name: Rename (for test) + run: mv ./coverage_integration-test.xml ./coverage2.xml + - name: Upload coverage report to platform Codecov if: ${{ inputs.test_type == 'all-test' }} uses: codecov/codecov-action@v3 with: token: ${{ secrets.codecov_token }} # not required for public repos - files: ./coverage_unit-test.xml,./coverage_integration-test.xml +# files: ./coverage_unit-test.xml,./coverage_integration-test.xml + files: ./coverage1.xml,./coverage2.xml # optional flags: ${{ inputs.codecov_flags }} # optional env_vars: OS,PYTHON name: ${{ inputs.codecov_name }} # optional From 28213cef1b8e04195818596408146f7d4422ade9 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 17:13:26 +0800 Subject: [PATCH 041/241] [Test] (config) Test for uploading testing coverage reports feature. --- .github/workflows/upload_test_report_to_codecov.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index f773b534..572699b1 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -82,10 +82,10 @@ jobs: uses: codecov/codecov-action@v3 with: token: ${{ secrets.codecov_token }} # not required for public repos -# files: ./coverage_unit-test.xml,./coverage_integration-test.xml files: ./coverage1.xml,./coverage2.xml # optional - flags: ${{ inputs.codecov_flags }} # optional - env_vars: OS,PYTHON - name: ${{ inputs.codecov_name }} # optional fail_ci_if_error: true # optional (default = false) verbose: true # optional (default = false) +# files: ./coverage_unit-test.xml,./coverage_integration-test.xml +# flags: ${{ inputs.codecov_flags }} # optional +# env_vars: OS,PYTHON # optional +# name: ${{ inputs.codecov_name }} # optional From f88c22589919741e86bcecf5947d7af71175d6a4 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 18:43:43 +0800 Subject: [PATCH 042/241] [Test] (config) Test for another API token. --- .github/workflows/test-reusable-workflows.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index a8d406bb..9140f148 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -126,7 +126,7 @@ jobs: needs: [unit-test_codecov, integration-test_codecov] uses: ./.github/workflows/upload_test_report_to_codecov.yaml secrets: - codecov_token: ${{ secrets.CODECOV_TOKEN }} + codecov_token: ${{ secrets.CODECOV_TOKEN_NEW }} with: download_path: ./ test_type: all-test From c99e5263e5bcedc657e5be164145c97298c25fac Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 18:58:16 +0800 Subject: [PATCH 043/241] [Test] (config) Test for another API token. --- .github/workflows/test-reusable-workflows.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 9140f148..a8d406bb 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -126,7 +126,7 @@ jobs: needs: [unit-test_codecov, integration-test_codecov] uses: ./.github/workflows/upload_test_report_to_codecov.yaml secrets: - codecov_token: ${{ secrets.CODECOV_TOKEN_NEW }} + codecov_token: ${{ secrets.CODECOV_TOKEN }} with: download_path: ./ test_type: all-test From 26a4456a8d76d5722b8e9d312d6abba4ddcf1689 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 19:26:54 +0800 Subject: [PATCH 044/241] [Test] (config) Add processes about setup Python and install Python dependencies. --- .github/workflows/upload_test_report_to_codecov.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 572699b1..1544a7da 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -58,6 +58,18 @@ jobs: name: final_project_testing_coverage_report path: ${{ inputs.download_path }} + - name: Setup Python 3.10 in Ubuntu OS + uses: actions/setup-python@v2 + with: + python-version: '3.10' + + - name: Install Python tool 'coverage' + run: | + python -m pip install --upgrade pip + pip install -U pip + pip install coverage + pip install codecov + - name: Upload coverage report to platform Codecov if: ${{ inputs.test_type != 'all-test' }} uses: codecov/codecov-action@v3 From 4f0d4b02e947ca1dcecfefe6b90716e6d3357a4e Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 19:54:06 +0800 Subject: [PATCH 045/241] [Test] (config) Modify the file paths. --- ...and_generate_testing_coverage_reports.yaml | 9 +++++- .../upload_test_report_to_codecov.yaml | 32 ++++++------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/.github/workflows/organize_and_generate_testing_coverage_reports.yaml b/.github/workflows/organize_and_generate_testing_coverage_reports.yaml index 8147a92f..28babb3b 100644 --- a/.github/workflows/organize_and_generate_testing_coverage_reports.yaml +++ b/.github/workflows/organize_and_generate_testing_coverage_reports.yaml @@ -60,9 +60,16 @@ jobs: - name: General testing coverage report as XML format with ${{ inputs.test_type }} run: coverage xml --data-file=.coverage.${{ inputs.test_type }} -o coverage_${{ inputs.test_type }}.xml - - name: Upload testing coverage report + - name: Upload testing coverage report (.coverage) uses: actions/upload-artifact@v3 with: name: final_project_testing_coverage_report + path: .coverage.${{ inputs.test_type }} + if-no-files-found: error + + - name: Upload testing coverage report (.xml) + uses: actions/upload-artifact@v3 + with: + name: final_project_testing_coverage_xml_report path: coverage_${{ inputs.test_type }}.xml if-no-files-found: error diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 1544a7da..55d662b4 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -58,18 +58,6 @@ jobs: name: final_project_testing_coverage_report path: ${{ inputs.download_path }} - - name: Setup Python 3.10 in Ubuntu OS - uses: actions/setup-python@v2 - with: - python-version: '3.10' - - - name: Install Python tool 'coverage' - run: | - python -m pip install --upgrade pip - pip install -U pip - pip install coverage - pip install codecov - - name: Upload coverage report to platform Codecov if: ${{ inputs.test_type != 'all-test' }} uses: codecov/codecov-action@v3 @@ -83,21 +71,21 @@ jobs: fail_ci_if_error: true # optional (default = false) verbose: true # optional (default = false) - - name: Rename (for test) - run: mv ./coverage_unit-test.xml ./coverage1.xml - - - name: Rename (for test) - run: mv ./coverage_integration-test.xml ./coverage2.xml +# - name: Rename (for test) +# run: mv ./coverage_unit-test.xml ./coverage1.xml +# +# - name: Rename (for test) +# run: mv ./coverage_integration-test.xml ./coverage2.xml - name: Upload coverage report to platform Codecov if: ${{ inputs.test_type == 'all-test' }} uses: codecov/codecov-action@v3 with: token: ${{ secrets.codecov_token }} # not required for public repos - files: ./coverage1.xml,./coverage2.xml # optional +# files: ./coverage_unit-test.xml,./coverage_integration-test.xml + files: ./.coverage_unit-test,./.coverage_integration-test # optional + flags: ${{ inputs.codecov_flags }} # optional + env_vars: OS,PYTHON # optional + name: ${{ inputs.codecov_name }} # optional fail_ci_if_error: true # optional (default = false) verbose: true # optional (default = false) -# files: ./coverage_unit-test.xml,./coverage_integration-test.xml -# flags: ${{ inputs.codecov_flags }} # optional -# env_vars: OS,PYTHON # optional -# name: ${{ inputs.codecov_name }} # optional From 8ef44ff7998131db9767c62d58e628023b1ed65a Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 20:01:42 +0800 Subject: [PATCH 046/241] [Test] (config) Test for uploading testing coverage reports feature. --- .github/workflows/upload_test_report_to_codecov.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 55d662b4..36bbfe2e 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -83,7 +83,7 @@ jobs: with: token: ${{ secrets.codecov_token }} # not required for public repos # files: ./coverage_unit-test.xml,./coverage_integration-test.xml - files: ./.coverage_unit-test,./.coverage_integration-test # optional + files: ./.coverage.unit-test,./.coverage.integration-test # optional flags: ${{ inputs.codecov_flags }} # optional env_vars: OS,PYTHON # optional name: ${{ inputs.codecov_name }} # optional From 5d1a042d391f5fe943be71abb4020ae54ce34e9c Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 21:02:22 +0800 Subject: [PATCH 047/241] [Refactor] (config) Move the testing HTTP server code path. --- {test/_http_server => _http_server}/app.py | 0 {test/_http_server => _http_server}/test_data.json | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {test/_http_server => _http_server}/app.py (100%) rename {test/_http_server => _http_server}/test_data.json (100%) diff --git a/test/_http_server/app.py b/_http_server/app.py similarity index 100% rename from test/_http_server/app.py rename to _http_server/app.py diff --git a/test/_http_server/test_data.json b/_http_server/test_data.json similarity index 100% rename from test/_http_server/test_data.json rename to _http_server/test_data.json From bef713f779cd7aa7ebbea7a9c7fa46b07f00804e Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 21:02:53 +0800 Subject: [PATCH 048/241] [Breaking Change] (config) Modify the testing HTTP server module path. --- .github/workflows/test-reusable-workflows.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index a8d406bb..2dc2b109 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -61,7 +61,7 @@ jobs: setup_http_server: true http_server_host: 0.0.0.0 http_server_port: 30303 - http_server_app_module: test._http_server.app + http_server_app_module: _http_server.app http_server_enter_point: app From 87b20f52520e24d9c5c81068f38e0c0ae4357973 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 21:24:49 +0800 Subject: [PATCH 049/241] [Breaking Change] (config) Modify the version of 'codecov/codecov-action'. --- .github/workflows/upload_test_report_to_codecov.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 36bbfe2e..42613047 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -79,7 +79,7 @@ jobs: - name: Upload coverage report to platform Codecov if: ${{ inputs.test_type == 'all-test' }} - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v3.0.0 with: token: ${{ secrets.codecov_token }} # not required for public repos # files: ./coverage_unit-test.xml,./coverage_integration-test.xml From 9715ccd4fbff19f4359fe77b225cfdf0ed1894f6 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 21:32:19 +0800 Subject: [PATCH 050/241] [Breaking Change] (config) Modify the version of 'codecov/codecov-action'. --- .github/workflows/upload_test_report_to_codecov.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 42613047..60e226d7 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -79,7 +79,7 @@ jobs: - name: Upload coverage report to platform Codecov if: ${{ inputs.test_type == 'all-test' }} - uses: codecov/codecov-action@v3.0.0 + uses: codecov/codecov-action@v2 with: token: ${{ secrets.codecov_token }} # not required for public repos # files: ./coverage_unit-test.xml,./coverage_integration-test.xml From d6da7f06ae7f9c1b9abfdead826c246c30761f95 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 22:11:15 +0800 Subject: [PATCH 051/241] [New Feature + Test] (config) Add new steps about uploading testing coverage reports to Coveralls. --- .../upload_test_report_to_codecov.yaml | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 60e226d7..a22ad51c 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -24,25 +24,34 @@ on: inputs: download_path: description: "The path to download testing coverage reports via 'actions/download-artifact@v3'." - required: true type: string + required: true test_type: description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'." - required: true type: string + required: true codecov_flags: description: "The flags of the testing coverage report for Codecov." - required: true type: string + required: false codecov_name: description: "The name of the testing coverage report for Codecov." - required: true type: string + required: false + coveralls_flag: + description: "The name of the testing coverage report for Codecov." + type: string + required: false secrets: codecov_token: description: "The API token for uploading testing coverage report to Codecov." - required: true + required: false + default: "" + coveralls_token: + description: "The API token for uploading testing coverage report to Coveralls." + required: false + default: "" jobs: @@ -78,8 +87,8 @@ jobs: # run: mv ./coverage_integration-test.xml ./coverage2.xml - name: Upload coverage report to platform Codecov - if: ${{ inputs.test_type == 'all-test' }} - uses: codecov/codecov-action@v2 + if: ${{ secrets.coveralls_token != '' || inputs.test_type == 'all-test' }} + uses: codecov/codecov-action@v3 with: token: ${{ secrets.codecov_token }} # not required for public repos # files: ./coverage_unit-test.xml,./coverage_integration-test.xml @@ -89,3 +98,10 @@ jobs: name: ${{ inputs.codecov_name }} # optional fail_ci_if_error: true # optional (default = false) verbose: true # optional (default = false) + + - name: Upload coverage report to platform Coveralls + if: ${{ secrets.coveralls_token != '' || inputs.test_type == 'all-test' }} + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.coveralls_token }} + flag-name: ${{ secrets.coveralls_flag }} From cd8c76656e817ee79dcc309e6fa292e52bbce167 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 22:11:21 +0800 Subject: [PATCH 052/241] [New Feature + Test] (config) Add new steps about uploading testing coverage reports to Coveralls. --- .github/workflows/upload_test_report_to_codecov.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index a22ad51c..b34d4d59 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -68,7 +68,7 @@ jobs: path: ${{ inputs.download_path }} - name: Upload coverage report to platform Codecov - if: ${{ inputs.test_type != 'all-test' }} + if: ${{ secrets.coveralls_token != '' || inputs.test_type != 'all-test' }} uses: codecov/codecov-action@v3 with: token: ${{ secrets.codecov_token }} # not required for public repos @@ -87,7 +87,7 @@ jobs: # run: mv ./coverage_integration-test.xml ./coverage2.xml - name: Upload coverage report to platform Codecov - if: ${{ secrets.coveralls_token != '' || inputs.test_type == 'all-test' }} + if: ${{ secrets.codecov_token != '' || inputs.test_type == 'all-test' }} uses: codecov/codecov-action@v3 with: token: ${{ secrets.codecov_token }} # not required for public repos From 28f5c2023042972fc2613a41d2e06fc2e0f11359 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 22:12:01 +0800 Subject: [PATCH 053/241] [Breaking Change] (config) Add new job 'coveralls_finish' about uploading testing report to Coveralls. --- .github/workflows/test-reusable-workflows.yaml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 2dc2b109..985e5348 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -130,8 +130,18 @@ jobs: with: download_path: ./ test_type: all-test - codecov_flags: unit,integration - codecov_name: smoothcrawler-appintegration_github-actions_test # optional +# codecov_flags: unit,integration +# codecov_name: smoothcrawler-appintegration_github-actions_test # optional + + + coveralls_finish: +# name: Organize and generate the testing report and upload it to Coveralls +# if: github.ref_name == 'release' || github.ref_name == 'master' + needs: [unit-test_codecov, integration-test_codecov] + uses: ./.github/workflows/upload_test_report_to_codecov.yaml + with: + github-token: ${{ secrets.COVERALLS_TOKEN }} + flag-name: all-test codacy_finish: From f76f3634aecd338ca5a01b0ee5d420f120da4bae Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 22:19:02 +0800 Subject: [PATCH 054/241] [Breaking Change] (config) Fix the issue about incorrect input parameters name. --- .github/workflows/test-reusable-workflows.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 985e5348..c17bbd97 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -140,8 +140,8 @@ jobs: needs: [unit-test_codecov, integration-test_codecov] uses: ./.github/workflows/upload_test_report_to_codecov.yaml with: - github-token: ${{ secrets.COVERALLS_TOKEN }} - flag-name: all-test + codecov_token: ${{ secrets.COVERALLS_TOKEN }} + coveralls_flag: all-test codacy_finish: From f8686f52e386d6162e8e1492881e69e11c1f202b Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 22:20:33 +0800 Subject: [PATCH 055/241] [Breaking Change] (config) Fix the issue about incorrect input parameters settings. --- .github/workflows/test-reusable-workflows.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index c17bbd97..d7af85bc 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -139,8 +139,9 @@ jobs: # if: github.ref_name == 'release' || github.ref_name == 'master' needs: [unit-test_codecov, integration-test_codecov] uses: ./.github/workflows/upload_test_report_to_codecov.yaml - with: + secrets: codecov_token: ${{ secrets.COVERALLS_TOKEN }} + with: coveralls_flag: all-test From d8371e32bed4746f3666823d9ffe671b798a0af3 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 22:21:48 +0800 Subject: [PATCH 056/241] [Breaking Change] (config) Remove unused input parameter. --- .github/workflows/upload_test_report_to_codecov.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index b34d4d59..35a81f94 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -47,11 +47,9 @@ on: codecov_token: description: "The API token for uploading testing coverage report to Codecov." required: false - default: "" coveralls_token: description: "The API token for uploading testing coverage report to Coveralls." required: false - default: "" jobs: From 5b89e102dc8b2e78bb8c7301fafff5fc4c9b915b Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 22:25:00 +0800 Subject: [PATCH 057/241] [Breaking Change] (config) Modify the input parameters. --- .github/workflows/test-reusable-workflows.yaml | 2 ++ .../workflows/upload_test_report_to_codecov.yaml | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index d7af85bc..adc55b2e 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -128,6 +128,7 @@ jobs: secrets: codecov_token: ${{ secrets.CODECOV_TOKEN }} with: + use_codecov: true download_path: ./ test_type: all-test # codecov_flags: unit,integration @@ -142,6 +143,7 @@ jobs: secrets: codecov_token: ${{ secrets.COVERALLS_TOKEN }} with: + use_coveralls: true coveralls_flag: all-test diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 35a81f94..2e37ba4d 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -30,6 +30,16 @@ on: description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'." type: string required: true + use_codecov: + description: "The flags of the testing coverage report for Codecov." + type: boolean + required: false + default: false + use_coveralls: + description: "The flags of the testing coverage report for Codecov." + type: boolean + required: false + default: false codecov_flags: description: "The flags of the testing coverage report for Codecov." type: string @@ -66,7 +76,7 @@ jobs: path: ${{ inputs.download_path }} - name: Upload coverage report to platform Codecov - if: ${{ secrets.coveralls_token != '' || inputs.test_type != 'all-test' }} + if: ${{ inputs.use_codecov == true && inputs.test_type != 'all-test' }} uses: codecov/codecov-action@v3 with: token: ${{ secrets.codecov_token }} # not required for public repos @@ -85,7 +95,7 @@ jobs: # run: mv ./coverage_integration-test.xml ./coverage2.xml - name: Upload coverage report to platform Codecov - if: ${{ secrets.codecov_token != '' || inputs.test_type == 'all-test' }} + if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} uses: codecov/codecov-action@v3 with: token: ${{ secrets.codecov_token }} # not required for public repos From 2ab2278fce3e89408f86e089f3901888c1035d16 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 22:26:05 +0800 Subject: [PATCH 058/241] [Breaking Change] (config) Modify the input parameters. --- .../upload_test_report_to_codecov.yaml | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 2e37ba4d..e5dbb8e1 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -75,18 +75,18 @@ jobs: name: final_project_testing_coverage_report path: ${{ inputs.download_path }} - - name: Upload coverage report to platform Codecov - if: ${{ inputs.use_codecov == true && inputs.test_type != 'all-test' }} - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.codecov_token }} # not required for public repos -# files: coverage.xml # optional - files: ./coverage_${{ inputs.test_type }}.xml # optional - flags: ${{ inputs.codecov_flags }} # optional - env_vars: OS,PYTHON - name: ${{ inputs.codecov_name }} # optional - fail_ci_if_error: true # optional (default = false) - verbose: true # optional (default = false) +# - name: Upload coverage report to platform Codecov +# if: ${{ inputs.use_codecov == true && inputs.test_type != 'all-test' }} +# uses: codecov/codecov-action@v3 +# with: +# token: ${{ secrets.codecov_token }} # not required for public repos +## files: coverage.xml # optional +# files: ./coverage_${{ inputs.test_type }}.xml # optional +# flags: ${{ inputs.codecov_flags }} # optional +# env_vars: OS,PYTHON +# name: ${{ inputs.codecov_name }} # optional +# fail_ci_if_error: true # optional (default = false) +# verbose: true # optional (default = false) # - name: Rename (for test) # run: mv ./coverage_unit-test.xml ./coverage1.xml @@ -95,7 +95,7 @@ jobs: # run: mv ./coverage_integration-test.xml ./coverage2.xml - name: Upload coverage report to platform Codecov - if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} + if: ${{ inputs.use_codecov == true && inputs.test_type == 'all-test' }} uses: codecov/codecov-action@v3 with: token: ${{ secrets.codecov_token }} # not required for public repos @@ -108,7 +108,7 @@ jobs: verbose: true # optional (default = false) - name: Upload coverage report to platform Coveralls - if: ${{ secrets.coveralls_token != '' || inputs.test_type == 'all-test' }} + if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} uses: coverallsapp/github-action@master with: github-token: ${{ secrets.coveralls_token }} From cf155bd895302b0a201ca48afa71e87deda5d893 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 22:27:09 +0800 Subject: [PATCH 059/241] [Breaking Change] (config) Add required input parameters. --- .github/workflows/test-reusable-workflows.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index adc55b2e..b633d1d1 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -144,6 +144,7 @@ jobs: codecov_token: ${{ secrets.COVERALLS_TOKEN }} with: use_coveralls: true + download_path: ./ coveralls_flag: all-test From 804cabb07e524785edb33b0b2f176ed7e1804871 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 22:27:57 +0800 Subject: [PATCH 060/241] test --- .github/workflows/test-reusable-workflows.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index b633d1d1..777b5c80 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -146,6 +146,7 @@ jobs: use_coveralls: true download_path: ./ coveralls_flag: all-test + test_type: all-test codacy_finish: From 8633ba9fcf9af4607575a815f73553b25efae5d2 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 22:37:27 +0800 Subject: [PATCH 061/241] [Bug Fix] (config) Fix the incorrect input parameter. --- .github/workflows/test-reusable-workflows.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 777b5c80..fca46ee6 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -141,7 +141,7 @@ jobs: needs: [unit-test_codecov, integration-test_codecov] uses: ./.github/workflows/upload_test_report_to_codecov.yaml secrets: - codecov_token: ${{ secrets.COVERALLS_TOKEN }} + coveralls_token: ${{ secrets.COVERALLS_TOKEN }} with: use_coveralls: true download_path: ./ From f99e51e491a417a6628ede9b9fa6db9cc3e42b40 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 22:52:13 +0800 Subject: [PATCH 062/241] [Breaking Change + Test] (config) Add a option 'path-to-lcov'. --- .github/workflows/upload_test_report_to_codecov.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index e5dbb8e1..90889e2d 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -112,4 +112,5 @@ jobs: uses: coverallsapp/github-action@master with: github-token: ${{ secrets.coveralls_token }} + path-to-lcov: ./.coverage.integration-test flag-name: ${{ secrets.coveralls_flag }} From 2d674b4f80ccff258ce293cedfcce3bd16fbaea7 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 23:07:30 +0800 Subject: [PATCH 063/241] [New Feature] (config) Add configuration of Coveralls. --- .coveralls.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .coveralls.yml diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 00000000..00fe1db5 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1 @@ +repo_token: $COVERALLS_TOKEN \ No newline at end of file From 1c3aa29356ad4e583d7735146e411a8ca4cb1e64 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 23:07:56 +0800 Subject: [PATCH 064/241] [Breaking Change] (config) Modify the configuration to use command lines. --- .../upload_test_report_to_codecov.yaml | 50 +++++++++++++------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 90889e2d..14a65774 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -75,6 +75,18 @@ jobs: name: final_project_testing_coverage_report path: ${{ inputs.download_path }} + - name: Install Python 3.10 + uses: actions/setup-python@v2 + with: + python-version: "3.10" + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + pip install -U pip + pip install -U codecov + pip install -U coveralls + # - name: Upload coverage report to platform Codecov # if: ${{ inputs.use_codecov == true && inputs.test_type != 'all-test' }} # uses: codecov/codecov-action@v3 @@ -96,21 +108,29 @@ jobs: - name: Upload coverage report to platform Codecov if: ${{ inputs.use_codecov == true && inputs.test_type == 'all-test' }} - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.codecov_token }} # not required for public repos -# files: ./coverage_unit-test.xml,./coverage_integration-test.xml - files: ./.coverage.unit-test,./.coverage.integration-test # optional - flags: ${{ inputs.codecov_flags }} # optional - env_vars: OS,PYTHON # optional - name: ${{ inputs.codecov_name }} # optional - fail_ci_if_error: true # optional (default = false) - verbose: true # optional (default = false) + run: | + codecov -t ${{ secrets.codecov_token }} \ + --file ./.coverage.unit-test,./.coverage.integration-test \ + --flags ${{ inputs.codecov_flags }} \ + --env OS,PYTHON \ + --name ${{ inputs.codecov_name }} \ + --branch github.ref_name +# uses: codecov/codecov-action@v3 +# with: +# token: ${{ secrets.codecov_token }} # not required for public repos +## files: ./coverage_unit-test.xml,./coverage_integration-test.xml +# files: ./.coverage.unit-test,./.coverage.integration-test # optional +# flags: ${{ inputs.codecov_flags }} # optional +# env_vars: OS,PYTHON # optional +# name: ${{ inputs.codecov_name }} # optional +# fail_ci_if_error: true # optional (default = false) +# verbose: true # optional (default = false) - name: Upload coverage report to platform Coveralls if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.coveralls_token }} - path-to-lcov: ./.coverage.integration-test - flag-name: ${{ secrets.coveralls_flag }} + run: coveralls +# uses: coverallsapp/github-action@master +# with: +# github-token: ${{ secrets.coveralls_token }} +# path-to-lcov: ./.coverage.integration-test +# flag-name: ${{ secrets.coveralls_flag }} From 074d0d91cd314121710c3492bfc345d245990d4d Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 23:20:48 +0800 Subject: [PATCH 065/241] [Breaking Change + Test] (config) Fix some issues. --- .github/workflows/upload_test_report_to_codecov.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 14a65774..8fb6f755 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -44,14 +44,17 @@ on: description: "The flags of the testing coverage report for Codecov." type: string required: false + default: '' codecov_name: description: "The name of the testing coverage report for Codecov." type: string required: false + default: '' coveralls_flag: description: "The name of the testing coverage report for Codecov." type: string required: false + default: '' secrets: codecov_token: @@ -86,6 +89,7 @@ jobs: pip install -U pip pip install -U codecov pip install -U coveralls + pip install -U PyYAML # - name: Upload coverage report to platform Codecov # if: ${{ inputs.use_codecov == true && inputs.test_type != 'all-test' }} @@ -128,7 +132,7 @@ jobs: - name: Upload coverage report to platform Coveralls if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} - run: coveralls + run: coveralls --service=github # uses: coverallsapp/github-action@master # with: # github-token: ${{ secrets.coveralls_token }} From 08aba076266598874b28a580ccaebe0a0781d1e9 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 23:29:52 +0800 Subject: [PATCH 066/241] [Debug + Test] (config) Only test and troubleshooting with ubuntu-22.04, macos11 with Python 3.10. --- .github/workflows/run_test_items_via_pytest.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index c1ef947b..a3918074 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -64,8 +64,10 @@ jobs: strategy: matrix: - python-version: [3.6,3.7,3.8,3.9,'3.10'] - os: [ubuntu-18.04,ubuntu-20.04,ubuntu-22.04, macos-10.15,macos-11,macos-12] +# python-version: [3.6,3.7,3.8,3.9,'3.10'] +# os: [ubuntu-18.04,ubuntu-20.04,ubuntu-22.04,macos-10.15,macos-11,macos-12] + python-version: ['3.10'] + os: [ubuntu-22.04,macos-11] exclude: - os: ubuntu-18.04 python-version: 3.6 From 6906fa21e52f593e1175d12bb5fbc525cad16852 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 23:30:22 +0800 Subject: [PATCH 067/241] [Breaking Change + Test] (config) Test. --- .github/workflows/test-reusable-workflows.yaml | 4 ++-- .github/workflows/upload_test_report_to_codecov.yaml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index fca46ee6..3f2c578d 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -131,8 +131,8 @@ jobs: use_codecov: true download_path: ./ test_type: all-test -# codecov_flags: unit,integration -# codecov_name: smoothcrawler-appintegration_github-actions_test # optional + codecov_flags: unit,integration + codecov_name: smoothcrawler-appintegration_github-actions_test # optional coveralls_finish: diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 8fb6f755..514a7dc4 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -132,6 +132,8 @@ jobs: - name: Upload coverage report to platform Coveralls if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} + env: + GITHUB_TOKEN: ${{ secrets.coveralls_token }} run: coveralls --service=github # uses: coverallsapp/github-action@master # with: From 1eca97474be3d7a728fb1311255c8ffbc11f05a5 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 24 Aug 2022 23:40:25 +0800 Subject: [PATCH 068/241] [Breaking Change + Test] (config) Test. --- .github/workflows/upload_test_report_to_codecov.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 514a7dc4..c965165d 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -75,7 +75,8 @@ jobs: - name: Download code coverage result file uses: actions/download-artifact@v3 with: - name: final_project_testing_coverage_report +# name: final_project_testing_coverage_report + name: final_project_testing_coverage_xml_report path: ${{ inputs.download_path }} - name: Install Python 3.10 @@ -114,7 +115,7 @@ jobs: if: ${{ inputs.use_codecov == true && inputs.test_type == 'all-test' }} run: | codecov -t ${{ secrets.codecov_token }} \ - --file ./.coverage.unit-test,./.coverage.integration-test \ + --file ./coverage_integration-test.xml \ --flags ${{ inputs.codecov_flags }} \ --env OS,PYTHON \ --name ${{ inputs.codecov_name }} \ From 8482905e4ec729a4e272519212a23eb936aab1bc Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 08:59:58 +0800 Subject: [PATCH 069/241] [Breaking Change + Test] (config) Test for uploading test report. --- .../upload_test_report_to_codecov.yaml | 46 +++++++++++++------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index c965165d..170dfe37 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -75,6 +75,13 @@ jobs: - name: Download code coverage result file uses: actions/download-artifact@v3 with: + name: final_project_testing_coverage_report +# name: final_project_testing_coverage_xml_report + path: ${{ inputs.download_path }} + + - name: Download code coverage result file + uses: actions/download-artifact@v3 + with: # name: final_project_testing_coverage_report name: final_project_testing_coverage_xml_report path: ${{ inputs.download_path }} @@ -88,9 +95,14 @@ jobs: run: | python -m pip install --upgrade pip pip install -U pip - pip install -U codecov - pip install -U coveralls - pip install -U PyYAML + pip install coverage + pip install coverage-lcov + pip install codecov + pip install coveralls + pip install PyYAML + + - name: Test the coverage report + run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} # - name: Upload coverage report to platform Codecov # if: ${{ inputs.use_codecov == true && inputs.test_type != 'all-test' }} @@ -116,10 +128,10 @@ jobs: run: | codecov -t ${{ secrets.codecov_token }} \ --file ./coverage_integration-test.xml \ - --flags ${{ inputs.codecov_flags }} \ - --env OS,PYTHON \ - --name ${{ inputs.codecov_name }} \ - --branch github.ref_name +# --flags ${{ inputs.codecov_flags }} \ +# --env OS,PYTHON \ +# --name ${{ inputs.codecov_name }} \ +# --branch github.ref_name # uses: codecov/codecov-action@v3 # with: # token: ${{ secrets.codecov_token }} # not required for public repos @@ -131,13 +143,17 @@ jobs: # fail_ci_if_error: true # optional (default = false) # verbose: true # optional (default = false) + - name: Test the coverage report + if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} + run: coverage-lcov --data_file_path ./.coverage.integration-test --output_file_path lcov.info + - name: Upload coverage report to platform Coveralls if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} - env: - GITHUB_TOKEN: ${{ secrets.coveralls_token }} - run: coveralls --service=github -# uses: coverallsapp/github-action@master -# with: -# github-token: ${{ secrets.coveralls_token }} -# path-to-lcov: ./.coverage.integration-test -# flag-name: ${{ secrets.coveralls_flag }} +# env: +# GITHUB_TOKEN: ${{ secrets.coveralls_token }} +# run: coveralls --service=github + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.coveralls_token }} + path-to-lcov: ./lcov.info + flag-name: ${{ secrets.coveralls_flag }} From 925ade8657bcb3bc2f78cea0650207df258135fe Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 09:06:01 +0800 Subject: [PATCH 070/241] [Breaking Change + Test] (config) Test for uploading test report. --- .../workflows/upload_test_report_to_codecov.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 170dfe37..38b8ddf9 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -93,13 +93,13 @@ jobs: - name: Install Python dependencies run: | - python -m pip install --upgrade pip - pip install -U pip - pip install coverage - pip install coverage-lcov - pip install codecov - pip install coveralls - pip install PyYAML + python3 -m pip install --upgrade pip + pip3 install -U pip + pip3 install coverage + pip3 install coverage-lcov + pip3 install codecov + pip3 install coveralls + pip3 install PyYAML - name: Test the coverage report run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} From 8304d03e243d81e1e54dc1c90d295d7b3464cb15 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 09:14:05 +0800 Subject: [PATCH 071/241] [Breaking Change + Test] (config) Test for uploading test report. --- .github/workflows/upload_test_report_to_codecov.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 38b8ddf9..cc4ce0f3 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -96,7 +96,6 @@ jobs: python3 -m pip install --upgrade pip pip3 install -U pip pip3 install coverage - pip3 install coverage-lcov pip3 install codecov pip3 install coveralls pip3 install PyYAML @@ -145,7 +144,9 @@ jobs: - name: Test the coverage report if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} - run: coverage-lcov --data_file_path ./.coverage.integration-test --output_file_path lcov.info + run: | + pip3 install coverage-lcov + coverage-lcov --data_file_path ./.coverage.integration-test --output_file_path lcov.info - name: Upload coverage report to platform Coveralls if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} From d630c5394dc571c35d0b6a952f0fa7d80c8b485d Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 09:21:59 +0800 Subject: [PATCH 072/241] [Breaking Change + Test] (config) Test for uploading test report. --- .../upload_test_report_to_codecov.yaml | 63 ++++++++++--------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index cc4ce0f3..b47b7011 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -75,16 +75,15 @@ jobs: - name: Download code coverage result file uses: actions/download-artifact@v3 with: - name: final_project_testing_coverage_report -# name: final_project_testing_coverage_xml_report - path: ${{ inputs.download_path }} + name: coverage + path: ./ - - name: Download code coverage result file - uses: actions/download-artifact@v3 - with: -# name: final_project_testing_coverage_report - name: final_project_testing_coverage_xml_report - path: ${{ inputs.download_path }} +# - name: Download code coverage result file +# uses: actions/download-artifact@v3 +# with: +## name: final_project_testing_coverage_report +# name: final_project_testing_coverage_xml_report +# path: ${{ inputs.download_path }} - name: Install Python 3.10 uses: actions/setup-python@v2 @@ -96,13 +95,16 @@ jobs: python3 -m pip install --upgrade pip pip3 install -U pip pip3 install coverage - pip3 install codecov - pip3 install coveralls - pip3 install PyYAML - - name: Test the coverage report + - name: Combine all testing code coverage result files with all test types + run: coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.* + + - name: Report testing coverage of project code run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} + - name: General testing coverage report as XML format with ${{ inputs.test_type }} + run: coverage xml --data-file=.coverage.${{ inputs.test_type }} -o coverage_${{ inputs.test_type }}.xml + # - name: Upload coverage report to platform Codecov # if: ${{ inputs.use_codecov == true && inputs.test_type != 'all-test' }} # uses: codecov/codecov-action@v3 @@ -124,29 +126,30 @@ jobs: - name: Upload coverage report to platform Codecov if: ${{ inputs.use_codecov == true && inputs.test_type == 'all-test' }} - run: | - codecov -t ${{ secrets.codecov_token }} \ - --file ./coverage_integration-test.xml \ -# --flags ${{ inputs.codecov_flags }} \ -# --env OS,PYTHON \ -# --name ${{ inputs.codecov_name }} \ -# --branch github.ref_name -# uses: codecov/codecov-action@v3 -# with: -# token: ${{ secrets.codecov_token }} # not required for public repos -## files: ./coverage_unit-test.xml,./coverage_integration-test.xml +# run: | +# codecov -t ${{ secrets.codecov_token }} \ +# --file ./coverage_integration-test.xml \ +## --flags ${{ inputs.codecov_flags }} \ +## --env OS,PYTHON \ +## --name ${{ inputs.codecov_name }} \ +## --branch github.ref_name + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.codecov_token }} # not required for public repos +# files: ./coverage_unit-test.xml,./coverage_integration-test.xml # files: ./.coverage.unit-test,./.coverage.integration-test # optional -# flags: ${{ inputs.codecov_flags }} # optional -# env_vars: OS,PYTHON # optional -# name: ${{ inputs.codecov_name }} # optional -# fail_ci_if_error: true # optional (default = false) -# verbose: true # optional (default = false) + files: ./coverage_${{ inputs.test_type }}.xml + flags: ${{ inputs.codecov_flags }} # optional + env_vars: OS,PYTHON # optional + name: ${{ inputs.codecov_name }} # optional + fail_ci_if_error: true # optional (default = false) + verbose: true # optional (default = false) - name: Test the coverage report if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} run: | pip3 install coverage-lcov - coverage-lcov --data_file_path ./.coverage.integration-test --output_file_path lcov.info + coverage-lcov --data_file_path ./.coverage.${{ inputs.test_type }} --output_file_path lcov.info - name: Upload coverage report to platform Coveralls if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} From a079bc224921525b62e6b58af68d964beada2102 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 09:31:23 +0800 Subject: [PATCH 073/241] [Breaking Change + Test] (config) Test for uploading test report. --- .coveralls.yml | 3 ++- .github/workflows/upload_test_report_to_codecov.yaml | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.coveralls.yml b/.coveralls.yml index 00fe1db5..2cef687c 100644 --- a/.coveralls.yml +++ b/.coveralls.yml @@ -1 +1,2 @@ -repo_token: $COVERALLS_TOKEN \ No newline at end of file +service_name: github +repo_token: $COVERALLS_REPO_TOKEN diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index b47b7011..43ae9033 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -153,8 +153,8 @@ jobs: - name: Upload coverage report to platform Coveralls if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} -# env: -# GITHUB_TOKEN: ${{ secrets.coveralls_token }} + env: + COVERALLS_REPO_TOKEN: ${{ secrets.coveralls_token }} # run: coveralls --service=github uses: coverallsapp/github-action@master with: From f3354253eeb9e744a8301effce9aa053906b674e Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 09:37:38 +0800 Subject: [PATCH 074/241] [Breaking Change + Test] (config) Test for uploading test report. --- .../upload_test_report_to_codecov.yaml | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 43ae9033..e0557986 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -145,19 +145,19 @@ jobs: fail_ci_if_error: true # optional (default = false) verbose: true # optional (default = false) - - name: Test the coverage report - if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} - run: | - pip3 install coverage-lcov - coverage-lcov --data_file_path ./.coverage.${{ inputs.test_type }} --output_file_path lcov.info +# - name: Test the coverage report +# if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} +# run: | +# pip3 install coverage-lcov +# coverage-lcov --data_file_path ./.coverage.${{ inputs.test_type }} --output_file_path lcov.info - name: Upload coverage report to platform Coveralls if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} env: COVERALLS_REPO_TOKEN: ${{ secrets.coveralls_token }} -# run: coveralls --service=github - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.coveralls_token }} - path-to-lcov: ./lcov.info - flag-name: ${{ secrets.coveralls_flag }} + run: coveralls --service=github +# uses: coverallsapp/github-action@master +# with: +# github-token: ${{ secrets.coveralls_token }} +# path-to-lcov: ./lcov.info +# flag-name: ${{ secrets.coveralls_flag }} From 8adc3fa2bdd8dc3e0d8addf1cd84c10ac329a74e Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 09:44:18 +0800 Subject: [PATCH 075/241] [Breaking Change + Test] (config) Test for uploading test report. --- .github/workflows/upload_test_report_to_codecov.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index e0557986..4f818912 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -95,6 +95,7 @@ jobs: python3 -m pip install --upgrade pip pip3 install -U pip pip3 install coverage + pip3 install coveralls - name: Combine all testing code coverage result files with all test types run: coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.* From b95f1db985cf84e00d7823a265c0770c31d09344 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 09:50:49 +0800 Subject: [PATCH 076/241] [Breaking Change + Test] (config) Test for uploading test report. --- .github/workflows/upload_test_report_to_codecov.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 4f818912..b446558c 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -140,9 +140,9 @@ jobs: # files: ./coverage_unit-test.xml,./coverage_integration-test.xml # files: ./.coverage.unit-test,./.coverage.integration-test # optional files: ./coverage_${{ inputs.test_type }}.xml - flags: ${{ inputs.codecov_flags }} # optional - env_vars: OS,PYTHON # optional - name: ${{ inputs.codecov_name }} # optional +# flags: ${{ inputs.codecov_flags }} # optional +# env_vars: OS,PYTHON # optional +# name: ${{ inputs.codecov_name }} # optional fail_ci_if_error: true # optional (default = false) verbose: true # optional (default = false) @@ -154,9 +154,9 @@ jobs: - name: Upload coverage report to platform Coveralls if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} - env: - COVERALLS_REPO_TOKEN: ${{ secrets.coveralls_token }} - run: coveralls --service=github +# env: +# COVERALLS_REPO_TOKEN: ${{ secrets.coveralls_token }} + run: coveralls # uses: coverallsapp/github-action@master # with: # github-token: ${{ secrets.coveralls_token }} From 3689a3fa45a3be1ababea5be38ee45726148e5c4 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 09:56:06 +0800 Subject: [PATCH 077/241] [Breaking Change + Test] (config) Test for uploading test report. --- .github/workflows/upload_code_report_to_codacy.yaml | 2 +- .github/workflows/upload_test_report_to_codecov.yaml | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/upload_code_report_to_codacy.yaml b/.github/workflows/upload_code_report_to_codacy.yaml index 3ae3e19e..b0fc14af 100644 --- a/.github/workflows/upload_code_report_to_codacy.yaml +++ b/.github/workflows/upload_code_report_to_codacy.yaml @@ -44,7 +44,7 @@ jobs: - name: Download testing coverage report uses: actions/download-artifact@v3 with: - name: final_project_testing_coverage_report + name: final_project_testing_coverage_xml_report path: ${{ inputs.download_path }} - name: Upload testing report to Codacy diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index b446558c..a51218f1 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -106,6 +106,9 @@ jobs: - name: General testing coverage report as XML format with ${{ inputs.test_type }} run: coverage xml --data-file=.coverage.${{ inputs.test_type }} -o coverage_${{ inputs.test_type }}.xml + - name: Report testing coverage of project code + run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} + # - name: Upload coverage report to platform Codecov # if: ${{ inputs.use_codecov == true && inputs.test_type != 'all-test' }} # uses: codecov/codecov-action@v3 @@ -154,8 +157,8 @@ jobs: - name: Upload coverage report to platform Coveralls if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} -# env: -# COVERALLS_REPO_TOKEN: ${{ secrets.coveralls_token }} + env: + GITHUB_TOKEN: ${{ secrets.coveralls_token }} run: coveralls # uses: coverallsapp/github-action@master # with: From c6499fcbe18a0ed5ca4a4021ce03ffd69c2ecf08 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 10:09:43 +0800 Subject: [PATCH 078/241] [Breaking Change + Test] (config) Test for uploading test report. --- .../upload_test_report_to_codecov.yaml | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index a51218f1..7601d5cd 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -72,18 +72,18 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Download code coverage result file - uses: actions/download-artifact@v3 - with: - name: coverage - path: ./ - # - name: Download code coverage result file # uses: actions/download-artifact@v3 # with: -## name: final_project_testing_coverage_report +# name: coverage +# path: ./ + + - name: Download code coverage result file + uses: actions/download-artifact@v3 + with: + name: final_project_testing_coverage_report # name: final_project_testing_coverage_xml_report -# path: ${{ inputs.download_path }} + path: ${{ inputs.download_path }} - name: Install Python 3.10 uses: actions/setup-python@v2 @@ -97,17 +97,29 @@ jobs: pip3 install coverage pip3 install coveralls +# - name: Combine all testing code coverage result files with all test types +# run: coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.* +# +# - name: Report testing coverage of project code +# run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} +# +# - name: General testing coverage report as XML format with ${{ inputs.test_type }} +# run: coverage xml --data-file=.coverage.${{ inputs.test_type }} -o coverage_${{ inputs.test_type }}.xml +# +# - name: Report testing coverage of project code +# run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} + - name: Combine all testing code coverage result files with all test types - run: coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.* + run: coverage combine .coverage.* - name: Report testing coverage of project code - run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} + run: coverage report -m - name: General testing coverage report as XML format with ${{ inputs.test_type }} - run: coverage xml --data-file=.coverage.${{ inputs.test_type }} -o coverage_${{ inputs.test_type }}.xml + run: coverage xml - name: Report testing coverage of project code - run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} + run: coverage report -m # - name: Upload coverage report to platform Codecov # if: ${{ inputs.use_codecov == true && inputs.test_type != 'all-test' }} @@ -142,7 +154,7 @@ jobs: token: ${{ secrets.codecov_token }} # not required for public repos # files: ./coverage_unit-test.xml,./coverage_integration-test.xml # files: ./.coverage.unit-test,./.coverage.integration-test # optional - files: ./coverage_${{ inputs.test_type }}.xml + files: ./coverage.xml # flags: ${{ inputs.codecov_flags }} # optional # env_vars: OS,PYTHON # optional # name: ${{ inputs.codecov_name }} # optional From bac4af26bf204ab6272ad4d572933a9b84a648ab Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 10:20:02 +0800 Subject: [PATCH 079/241] [Breaking Change + Test] (config) Test for uploading test report. --- .../upload_test_report_to_codecov.yaml | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 7601d5cd..4434aea2 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -94,6 +94,7 @@ jobs: run: | python3 -m pip install --upgrade pip pip3 install -U pip + pip3 install codecov pip3 install coverage pip3 install coveralls @@ -109,17 +110,18 @@ jobs: # - name: Report testing coverage of project code # run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} - - name: Combine all testing code coverage result files with all test types - run: coverage combine .coverage.* - - - name: Report testing coverage of project code - run: coverage report -m - - - name: General testing coverage report as XML format with ${{ inputs.test_type }} - run: coverage xml - - - name: Report testing coverage of project code - run: coverage report -m +## Second usage +# - name: Combine all testing code coverage result files with all test types +# run: coverage combine .coverage.* +# +# - name: Report testing coverage of project code +# run: coverage report -m +# +# - name: General testing coverage report as XML format with ${{ inputs.test_type }} +# run: coverage xml +# +# - name: Report testing coverage of project code +# run: coverage report -m # - name: Upload coverage report to platform Codecov # if: ${{ inputs.use_codecov == true && inputs.test_type != 'all-test' }} @@ -142,6 +144,7 @@ jobs: - name: Upload coverage report to platform Codecov if: ${{ inputs.use_codecov == true && inputs.test_type == 'all-test' }} + run: codecov -t ${{ secrets.codecov_token }} # run: | # codecov -t ${{ secrets.codecov_token }} \ # --file ./coverage_integration-test.xml \ @@ -149,17 +152,17 @@ jobs: ## --env OS,PYTHON \ ## --name ${{ inputs.codecov_name }} \ ## --branch github.ref_name - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.codecov_token }} # not required for public repos -# files: ./coverage_unit-test.xml,./coverage_integration-test.xml -# files: ./.coverage.unit-test,./.coverage.integration-test # optional - files: ./coverage.xml -# flags: ${{ inputs.codecov_flags }} # optional -# env_vars: OS,PYTHON # optional -# name: ${{ inputs.codecov_name }} # optional - fail_ci_if_error: true # optional (default = false) - verbose: true # optional (default = false) +# uses: codecov/codecov-action@v3 +# with: +# token: ${{ secrets.codecov_token }} # not required for public repos +## files: ./coverage_unit-test.xml,./coverage_integration-test.xml +## files: ./.coverage.unit-test,./.coverage.integration-test # optional +# files: ./coverage.xml +## flags: ${{ inputs.codecov_flags }} # optional +## env_vars: OS,PYTHON # optional +## name: ${{ inputs.codecov_name }} # optional +# fail_ci_if_error: true # optional (default = false) +# verbose: true # optional (default = false) # - name: Test the coverage report # if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} From dbadff517260138d08231f010547c37356a2c150 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 10:24:33 +0800 Subject: [PATCH 080/241] [Breaking Change + Test] (config) Test for uploading test report. --- .../upload_test_report_to_codecov.yaml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index 4434aea2..d56d6607 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -111,12 +111,12 @@ jobs: # run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} ## Second usage -# - name: Combine all testing code coverage result files with all test types -# run: coverage combine .coverage.* -# -# - name: Report testing coverage of project code -# run: coverage report -m -# + - name: Combine all testing code coverage result files with all test types + run: coverage combine .coverage.* + + - name: Report testing coverage of project code + run: coverage report -m + # - name: General testing coverage report as XML format with ${{ inputs.test_type }} # run: coverage xml # @@ -136,12 +136,6 @@ jobs: # fail_ci_if_error: true # optional (default = false) # verbose: true # optional (default = false) -# - name: Rename (for test) -# run: mv ./coverage_unit-test.xml ./coverage1.xml -# -# - name: Rename (for test) -# run: mv ./coverage_integration-test.xml ./coverage2.xml - - name: Upload coverage report to platform Codecov if: ${{ inputs.use_codecov == true && inputs.test_type == 'all-test' }} run: codecov -t ${{ secrets.codecov_token }} From 5cbd53b3439ca1e15b3b67d6deca096fa744c753 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 10:40:32 +0800 Subject: [PATCH 081/241] [Breaking Change + Test] (config) Test for uploading test report. --- .github/workflows/upload_test_report_to_codecov.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index d56d6607..e2a9e3d2 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -138,7 +138,8 @@ jobs: - name: Upload coverage report to platform Codecov if: ${{ inputs.use_codecov == true && inputs.test_type == 'all-test' }} - run: codecov -t ${{ secrets.codecov_token }} +# run: bash <(curl -s https://codecov.io/bash) +# run: codecov -t ${{ secrets.codecov_token }} # run: | # codecov -t ${{ secrets.codecov_token }} \ # --file ./coverage_integration-test.xml \ @@ -146,7 +147,7 @@ jobs: ## --env OS,PYTHON \ ## --name ${{ inputs.codecov_name }} \ ## --branch github.ref_name -# uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v3 # with: # token: ${{ secrets.codecov_token }} # not required for public repos ## files: ./coverage_unit-test.xml,./coverage_integration-test.xml @@ -168,7 +169,7 @@ jobs: if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} env: GITHUB_TOKEN: ${{ secrets.coveralls_token }} - run: coveralls + run: coveralls --verbose # uses: coverallsapp/github-action@master # with: # github-token: ${{ secrets.coveralls_token }} From 0879ac84d1a98a1dd813f92a0fd493e48268b617 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 10:46:02 +0800 Subject: [PATCH 082/241] [Breaking Change + Test] (config) Test for uploading test report. --- ...eports.yaml => organize_and_generate_testing_reports.yaml} | 0 .github/workflows/test-reusable-workflows.yaml | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{organize_and_generate_testing_coverage_reports.yaml => organize_and_generate_testing_reports.yaml} (100%) diff --git a/.github/workflows/organize_and_generate_testing_coverage_reports.yaml b/.github/workflows/organize_and_generate_testing_reports.yaml similarity index 100% rename from .github/workflows/organize_and_generate_testing_coverage_reports.yaml rename to .github/workflows/organize_and_generate_testing_reports.yaml diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 3f2c578d..fbb218d3 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -68,7 +68,7 @@ jobs: unit-test_codecov: # name: Organize and generate the testing report and upload it to Codecov needs: run_unit-test - uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml + uses: ./.github/workflows/organize_and_generate_testing_reports.yaml with: test_type: unit-test # generate_xml_report_finally: false @@ -77,7 +77,7 @@ jobs: integration-test_codecov: # name: Organize and generate the testing report and upload it to Codecov needs: run_integration-test - uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml + uses: ./.github/workflows/organize_and_generate_testing_reports.yaml with: test_type: integration-test # generate_xml_report_finally: false From 22094188fed88f366ead08b419d90d7e581098e1 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 10:53:46 +0800 Subject: [PATCH 083/241] [Breaking Change + Test] (config) Test for uploading test report. --- .github/workflows/upload_test_report_to_codecov.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index e2a9e3d2..d57b215b 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -147,8 +147,9 @@ jobs: ## --env OS,PYTHON \ ## --name ${{ inputs.codecov_name }} \ ## --branch github.ref_name - uses: codecov/codecov-action@v3 -# with: + uses: codecov/codecov-action@v2 + with: + file: .coverage # token: ${{ secrets.codecov_token }} # not required for public repos ## files: ./coverage_unit-test.xml,./coverage_integration-test.xml ## files: ./.coverage.unit-test,./.coverage.integration-test # optional From 46325822a1ed0c8242d4aeab6641471def00298c Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 10:57:56 +0800 Subject: [PATCH 084/241] [Breaking Change + Test] (config) Test for uploading test report. --- .github/workflows/upload_test_report_to_codecov.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml index d57b215b..d422540b 100644 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ b/.github/workflows/upload_test_report_to_codecov.yaml @@ -138,7 +138,7 @@ jobs: - name: Upload coverage report to platform Codecov if: ${{ inputs.use_codecov == true && inputs.test_type == 'all-test' }} -# run: bash <(curl -s https://codecov.io/bash) + run: bash <(curl -s https://codecov.io/bash) # run: codecov -t ${{ secrets.codecov_token }} # run: | # codecov -t ${{ secrets.codecov_token }} \ @@ -147,9 +147,9 @@ jobs: ## --env OS,PYTHON \ ## --name ${{ inputs.codecov_name }} \ ## --branch github.ref_name - uses: codecov/codecov-action@v2 - with: - file: .coverage +# uses: codecov/codecov-action@v2 +# with: +# file: .coverage # token: ${{ secrets.codecov_token }} # not required for public repos ## files: ./coverage_unit-test.xml,./coverage_integration-test.xml ## files: ./.coverage.unit-test,./.coverage.integration-test # optional From b3a9a6b7ba7250c13683cefe3ab4927b0868c31f Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 19:01:59 +0800 Subject: [PATCH 085/241] [Refactor + Breaking Change + Test] (config) Integrate all features about uploading test coverage report into a reusable workflow. --- .github/workflows/upload_test_cov_report.yaml | 139 ++++++++++++++ .../upload_test_report_to_codecov.yaml | 178 ------------------ 2 files changed, 139 insertions(+), 178 deletions(-) create mode 100644 .github/workflows/upload_test_cov_report.yaml delete mode 100644 .github/workflows/upload_test_report_to_codecov.yaml diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml new file mode 100644 index 00000000..f18b8db2 --- /dev/null +++ b/.github/workflows/upload_test_cov_report.yaml @@ -0,0 +1,139 @@ +############################################################################ +# +# Workflow Description: +# Upload the testing coverage reports to Codecov. +# +# Workflow input parameters: +# * General arguments: +# * download_path: The path to download testing coverage reports via 'actions/download-artifact@v3'. +# * upload-to-codecov: If it's true, it would upload testing coverage report for Codecov (https://codecov.io). +# * upload-to-coveralls: If it's true, it would upload testing coverage report for Coveralls (https://coveralls.io). +# * upload-to-codacy: If it's true, it would upload testing coverage report for Codacy (https://app.codacy.com/). +# +# * Secret arguments: +# * codecov_token: The API token for uploading testing coverage report to Codecov. +# * coveralls_token: The API token for uploading testing coverage report to Coveralls. +# * codacy_token: The API token for uploading testing coverage report to Codacy. +# +# Workflow running output: +# No and do nothing. +# +############################################################################ + +name: Upload test report to Codecov + +on: + workflow_call: + inputs: + download_path: + description: "The path to download testing coverage reports via 'actions/download-artifact@v3'." + type: string + required: false + default: ./ + upload-to-codecov: + description: "If it's true, it would upload testing coverage report for Codecov (https://codecov.io)." + type: boolean + required: false + default: false + upload-to-coveralls: + description: "If it's true, it would upload testing coverage report for Coveralls (https://coveralls.io)." + type: boolean + required: false + default: false + upload-to-codacy: + description: "If it's true, it would upload testing coverage report for Codacy (https://app.codacy.com/)." + type: boolean + required: false + default: false +# codecov_flags: +# description: "The flags of the testing coverage report for Codecov." +# type: string +# required: false +# default: '' +# codecov_name: +# description: "The name of the testing coverage report for Codecov." +# type: string +# required: false +# default: '' + + secrets: + codecov_token: + description: "The API token for uploading testing coverage report to Codecov." + required: false + coveralls_token: + description: "The API token for uploading testing coverage report to Coveralls." + required: false + codacy_token: + description: "The API token for uploading testing coverage report to Codacy." + required: true + + +jobs: + upload_report_to_codecov: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Download code coverage result files which has be handled by different test type process + uses: actions/download-artifact@v3 + with: + name: final_project_testing_coverage_report + path: ${{ inputs.download_path }} + + - name: Install Python 3.10 + uses: actions/setup-python@v2 + with: + python-version: "3.10" + + - name: Install Python dependencies about handling testing coverage report + run: | + python3 -m pip install --upgrade pip + pip3 install -U pip + pip3 install coverage + + - name: Combine all testing code coverage result files with all test types + run: coverage combine .coverage.* + + - name: Report testing coverage of project code + run: coverage report -m + + - name: Install Python dependencies about tool of Codecov + if: ${{ inputs.upload-to-codecov == true }} + run: pip3 install codecov + + - name: Upload coverage report to Codecov https://codecov.io + if: ${{ inputs.upload-to-codecov == true }} +#### Way 1 +# run: bash <(curl -s https://codecov.io/bash) +#### Way 2 + run: codecov -t ${{ secrets.codecov_token }} +#### Way 3 +# uses: codecov/codecov-action@v2 +# with: +# file: .coverage +# token: ${{ secrets.codecov_token }} # not required for public repos +# files: ./coverage.xml +## flags: ${{ inputs.codecov_flags }} # optional +## env_vars: OS,PYTHON # optional +## name: ${{ inputs.codecov_name }} # optional +# fail_ci_if_error: true # optional (default = false) +# verbose: true # optional (default = false) + + - name: Install Python dependencies about tool of Coveralls + if: ${{ inputs.upload-to-coveralls == true }} + run: pip3 install coveralls + + - name: Upload coverage report to Coveralls https://coveralls.io + if: ${{ inputs.upload-to-coveralls == true }} + env: + GITHUB_TOKEN: ${{ secrets.coveralls_token }} + run: coveralls --verbose + + - name: Upload testing report to Codacy https://app.codacy.com/ + if: ${{ inputs.upload-to-codacy == true }} + uses: codacy/codacy-coverage-reporter-action@v1 + with: + project-token: ${{ secrets.codacy_token }} + coverage-reports: coverage.xml +# coverage-reports: cobertura.xml diff --git a/.github/workflows/upload_test_report_to_codecov.yaml b/.github/workflows/upload_test_report_to_codecov.yaml deleted file mode 100644 index d422540b..00000000 --- a/.github/workflows/upload_test_report_to_codecov.yaml +++ /dev/null @@ -1,178 +0,0 @@ -############################################################################ -# -# Workflow Description: -# Upload the testing coverage reports to Codecov. -# -# Workflow input parameters: -# * General arguments: -# * download_path: The path to download testing coverage reports via 'actions/download-artifact@v3'. -# * codecov_flags: The flags of the testing coverage report for Codecov. -# * codecov_name: The name of the testing coverage report for Codecov. -# -# * Secret arguments: -# * codecov_token: The API token for uploading testing coverage report to Codecov. -# -# Workflow running output: -# No and do nothing. -# -############################################################################ - -name: Upload test report to Codecov - -on: - workflow_call: - inputs: - download_path: - description: "The path to download testing coverage reports via 'actions/download-artifact@v3'." - type: string - required: true - test_type: - description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'." - type: string - required: true - use_codecov: - description: "The flags of the testing coverage report for Codecov." - type: boolean - required: false - default: false - use_coveralls: - description: "The flags of the testing coverage report for Codecov." - type: boolean - required: false - default: false - codecov_flags: - description: "The flags of the testing coverage report for Codecov." - type: string - required: false - default: '' - codecov_name: - description: "The name of the testing coverage report for Codecov." - type: string - required: false - default: '' - coveralls_flag: - description: "The name of the testing coverage report for Codecov." - type: string - required: false - default: '' - - secrets: - codecov_token: - description: "The API token for uploading testing coverage report to Codecov." - required: false - coveralls_token: - description: "The API token for uploading testing coverage report to Coveralls." - required: false - - -jobs: - upload_report_to_codecov: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - -# - name: Download code coverage result file -# uses: actions/download-artifact@v3 -# with: -# name: coverage -# path: ./ - - - name: Download code coverage result file - uses: actions/download-artifact@v3 - with: - name: final_project_testing_coverage_report -# name: final_project_testing_coverage_xml_report - path: ${{ inputs.download_path }} - - - name: Install Python 3.10 - uses: actions/setup-python@v2 - with: - python-version: "3.10" - - - name: Install Python dependencies - run: | - python3 -m pip install --upgrade pip - pip3 install -U pip - pip3 install codecov - pip3 install coverage - pip3 install coveralls - -# - name: Combine all testing code coverage result files with all test types -# run: coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.* -# -# - name: Report testing coverage of project code -# run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} -# -# - name: General testing coverage report as XML format with ${{ inputs.test_type }} -# run: coverage xml --data-file=.coverage.${{ inputs.test_type }} -o coverage_${{ inputs.test_type }}.xml -# -# - name: Report testing coverage of project code -# run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} - -## Second usage - - name: Combine all testing code coverage result files with all test types - run: coverage combine .coverage.* - - - name: Report testing coverage of project code - run: coverage report -m - -# - name: General testing coverage report as XML format with ${{ inputs.test_type }} -# run: coverage xml -# -# - name: Report testing coverage of project code -# run: coverage report -m - -# - name: Upload coverage report to platform Codecov -# if: ${{ inputs.use_codecov == true && inputs.test_type != 'all-test' }} -# uses: codecov/codecov-action@v3 -# with: -# token: ${{ secrets.codecov_token }} # not required for public repos -## files: coverage.xml # optional -# files: ./coverage_${{ inputs.test_type }}.xml # optional -# flags: ${{ inputs.codecov_flags }} # optional -# env_vars: OS,PYTHON -# name: ${{ inputs.codecov_name }} # optional -# fail_ci_if_error: true # optional (default = false) -# verbose: true # optional (default = false) - - - name: Upload coverage report to platform Codecov - if: ${{ inputs.use_codecov == true && inputs.test_type == 'all-test' }} - run: bash <(curl -s https://codecov.io/bash) -# run: codecov -t ${{ secrets.codecov_token }} -# run: | -# codecov -t ${{ secrets.codecov_token }} \ -# --file ./coverage_integration-test.xml \ -## --flags ${{ inputs.codecov_flags }} \ -## --env OS,PYTHON \ -## --name ${{ inputs.codecov_name }} \ -## --branch github.ref_name -# uses: codecov/codecov-action@v2 -# with: -# file: .coverage -# token: ${{ secrets.codecov_token }} # not required for public repos -## files: ./coverage_unit-test.xml,./coverage_integration-test.xml -## files: ./.coverage.unit-test,./.coverage.integration-test # optional -# files: ./coverage.xml -## flags: ${{ inputs.codecov_flags }} # optional -## env_vars: OS,PYTHON # optional -## name: ${{ inputs.codecov_name }} # optional -# fail_ci_if_error: true # optional (default = false) -# verbose: true # optional (default = false) - -# - name: Test the coverage report -# if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} -# run: | -# pip3 install coverage-lcov -# coverage-lcov --data_file_path ./.coverage.${{ inputs.test_type }} --output_file_path lcov.info - - - name: Upload coverage report to platform Coveralls - if: ${{ inputs.use_coveralls == true && inputs.test_type == 'all-test' }} - env: - GITHUB_TOKEN: ${{ secrets.coveralls_token }} - run: coveralls --verbose -# uses: coverallsapp/github-action@master -# with: -# github-token: ${{ secrets.coveralls_token }} -# path-to-lcov: ./lcov.info -# flag-name: ${{ secrets.coveralls_flag }} From 25d82a63b2311340bade0f4f9bec8639ab3f02cd Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 19:03:01 +0800 Subject: [PATCH 086/241] [Refactor + Test] (config) Modify to use newer reusable 'upload_test_cov_report.yaml' with newer parameters. --- .../workflows/test-reusable-workflows.yaml | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index fbb218d3..4d13d168 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -124,40 +124,34 @@ jobs: # name: Organize and generate the testing report and upload it to Codecov # if: github.ref_name == 'release' || github.ref_name == 'master' needs: [unit-test_codecov, integration-test_codecov] - uses: ./.github/workflows/upload_test_report_to_codecov.yaml + uses: ./.github/workflows/upload_test_cov_report.yaml secrets: codecov_token: ${{ secrets.CODECOV_TOKEN }} with: - use_codecov: true - download_path: ./ - test_type: all-test - codecov_flags: unit,integration - codecov_name: smoothcrawler-appintegration_github-actions_test # optional + upload-to-codecov: true +# codecov_flags: unit,integration +# codecov_name: smoothcrawler-appintegration_github-actions_test # optional coveralls_finish: # name: Organize and generate the testing report and upload it to Coveralls # if: github.ref_name == 'release' || github.ref_name == 'master' needs: [unit-test_codecov, integration-test_codecov] - uses: ./.github/workflows/upload_test_report_to_codecov.yaml + uses: ./.github/workflows/upload_test_cov_report.yaml secrets: coveralls_token: ${{ secrets.COVERALLS_TOKEN }} with: - use_coveralls: true - download_path: ./ - coveralls_flag: all-test - test_type: all-test + upload-to-coveralls: true codacy_finish: # name: Upload test report to Codacy to analyse and record code quality needs: [unit-test_codecov, integration-test_codecov] - uses: ./.github/workflows/upload_code_report_to_codacy.yaml + uses: ./.github/workflows/upload_test_cov_report.yaml secrets: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} with: - download_path: ./ - test_type: all-test + upload-to-codacy: true # pre-building_check: From 324c37ad0489dcb3ae56932eb4a2584c3efa2a02 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 19:04:32 +0800 Subject: [PATCH 087/241] [Bug Fix] (config) Fix the issue about incorrect setting of input parameter. --- .github/workflows/upload_test_cov_report.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index f18b8db2..2b9c0548 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -65,7 +65,7 @@ on: required: false codacy_token: description: "The API token for uploading testing coverage report to Codacy." - required: true + required: false jobs: From b912e84543113538e3aeaac73a580506ebe3d22c Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 19:10:43 +0800 Subject: [PATCH 088/241] [Bug Fix] (config) Fix the issue about losing step to generate XML report. --- .github/workflows/upload_test_cov_report.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 2b9c0548..3ad42af5 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -69,7 +69,7 @@ on: jobs: - upload_report_to_codecov: + upload_test_cov_report: runs-on: ubuntu-latest steps: - name: Checkout @@ -98,6 +98,9 @@ jobs: - name: Report testing coverage of project code run: coverage report -m + - name: Report testing coverage of project code + run: coverage xml + - name: Install Python dependencies about tool of Codecov if: ${{ inputs.upload-to-codecov == true }} run: pip3 install codecov From 272400ef3ca01e6742895589c187f03a44792153 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 19:17:47 +0800 Subject: [PATCH 089/241] for testing. --- .../workflows/test-reusable-workflows.yaml | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 4d13d168..18a2808d 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -120,28 +120,28 @@ jobs: # codecov_name: smoothcrawler-appintegration_github-actions_test # optional - codecov_finish: -# name: Organize and generate the testing report and upload it to Codecov -# if: github.ref_name == 'release' || github.ref_name == 'master' - needs: [unit-test_codecov, integration-test_codecov] - uses: ./.github/workflows/upload_test_cov_report.yaml - secrets: - codecov_token: ${{ secrets.CODECOV_TOKEN }} - with: - upload-to-codecov: true -# codecov_flags: unit,integration -# codecov_name: smoothcrawler-appintegration_github-actions_test # optional - - - coveralls_finish: -# name: Organize and generate the testing report and upload it to Coveralls -# if: github.ref_name == 'release' || github.ref_name == 'master' - needs: [unit-test_codecov, integration-test_codecov] - uses: ./.github/workflows/upload_test_cov_report.yaml - secrets: - coveralls_token: ${{ secrets.COVERALLS_TOKEN }} - with: - upload-to-coveralls: true +# codecov_finish: +## name: Organize and generate the testing report and upload it to Codecov +## if: github.ref_name == 'release' || github.ref_name == 'master' +# needs: [unit-test_codecov, integration-test_codecov] +# uses: ./.github/workflows/upload_test_cov_report.yaml +# secrets: +# codecov_token: ${{ secrets.CODECOV_TOKEN }} +# with: +# upload-to-codecov: true +## codecov_flags: unit,integration +## codecov_name: smoothcrawler-appintegration_github-actions_test # optional +# +# +# coveralls_finish: +## name: Organize and generate the testing report and upload it to Coveralls +## if: github.ref_name == 'release' || github.ref_name == 'master' +# needs: [unit-test_codecov, integration-test_codecov] +# uses: ./.github/workflows/upload_test_cov_report.yaml +# secrets: +# coveralls_token: ${{ secrets.COVERALLS_TOKEN }} +# with: +# upload-to-coveralls: true codacy_finish: From 12454c7219f6103f72240fb15bf71a0fc7256842 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 19:25:56 +0800 Subject: [PATCH 090/241] [New Feature + Test] (config) Add 2 new reusable workflows about uploading test coverage report. --- .../upload_test_cov_report_to_codecov.yaml | 85 +++++++++++++++++++ .../upload_test_cov_report_to_coveralls.yaml | 74 ++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 .github/workflows/upload_test_cov_report_to_codecov.yaml create mode 100644 .github/workflows/upload_test_cov_report_to_coveralls.yaml diff --git a/.github/workflows/upload_test_cov_report_to_codecov.yaml b/.github/workflows/upload_test_cov_report_to_codecov.yaml new file mode 100644 index 00000000..b6748b06 --- /dev/null +++ b/.github/workflows/upload_test_cov_report_to_codecov.yaml @@ -0,0 +1,85 @@ +############################################################################ +# +# Workflow Description: +# Upload the testing coverage reports to Codacy. +# +# Workflow input parameters: +# * General arguments: +# * download_path: The path to download testing coverage reports via 'actions/download-artifact@v3'. +# +# * Secret arguments: +# * codacy_token: The API token for uploading testing coverage report to Codacy. +# +# Workflow running output: +# No and do nothing. +# +############################################################################ + +name: Upload code detail report to Codacy + +on: + workflow_call: + inputs: + download_path: + description: "The path to download testing coverage reports via 'actions/download-artifact@v3'." + type: string + required: false + default: ./ + + secrets: + codecov_token: + description: "The API token for uploading testing coverage report to Codacy." + required: true + + +jobs: + upload_code_to_codacy_check_quality: + runs-on: ubuntu-latest + steps: + - name: Download testing coverage report + uses: actions/download-artifact@v3 + with: + name: final_project_testing_coverage_xml_report + path: ${{ inputs.download_path }} + + - name: Install Python 3.10 + uses: actions/setup-python@v2 + with: + python-version: "3.10" + + - name: Install Python dependencies about handling testing coverage report + run: | + python3 -m pip install --upgrade pip + pip3 install -U pip + pip3 install coverage + + - name: Combine all testing code coverage result files with all test types + run: coverage combine .coverage.* + + - name: Report testing coverage of project code + run: coverage report -m + + - name: Report testing coverage of project code + run: coverage xml + + - name: Install Python dependencies about tool of Codecov +# if: ${{ inputs.upload-to-codecov == true }} + run: pip3 install codecov + + - name: Upload coverage report to Codecov https://codecov.io +# if: ${{ inputs.upload-to-codecov == true }} +#### Way 1 +# run: bash <(curl -s https://codecov.io/bash) +#### Way 2 + run: codecov -t ${{ secrets.codecov_token }} +#### Way 3 +# uses: codecov/codecov-action@v2 +# with: +# file: .coverage +# token: ${{ secrets.codecov_token }} # not required for public repos +# files: ./coverage.xml +## flags: ${{ inputs.codecov_flags }} # optional +## env_vars: OS,PYTHON # optional +## name: ${{ inputs.codecov_name }} # optional +# fail_ci_if_error: true # optional (default = false) +# verbose: true # optional (default = false) diff --git a/.github/workflows/upload_test_cov_report_to_coveralls.yaml b/.github/workflows/upload_test_cov_report_to_coveralls.yaml new file mode 100644 index 00000000..2896fbb5 --- /dev/null +++ b/.github/workflows/upload_test_cov_report_to_coveralls.yaml @@ -0,0 +1,74 @@ +############################################################################ +# +# Workflow Description: +# Upload the testing coverage reports to Codacy. +# +# Workflow input parameters: +# * General arguments: +# * download_path: The path to download testing coverage reports via 'actions/download-artifact@v3'. +# +# * Secret arguments: +# * codacy_token: The API token for uploading testing coverage report to Codacy. +# +# Workflow running output: +# No and do nothing. +# +############################################################################ + +name: Upload code detail report to Codacy + +on: + workflow_call: + inputs: + download_path: + description: "The path to download testing coverage reports via 'actions/download-artifact@v3'." + type: string + required: false + default: ./ + + secrets: + coveralls_token: + description: "The API token for uploading testing coverage report to Codacy." + required: true + + +jobs: + upload_code_to_codacy_check_quality: + runs-on: ubuntu-latest + steps: + - name: Download testing coverage report + uses: actions/download-artifact@v3 + with: + name: final_project_testing_coverage_xml_report + path: ${{ inputs.download_path }} + + - name: Install Python 3.10 + uses: actions/setup-python@v2 + with: + python-version: "3.10" + + - name: Install Python dependencies about handling testing coverage report + run: | + python3 -m pip install --upgrade pip + pip3 install -U pip + pip3 install coverage + + - name: Combine all testing code coverage result files with all test types + run: coverage combine .coverage.* + + - name: Report testing coverage of project code + run: coverage report -m + + - name: Report testing coverage of project code + run: coverage xml + + - name: Install Python dependencies about tool of Coveralls +# if: ${{ inputs.upload-to-coveralls == true }} + run: pip3 install coveralls + + - name: Upload coverage report to Coveralls https://coveralls.io +# if: ${{ inputs.upload-to-coveralls == true }} + env: + GITHUB_TOKEN: ${{ secrets.coveralls_token }} + run: coveralls --verbose + From c3224b524a2d679158416c5a9a8c4ba05672b1d6 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 19:26:15 +0800 Subject: [PATCH 091/241] [Breaking Change + Test] (config) Test for uploading test report. --- .../workflows/test-reusable-workflows.yaml | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 18a2808d..936ecec0 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -120,26 +120,26 @@ jobs: # codecov_name: smoothcrawler-appintegration_github-actions_test # optional -# codecov_finish: -## name: Organize and generate the testing report and upload it to Codecov -## if: github.ref_name == 'release' || github.ref_name == 'master' -# needs: [unit-test_codecov, integration-test_codecov] -# uses: ./.github/workflows/upload_test_cov_report.yaml -# secrets: -# codecov_token: ${{ secrets.CODECOV_TOKEN }} + codecov_finish: +# name: Organize and generate the testing report and upload it to Codecov +# if: github.ref_name == 'release' || github.ref_name == 'master' + needs: [unit-test_codecov, integration-test_codecov] + uses: ./.github/workflows/upload_test_cov_report_to_codecov.yaml + secrets: + codecov_token: ${{ secrets.CODECOV_TOKEN }} # with: # upload-to-codecov: true -## codecov_flags: unit,integration -## codecov_name: smoothcrawler-appintegration_github-actions_test # optional -# -# -# coveralls_finish: -## name: Organize and generate the testing report and upload it to Coveralls -## if: github.ref_name == 'release' || github.ref_name == 'master' -# needs: [unit-test_codecov, integration-test_codecov] -# uses: ./.github/workflows/upload_test_cov_report.yaml -# secrets: -# coveralls_token: ${{ secrets.COVERALLS_TOKEN }} +# codecov_flags: unit,integration +# codecov_name: smoothcrawler-appintegration_github-actions_test # optional + + + coveralls_finish: +# name: Organize and generate the testing report and upload it to Coveralls +# if: github.ref_name == 'release' || github.ref_name == 'master' + needs: [unit-test_codecov, integration-test_codecov] + uses: ./.github/workflows/upload_test_cov_report_to_coveralls.yaml + secrets: + coveralls_token: ${{ secrets.COVERALLS_TOKEN }} # with: # upload-to-coveralls: true @@ -147,11 +147,11 @@ jobs: codacy_finish: # name: Upload test report to Codacy to analyse and record code quality needs: [unit-test_codecov, integration-test_codecov] - uses: ./.github/workflows/upload_test_cov_report.yaml + uses: ./.github/workflows/upload_code_report_to_codacy.yaml secrets: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} - with: - upload-to-codacy: true +# with: +# upload-to-codacy: true # pre-building_check: From 798c57af5b653d5a2e3ae80404ec8536a993c98a Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 19:26:36 +0800 Subject: [PATCH 092/241] [Breaking Change] (config) Remove unused input parameter. --- .github/workflows/upload_code_report_to_codacy.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/upload_code_report_to_codacy.yaml b/.github/workflows/upload_code_report_to_codacy.yaml index b0fc14af..fecf52c2 100644 --- a/.github/workflows/upload_code_report_to_codacy.yaml +++ b/.github/workflows/upload_code_report_to_codacy.yaml @@ -6,7 +6,6 @@ # Workflow input parameters: # * General arguments: # * download_path: The path to download testing coverage reports via 'actions/download-artifact@v3'. -# * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'. # # * Secret arguments: # * codacy_token: The API token for uploading testing coverage report to Codacy. @@ -26,10 +25,6 @@ on: type: string required: false default: ./ - test_type: - description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'." - type: string - required: true secrets: codacy_token: From 6dc38910609d7d82b9799bac8204a3116ad15770 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 19:29:58 +0800 Subject: [PATCH 093/241] [Bug Fix + Test] (config) Fix the issue about download name. --- .github/workflows/upload_test_cov_report_to_codecov.yaml | 2 +- .github/workflows/upload_test_cov_report_to_coveralls.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload_test_cov_report_to_codecov.yaml b/.github/workflows/upload_test_cov_report_to_codecov.yaml index b6748b06..4e28b1b7 100644 --- a/.github/workflows/upload_test_cov_report_to_codecov.yaml +++ b/.github/workflows/upload_test_cov_report_to_codecov.yaml @@ -39,7 +39,7 @@ jobs: - name: Download testing coverage report uses: actions/download-artifact@v3 with: - name: final_project_testing_coverage_xml_report + name: final_project_testing_coverage_report path: ${{ inputs.download_path }} - name: Install Python 3.10 diff --git a/.github/workflows/upload_test_cov_report_to_coveralls.yaml b/.github/workflows/upload_test_cov_report_to_coveralls.yaml index 2896fbb5..9048fbe5 100644 --- a/.github/workflows/upload_test_cov_report_to_coveralls.yaml +++ b/.github/workflows/upload_test_cov_report_to_coveralls.yaml @@ -39,7 +39,7 @@ jobs: - name: Download testing coverage report uses: actions/download-artifact@v3 with: - name: final_project_testing_coverage_xml_report + name: final_project_testing_coverage_report path: ${{ inputs.download_path }} - name: Install Python 3.10 From 4643de97234fd2f70899bb514e657f15fe6b39e1 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 19:33:18 +0800 Subject: [PATCH 094/241] modify. --- .github/workflows/upload_code_report_to_codacy.yaml | 3 +++ .github/workflows/upload_test_cov_report_to_codecov.yaml | 3 +++ .github/workflows/upload_test_cov_report_to_coveralls.yaml | 3 +++ 3 files changed, 9 insertions(+) diff --git a/.github/workflows/upload_code_report_to_codacy.yaml b/.github/workflows/upload_code_report_to_codacy.yaml index fecf52c2..ecdc79e3 100644 --- a/.github/workflows/upload_code_report_to_codacy.yaml +++ b/.github/workflows/upload_code_report_to_codacy.yaml @@ -36,6 +36,9 @@ jobs: upload_code_to_codacy_check_quality: runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Download testing coverage report uses: actions/download-artifact@v3 with: diff --git a/.github/workflows/upload_test_cov_report_to_codecov.yaml b/.github/workflows/upload_test_cov_report_to_codecov.yaml index 4e28b1b7..5466b368 100644 --- a/.github/workflows/upload_test_cov_report_to_codecov.yaml +++ b/.github/workflows/upload_test_cov_report_to_codecov.yaml @@ -36,6 +36,9 @@ jobs: upload_code_to_codacy_check_quality: runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Download testing coverage report uses: actions/download-artifact@v3 with: diff --git a/.github/workflows/upload_test_cov_report_to_coveralls.yaml b/.github/workflows/upload_test_cov_report_to_coveralls.yaml index 9048fbe5..4e5c5707 100644 --- a/.github/workflows/upload_test_cov_report_to_coveralls.yaml +++ b/.github/workflows/upload_test_cov_report_to_coveralls.yaml @@ -36,6 +36,9 @@ jobs: upload_code_to_codacy_check_quality: runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Download testing coverage report uses: actions/download-artifact@v3 with: From 4d1eb2cb7705ab7edc111b4966e9ed0c1f42b0e2 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 20:25:26 +0800 Subject: [PATCH 095/241] test --- ...organize_and_generate_testing_reports.yaml | 3 +- .../workflows/test-reusable-workflows.yaml | 40 +++++++++---------- .../upload_code_report_to_codacy.yaml | 3 +- .../upload_test_cov_report_to_codecov.yaml | 4 +- .../upload_test_cov_report_to_coveralls.yaml | 4 +- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/.github/workflows/organize_and_generate_testing_reports.yaml b/.github/workflows/organize_and_generate_testing_reports.yaml index 28babb3b..2c3994d1 100644 --- a/.github/workflows/organize_and_generate_testing_reports.yaml +++ b/.github/workflows/organize_and_generate_testing_reports.yaml @@ -64,7 +64,8 @@ jobs: uses: actions/upload-artifact@v3 with: name: final_project_testing_coverage_report - path: .coverage.${{ inputs.test_type }} +# path: .coverage.${{ inputs.test_type }} + path: .coverage if-no-files-found: error - name: Upload testing coverage report (.xml) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 936ecec0..6742990d 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -65,31 +65,31 @@ jobs: http_server_enter_point: app - unit-test_codecov: -# name: Organize and generate the testing report and upload it to Codecov - needs: run_unit-test - uses: ./.github/workflows/organize_and_generate_testing_reports.yaml - with: - test_type: unit-test -# generate_xml_report_finally: false +# unit-test_codecov: +## name: Organize and generate the testing report and upload it to Codecov +# needs: run_unit-test +# uses: ./.github/workflows/organize_and_generate_testing_reports.yaml +# with: +# test_type: unit-test +## generate_xml_report_finally: false +# +# +# integration-test_codecov: +## name: Organize and generate the testing report and upload it to Codecov +# needs: run_integration-test +# uses: ./.github/workflows/organize_and_generate_testing_reports.yaml +# with: +# test_type: integration-test +## generate_xml_report_finally: false - integration-test_codecov: + all-test_codecov: # name: Organize and generate the testing report and upload it to Codecov - needs: run_integration-test +# needs: [unit-test_codecov, integration-test_codecov] + needs: [run_unit-test, run_integration-test] uses: ./.github/workflows/organize_and_generate_testing_reports.yaml with: - test_type: integration-test -# generate_xml_report_finally: false - - -# organize_all-test_codecov_and_generate_report: -## name: Organize and generate the testing report and upload it to Codecov -## needs: [unit-test_codecov, integration-test_codecov] -# needs: [run_unit-test, run_integration-test] -# uses: ./.github/workflows/organize_and_generate_testing_coverage_reports.yaml -# with: -# test_type: all-test + test_type: all-test # unit-codecov_finish: diff --git a/.github/workflows/upload_code_report_to_codacy.yaml b/.github/workflows/upload_code_report_to_codacy.yaml index ecdc79e3..40ad5ee6 100644 --- a/.github/workflows/upload_code_report_to_codacy.yaml +++ b/.github/workflows/upload_code_report_to_codacy.yaml @@ -49,6 +49,7 @@ jobs: uses: codacy/codacy-coverage-reporter-action@v1 with: project-token: ${{ secrets.codacy_token }} - coverage-reports: coverage_unit-test.xml,coverage_integration-test.xml +# coverage-reports: coverage_unit-test.xml,coverage_integration-test.xml + coverage-reports: coverage_all-test.xml # coverage-reports: cobertura.xml diff --git a/.github/workflows/upload_test_cov_report_to_codecov.yaml b/.github/workflows/upload_test_cov_report_to_codecov.yaml index 5466b368..b4bb044b 100644 --- a/.github/workflows/upload_test_cov_report_to_codecov.yaml +++ b/.github/workflows/upload_test_cov_report_to_codecov.yaml @@ -56,8 +56,8 @@ jobs: pip3 install -U pip pip3 install coverage - - name: Combine all testing code coverage result files with all test types - run: coverage combine .coverage.* +# - name: Combine all testing code coverage result files with all test types +# run: coverage combine .coverage.* - name: Report testing coverage of project code run: coverage report -m diff --git a/.github/workflows/upload_test_cov_report_to_coveralls.yaml b/.github/workflows/upload_test_cov_report_to_coveralls.yaml index 4e5c5707..6484b374 100644 --- a/.github/workflows/upload_test_cov_report_to_coveralls.yaml +++ b/.github/workflows/upload_test_cov_report_to_coveralls.yaml @@ -56,8 +56,8 @@ jobs: pip3 install -U pip pip3 install coverage - - name: Combine all testing code coverage result files with all test types - run: coverage combine .coverage.* +# - name: Combine all testing code coverage result files with all test types +# run: coverage combine .coverage.* - name: Report testing coverage of project code run: coverage report -m From 4a0b4ee085399fe44d59e256a32380e9b7ecd495 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 20:26:32 +0800 Subject: [PATCH 096/241] test --- .github/workflows/test-reusable-workflows.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 6742990d..d2260905 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -123,7 +123,8 @@ jobs: codecov_finish: # name: Organize and generate the testing report and upload it to Codecov # if: github.ref_name == 'release' || github.ref_name == 'master' - needs: [unit-test_codecov, integration-test_codecov] +# needs: [unit-test_codecov, integration-test_codecov] + needs: [all-test_codecov] uses: ./.github/workflows/upload_test_cov_report_to_codecov.yaml secrets: codecov_token: ${{ secrets.CODECOV_TOKEN }} @@ -136,7 +137,8 @@ jobs: coveralls_finish: # name: Organize and generate the testing report and upload it to Coveralls # if: github.ref_name == 'release' || github.ref_name == 'master' - needs: [unit-test_codecov, integration-test_codecov] +# needs: [unit-test_codecov, integration-test_codecov] + needs: [all-test_codecov] uses: ./.github/workflows/upload_test_cov_report_to_coveralls.yaml secrets: coveralls_token: ${{ secrets.COVERALLS_TOKEN }} @@ -146,7 +148,8 @@ jobs: codacy_finish: # name: Upload test report to Codacy to analyse and record code quality - needs: [unit-test_codecov, integration-test_codecov] +# needs: [unit-test_codecov, integration-test_codecov] + needs: [all-test_codecov] uses: ./.github/workflows/upload_code_report_to_codacy.yaml secrets: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} From 3013fcc0e5b927a68eea9d4527c843c1e5d98a33 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 20:29:05 +0800 Subject: [PATCH 097/241] test --- .github/workflows/organize_and_generate_testing_reports.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/organize_and_generate_testing_reports.yaml b/.github/workflows/organize_and_generate_testing_reports.yaml index 2c3994d1..5ff95a7e 100644 --- a/.github/workflows/organize_and_generate_testing_reports.yaml +++ b/.github/workflows/organize_and_generate_testing_reports.yaml @@ -52,7 +52,7 @@ jobs: - name: Combine all testing code coverage result files with all test types if: ${{ inputs.test_type == 'all-test' }} - run: coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.* + run: coverage combine --data-file=.coverage .coverage.* - name: Report testing coverage of project code run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} From 8b6848ee25f52acb6d57f1ad14ee7bac32bdb5a1 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 20:33:36 +0800 Subject: [PATCH 098/241] test --- ...organize_and_generate_testing_reports.yaml | 84 +++++++++++++++---- .../workflows/test-reusable-workflows.yaml | 74 ++++++++-------- 2 files changed, 106 insertions(+), 52 deletions(-) diff --git a/.github/workflows/organize_and_generate_testing_reports.yaml b/.github/workflows/organize_and_generate_testing_reports.yaml index 5ff95a7e..24b3e97d 100644 --- a/.github/workflows/organize_and_generate_testing_reports.yaml +++ b/.github/workflows/organize_and_generate_testing_reports.yaml @@ -21,6 +21,17 @@ on: required: true type: string + secrets: + codecov_token: + description: "The API token for uploading testing coverage report to Codecov." + required: false + coveralls_token: + description: "The API token for uploading testing coverage report to Coveralls." + required: false + codacy_token: + description: "The API token for uploading testing coverage report to Codacy." + required: false + jobs: organize_and_generate_test_reports: @@ -52,25 +63,64 @@ jobs: - name: Combine all testing code coverage result files with all test types if: ${{ inputs.test_type == 'all-test' }} - run: coverage combine --data-file=.coverage .coverage.* + run: | + coverage combine --data-file=.coverage .coverage.* + coverage report + coverage xml + +# - name: Report testing coverage of project code +# run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} +# +# - name: General testing coverage report as XML format with ${{ inputs.test_type }} +# run: coverage xml --data-file=.coverage.${{ inputs.test_type }} -o coverage_${{ inputs.test_type }}.xml - - name: Report testing coverage of project code - run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} +# - name: Upload testing coverage report (.coverage) +# uses: actions/upload-artifact@v3 +# with: +# name: final_project_testing_coverage_report +## path: .coverage.${{ inputs.test_type }} +# path: .coverage +# if-no-files-found: error +# +# - name: Upload testing coverage report (.xml) +# uses: actions/upload-artifact@v3 +# with: +# name: final_project_testing_coverage_xml_report +# path: coverage_${{ inputs.test_type }}.xml +# if-no-files-found: error - - name: General testing coverage report as XML format with ${{ inputs.test_type }} - run: coverage xml --data-file=.coverage.${{ inputs.test_type }} -o coverage_${{ inputs.test_type }}.xml + - name: Upload coverage report to Codecov https://codecov.io +# if: ${{ inputs.upload-to-codecov == true }} +#### Way 1 +# run: bash <(curl -s https://codecov.io/bash) +#### Way 2 + run: codecov -t ${{ secrets.codecov_token }} +#### Way 3 +# uses: codecov/codecov-action@v2 +# with: +# file: .coverage +# token: ${{ secrets.codecov_token }} # not required for public repos +# files: ./coverage.xml +## flags: ${{ inputs.codecov_flags }} # optional +## env_vars: OS,PYTHON # optional +## name: ${{ inputs.codecov_name }} # optional +# fail_ci_if_error: true # optional (default = false) +# verbose: true # optional (default = false) - - name: Upload testing coverage report (.coverage) - uses: actions/upload-artifact@v3 - with: - name: final_project_testing_coverage_report -# path: .coverage.${{ inputs.test_type }} - path: .coverage - if-no-files-found: error + - name: Install Python dependencies about tool of Coveralls +# if: ${{ inputs.upload-to-coveralls == true }} + run: pip3 install coveralls + + - name: Upload coverage report to Coveralls https://coveralls.io +# if: ${{ inputs.upload-to-coveralls == true }} + env: + GITHUB_TOKEN: ${{ secrets.coveralls_token }} + run: coveralls --verbose - - name: Upload testing coverage report (.xml) - uses: actions/upload-artifact@v3 + - name: Upload testing report to Codacy https://app.codacy.com/ +# if: ${{ inputs.upload-to-codacy == true }} + uses: codacy/codacy-coverage-reporter-action@v1 with: - name: final_project_testing_coverage_xml_report - path: coverage_${{ inputs.test_type }}.xml - if-no-files-found: error + project-token: ${{ secrets.codacy_token }} + coverage-reports: coverage.xml +# coverage-reports: cobertura.xml diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index d2260905..dd0c4d30 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -90,6 +90,10 @@ jobs: uses: ./.github/workflows/organize_and_generate_testing_reports.yaml with: test_type: all-test + secrets: + codecov_token: ${{ secrets.CODECOV_TOKEN }} + coveralls_token: ${{ secrets.COVERALLS_TOKEN }} + codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} # unit-codecov_finish: @@ -120,41 +124,41 @@ jobs: # codecov_name: smoothcrawler-appintegration_github-actions_test # optional - codecov_finish: -# name: Organize and generate the testing report and upload it to Codecov -# if: github.ref_name == 'release' || github.ref_name == 'master' -# needs: [unit-test_codecov, integration-test_codecov] - needs: [all-test_codecov] - uses: ./.github/workflows/upload_test_cov_report_to_codecov.yaml - secrets: - codecov_token: ${{ secrets.CODECOV_TOKEN }} -# with: -# upload-to-codecov: true -# codecov_flags: unit,integration -# codecov_name: smoothcrawler-appintegration_github-actions_test # optional - - - coveralls_finish: -# name: Organize and generate the testing report and upload it to Coveralls -# if: github.ref_name == 'release' || github.ref_name == 'master' -# needs: [unit-test_codecov, integration-test_codecov] - needs: [all-test_codecov] - uses: ./.github/workflows/upload_test_cov_report_to_coveralls.yaml - secrets: - coveralls_token: ${{ secrets.COVERALLS_TOKEN }} -# with: -# upload-to-coveralls: true - - - codacy_finish: -# name: Upload test report to Codacy to analyse and record code quality -# needs: [unit-test_codecov, integration-test_codecov] - needs: [all-test_codecov] - uses: ./.github/workflows/upload_code_report_to_codacy.yaml - secrets: - codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} -# with: -# upload-to-codacy: true +# codecov_finish: +## name: Organize and generate the testing report and upload it to Codecov +## if: github.ref_name == 'release' || github.ref_name == 'master' +## needs: [unit-test_codecov, integration-test_codecov] +# needs: [all-test_codecov] +# uses: ./.github/workflows/upload_test_cov_report_to_codecov.yaml +# secrets: +# codecov_token: ${{ secrets.CODECOV_TOKEN }} +## with: +## upload-to-codecov: true +## codecov_flags: unit,integration +## codecov_name: smoothcrawler-appintegration_github-actions_test # optional +# +# +# coveralls_finish: +## name: Organize and generate the testing report and upload it to Coveralls +## if: github.ref_name == 'release' || github.ref_name == 'master' +## needs: [unit-test_codecov, integration-test_codecov] +# needs: [all-test_codecov] +# uses: ./.github/workflows/upload_test_cov_report_to_coveralls.yaml +# secrets: +# coveralls_token: ${{ secrets.COVERALLS_TOKEN }} +## with: +## upload-to-coveralls: true +# +# +# codacy_finish: +## name: Upload test report to Codacy to analyse and record code quality +## needs: [unit-test_codecov, integration-test_codecov] +# needs: [all-test_codecov] +# uses: ./.github/workflows/upload_code_report_to_codacy.yaml +# secrets: +# codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} +## with: +## upload-to-codacy: true # pre-building_check: From 157d566c787d9ce896b8601bfad4fe5fdae0185e Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 20:36:27 +0800 Subject: [PATCH 099/241] test --- .github/workflows/organize_and_generate_testing_reports.yaml | 2 ++ .github/workflows/run_test_items_via_pytest.yaml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/organize_and_generate_testing_reports.yaml b/.github/workflows/organize_and_generate_testing_reports.yaml index 24b3e97d..37531a60 100644 --- a/.github/workflows/organize_and_generate_testing_reports.yaml +++ b/.github/workflows/organize_and_generate_testing_reports.yaml @@ -56,6 +56,8 @@ jobs: python3 -m pip install --upgrade pip pip3 install -U pip pip3 install coverage + pip3 install codecov + pip3 install coveralls - name: Combine all testing code coverage result files with one specific test type if: ${{ inputs.test_type == 'unit-test' || inputs.test_type == 'integration-test' }} diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index a3918074..aae12f6f 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -67,7 +67,7 @@ jobs: # python-version: [3.6,3.7,3.8,3.9,'3.10'] # os: [ubuntu-18.04,ubuntu-20.04,ubuntu-22.04,macos-10.15,macos-11,macos-12] python-version: ['3.10'] - os: [ubuntu-22.04,macos-11] + os: [ubuntu-22.04] exclude: - os: ubuntu-18.04 python-version: 3.6 From 7ede3b2d247d2cd28f4912a1da7d13eb67242fa7 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 20:46:36 +0800 Subject: [PATCH 100/241] [Test] (config) For testing. --- .../workflows/run_test_items_via_pytest.yaml | 52 +++++++++++++++++++ .../workflows/test-reusable-workflows.yaml | 30 +++++++---- 2 files changed, 71 insertions(+), 11 deletions(-) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index aae12f6f..63a43dc0 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -57,6 +57,17 @@ on: required: false default: app + secrets: + codecov_token: + description: "The API token for uploading testing coverage report to Codecov." + required: false + coveralls_token: + description: "The API token for uploading testing coverage report to Coveralls." + required: false + codacy_token: + description: "The API token for uploading testing coverage report to Codacy." + required: false + jobs: run_test_items: @@ -120,6 +131,47 @@ jobs: run: pytest ${{ matrix.test-path }} continue-on-error: true + - name: Combine all testing code coverage result files with all test types + run: | + coverage report + coverage xml + + - name: Upload coverage report to Codecov https://codecov.io +# if: ${{ inputs.upload-to-codecov == true }} +#### Way 1 +# run: bash <(curl -s https://codecov.io/bash) +#### Way 2 + run: codecov -t ${{ secrets.codecov_token }} +#### Way 3 +# uses: codecov/codecov-action@v2 +# with: +# file: .coverage +# token: ${{ secrets.codecov_token }} # not required for public repos +# files: ./coverage.xml +## flags: ${{ inputs.codecov_flags }} # optional +## env_vars: OS,PYTHON # optional +## name: ${{ inputs.codecov_name }} # optional +# fail_ci_if_error: true # optional (default = false) +# verbose: true # optional (default = false) + + - name: Install Python dependencies about tool of Coveralls +# if: ${{ inputs.upload-to-coveralls == true }} + run: pip3 install coveralls + + - name: Upload coverage report to Coveralls https://coveralls.io +# if: ${{ inputs.upload-to-coveralls == true }} + env: + GITHUB_TOKEN: ${{ secrets.coveralls_token }} + run: coveralls --verbose + + - name: Upload testing report to Codacy https://app.codacy.com/ +# if: ${{ inputs.upload-to-codacy == true }} + uses: codacy/codacy-coverage-reporter-action@v1 + with: + project-token: ${{ secrets.codacy_token }} + coverage-reports: coverage.xml +# coverage-reports: cobertura.xml + - name: Rename the code coverage result file run: mv ./.coverage ./.coverage.${{ inputs.test_type }}.${{ matrix.os }}-${{ matrix.python-version }} diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index dd0c4d30..14cffd02 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -49,6 +49,10 @@ jobs: with: test_type: unit-test all_test_items_paths: ${{needs.prep-testbed_unit-test.outputs.all_test_items}} + secrets: + codecov_token: ${{ secrets.CODECOV_TOKEN }} + coveralls_token: ${{ secrets.COVERALLS_TOKEN }} + codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} run_integration-test: @@ -63,6 +67,10 @@ jobs: http_server_port: 30303 http_server_app_module: _http_server.app http_server_enter_point: app + secrets: + codecov_token: ${{ secrets.CODECOV_TOKEN }} + coveralls_token: ${{ secrets.COVERALLS_TOKEN }} + codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} # unit-test_codecov: @@ -83,17 +91,17 @@ jobs: ## generate_xml_report_finally: false - all-test_codecov: -# name: Organize and generate the testing report and upload it to Codecov -# needs: [unit-test_codecov, integration-test_codecov] - needs: [run_unit-test, run_integration-test] - uses: ./.github/workflows/organize_and_generate_testing_reports.yaml - with: - test_type: all-test - secrets: - codecov_token: ${{ secrets.CODECOV_TOKEN }} - coveralls_token: ${{ secrets.COVERALLS_TOKEN }} - codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} +# all-test_codecov: +## name: Organize and generate the testing report and upload it to Codecov +## needs: [unit-test_codecov, integration-test_codecov] +# needs: [run_unit-test, run_integration-test] +# uses: ./.github/workflows/organize_and_generate_testing_reports.yaml +# with: +# test_type: all-test +# secrets: +# codecov_token: ${{ secrets.CODECOV_TOKEN }} +# coveralls_token: ${{ secrets.COVERALLS_TOKEN }} +# codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} # unit-codecov_finish: From f4524782274fb4fcfd73c959014e3e9bcc565e22 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 21:01:28 +0800 Subject: [PATCH 101/241] [Test] (config) For testing. --- .../workflows/run_test_items_via_pytest.yaml | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index 63a43dc0..42323bcc 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -164,21 +164,24 @@ jobs: GITHUB_TOKEN: ${{ secrets.coveralls_token }} run: coveralls --verbose + - name: Generate testing report for Codacy + run: mv ./coverage.xml ./cobertura.xml + - name: Upload testing report to Codacy https://app.codacy.com/ # if: ${{ inputs.upload-to-codacy == true }} uses: codacy/codacy-coverage-reporter-action@v1 with: project-token: ${{ secrets.codacy_token }} - coverage-reports: coverage.xml -# coverage-reports: cobertura.xml +# coverage-reports: coverage.xml + coverage-reports: cobertura.xml - - name: Rename the code coverage result file - run: mv ./.coverage ./.coverage.${{ inputs.test_type }}.${{ matrix.os }}-${{ matrix.python-version }} +# - name: Rename the code coverage result file +# run: mv ./.coverage ./.coverage.${{ inputs.test_type }}.${{ matrix.os }}-${{ matrix.python-version }} - - name: Upload code coverage result file - uses: actions/upload-artifact@v3 - with: - name: coverage - path: .coverage.${{ inputs.test_type }}.${{ matrix.os }}-${{ matrix.python-version }} - if-no-files-found: error +# - name: Upload code coverage result file +# uses: actions/upload-artifact@v3 +# with: +# name: coverage +# path: .coverage.${{ inputs.test_type }}.${{ matrix.os }}-${{ matrix.python-version }} +# if-no-files-found: error From c9d69916a8e604c17adbc2a6a71c23ab258e29c2 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 21:35:23 +0800 Subject: [PATCH 102/241] [Test] (config) For testing. --- .../workflows/run_test_items_via_pytest.yaml | 4 +++ .../workflows/test-reusable-workflows.yaml | 25 ++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index 42323bcc..5c6b4a22 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -64,6 +64,9 @@ on: coveralls_token: description: "The API token for uploading testing coverage report to Coveralls." required: false + codacy_api_token: + description: "The API token for uploading testing coverage report to Codacy." + required: false codacy_token: description: "The API token for uploading testing coverage report to Codacy." required: false @@ -171,6 +174,7 @@ jobs: # if: ${{ inputs.upload-to-codacy == true }} uses: codacy/codacy-coverage-reporter-action@v1 with: + api-token: ${{ secrets.codacy_api_token }} project-token: ${{ secrets.codacy_token }} # coverage-reports: coverage.xml coverage-reports: cobertura.xml diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 14cffd02..6ddd4c8e 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -42,17 +42,17 @@ jobs: shell_arg: unix - run_unit-test: -# name: Run all unit test items - needs: prep-testbed_unit-test - uses: ./.github/workflows/run_test_items_via_pytest.yaml - with: - test_type: unit-test - all_test_items_paths: ${{needs.prep-testbed_unit-test.outputs.all_test_items}} - secrets: - codecov_token: ${{ secrets.CODECOV_TOKEN }} - coveralls_token: ${{ secrets.COVERALLS_TOKEN }} - codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} +# run_unit-test: +## name: Run all unit test items +# needs: prep-testbed_unit-test +# uses: ./.github/workflows/run_test_items_via_pytest.yaml +# with: +# test_type: unit-test +# all_test_items_paths: ${{needs.prep-testbed_unit-test.outputs.all_test_items}} +# secrets: +# codecov_token: ${{ secrets.CODECOV_TOKEN }} +# coveralls_token: ${{ secrets.COVERALLS_TOKEN }} +# codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} run_integration-test: @@ -70,7 +70,8 @@ jobs: secrets: codecov_token: ${{ secrets.CODECOV_TOKEN }} coveralls_token: ${{ secrets.COVERALLS_TOKEN }} - codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} + codacy_api_token: ${{ secrets.CODACY_API_TOKEN }} +# codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} # unit-test_codecov: From 6649aeeb1a134c6e98f7c7eaef8c9d37819cb13d Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 21:39:55 +0800 Subject: [PATCH 103/241] [Test] (config) For testing 1. --- .github/workflows/test-reusable-workflows.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 6ddd4c8e..886ffcec 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -70,8 +70,8 @@ jobs: secrets: codecov_token: ${{ secrets.CODECOV_TOKEN }} coveralls_token: ${{ secrets.COVERALLS_TOKEN }} - codacy_api_token: ${{ secrets.CODACY_API_TOKEN }} -# codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} +# codacy_api_token: ${{ secrets.CODACY_API_TOKEN }} + codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} # unit-test_codecov: From 81f8c6b96903ed05b70389e909fabeddf2bd99ad Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 22:08:10 +0800 Subject: [PATCH 104/241] [Refactor + Test] (config) Modify to use newer reusable 'organize_and_generate_test_cov_reports.yaml'. --- ...rganize_and_generate_test_cov_reports.yaml | 77 +++++++++++ ...organize_and_generate_testing_reports.yaml | 128 ------------------ 2 files changed, 77 insertions(+), 128 deletions(-) create mode 100644 .github/workflows/organize_and_generate_test_cov_reports.yaml delete mode 100644 .github/workflows/organize_and_generate_testing_reports.yaml diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml new file mode 100644 index 00000000..752bf642 --- /dev/null +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -0,0 +1,77 @@ +############################################################################ +# +# Workflow Description: +# Organize all the testing coverage reports. (it would save reports by 'actions/upload-artifact@v3'). +# +# Workflow input parameters: +# * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'. +# +# Workflow running output: +# No, but it would save the testing coverage reports (coverage.xml) to provide after-process to organize and record. +# +############################################################################ + +name: Organize all testing coverage reports which be tested in many different runtime OS and Python version as a testing coverage report + +on: + workflow_call: + inputs: + test_type: + description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'." + required: true + type: string + + +jobs: + organize_and_generate_test_reports: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Download code coverage result file + uses: actions/download-artifact@v3 + with: + name: coverage + path: ./ + + - name: Setup Python 3.10 in Ubuntu OS + uses: actions/setup-python@v2 + with: + python-version: '3.10' + + - name: Install Python tool 'coverage' + run: | + python3 -m pip install --upgrade pip + pip3 install -U pip + pip3 install coverage + pip3 install codecov + pip3 install coveralls + + - name: Combine all testing code coverage result files with one specific test type + if: ${{ inputs.test_type == 'unit-test' || inputs.test_type == 'integration-test' }} + run: coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.${{ inputs.test_type }}.* + + - name: Combine all testing code coverage result files with all test types + if: ${{ inputs.test_type == 'all-test' }} + run: coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.* + + - name: Report testing coverage of project code + run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} + + - name: General testing coverage report as XML format with ${{ inputs.test_type }} + run: coverage xml --data-file=.coverage.${{ inputs.test_type }} -o coverage_${{ inputs.test_type }}.xml + + - name: Upload testing coverage report (.coverage) + uses: actions/upload-artifact@v3 + with: + name: test_coverage_report + path: .coverage.${{ inputs.test_type }} + if-no-files-found: error + + - name: Upload testing coverage report (.xml) + uses: actions/upload-artifact@v3 + with: + name: test_coverage_xml_report + path: coverage_${{ inputs.test_type }}.xml + if-no-files-found: error diff --git a/.github/workflows/organize_and_generate_testing_reports.yaml b/.github/workflows/organize_and_generate_testing_reports.yaml deleted file mode 100644 index 37531a60..00000000 --- a/.github/workflows/organize_and_generate_testing_reports.yaml +++ /dev/null @@ -1,128 +0,0 @@ -############################################################################ -# -# Workflow Description: -# Organize all the testing coverage reports. (it would save reports by 'actions/upload-artifact@v3'). -# -# Workflow input parameters: -# * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'. -# -# Workflow running output: -# No, but it would save the testing coverage reports (coverage.xml) to provide after-process to organize and record. -# -############################################################################ - -name: Organize all testing coverage reports which be tested in many different runtime OS and Python version as a testing coverage report - -on: - workflow_call: - inputs: - test_type: - description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'." - required: true - type: string - - secrets: - codecov_token: - description: "The API token for uploading testing coverage report to Codecov." - required: false - coveralls_token: - description: "The API token for uploading testing coverage report to Coveralls." - required: false - codacy_token: - description: "The API token for uploading testing coverage report to Codacy." - required: false - - -jobs: - organize_and_generate_test_reports: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Download code coverage result file - uses: actions/download-artifact@v3 - with: - name: coverage - path: ./ - - - name: Setup Python 3.10 in Ubuntu OS - uses: actions/setup-python@v2 - with: - python-version: '3.10' - - - name: Install Python tool 'coverage' - run: | - python3 -m pip install --upgrade pip - pip3 install -U pip - pip3 install coverage - pip3 install codecov - pip3 install coveralls - - - name: Combine all testing code coverage result files with one specific test type - if: ${{ inputs.test_type == 'unit-test' || inputs.test_type == 'integration-test' }} - run: coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.${{ inputs.test_type }}.* - - - name: Combine all testing code coverage result files with all test types - if: ${{ inputs.test_type == 'all-test' }} - run: | - coverage combine --data-file=.coverage .coverage.* - coverage report - coverage xml - -# - name: Report testing coverage of project code -# run: coverage report -m --data-file=.coverage.${{ inputs.test_type }} -# -# - name: General testing coverage report as XML format with ${{ inputs.test_type }} -# run: coverage xml --data-file=.coverage.${{ inputs.test_type }} -o coverage_${{ inputs.test_type }}.xml - -# - name: Upload testing coverage report (.coverage) -# uses: actions/upload-artifact@v3 -# with: -# name: final_project_testing_coverage_report -## path: .coverage.${{ inputs.test_type }} -# path: .coverage -# if-no-files-found: error -# -# - name: Upload testing coverage report (.xml) -# uses: actions/upload-artifact@v3 -# with: -# name: final_project_testing_coverage_xml_report -# path: coverage_${{ inputs.test_type }}.xml -# if-no-files-found: error - - - name: Upload coverage report to Codecov https://codecov.io -# if: ${{ inputs.upload-to-codecov == true }} -#### Way 1 -# run: bash <(curl -s https://codecov.io/bash) -#### Way 2 - run: codecov -t ${{ secrets.codecov_token }} -#### Way 3 -# uses: codecov/codecov-action@v2 -# with: -# file: .coverage -# token: ${{ secrets.codecov_token }} # not required for public repos -# files: ./coverage.xml -## flags: ${{ inputs.codecov_flags }} # optional -## env_vars: OS,PYTHON # optional -## name: ${{ inputs.codecov_name }} # optional -# fail_ci_if_error: true # optional (default = false) -# verbose: true # optional (default = false) - - - name: Install Python dependencies about tool of Coveralls -# if: ${{ inputs.upload-to-coveralls == true }} - run: pip3 install coveralls - - - name: Upload coverage report to Coveralls https://coveralls.io -# if: ${{ inputs.upload-to-coveralls == true }} - env: - GITHUB_TOKEN: ${{ secrets.coveralls_token }} - run: coveralls --verbose - - - name: Upload testing report to Codacy https://app.codacy.com/ -# if: ${{ inputs.upload-to-codacy == true }} - uses: codacy/codacy-coverage-reporter-action@v1 - with: - project-token: ${{ secrets.codacy_token }} - coverage-reports: coverage.xml -# coverage-reports: cobertura.xml From a1419c4a89e735641cd093468e42331e6290a728 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 22:08:47 +0800 Subject: [PATCH 105/241] [Test] (config) For testing. --- .github/workflows/upload_test_cov_report.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 3ad42af5..4fad50dd 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -78,7 +78,7 @@ jobs: - name: Download code coverage result files which has be handled by different test type process uses: actions/download-artifact@v3 with: - name: final_project_testing_coverage_report + name: test_coverage_report path: ${{ inputs.download_path }} - name: Install Python 3.10 @@ -107,10 +107,12 @@ jobs: - name: Upload coverage report to Codecov https://codecov.io if: ${{ inputs.upload-to-codecov == true }} + run: codecov -t ${{ secrets.codecov_token }} + #### Way 1 # run: bash <(curl -s https://codecov.io/bash) #### Way 2 - run: codecov -t ${{ secrets.codecov_token }} +# run: codecov -t ${{ secrets.codecov_token }} #### Way 3 # uses: codecov/codecov-action@v2 # with: @@ -138,5 +140,7 @@ jobs: uses: codacy/codacy-coverage-reporter-action@v1 with: project-token: ${{ secrets.codacy_token }} - coverage-reports: coverage.xml + coverage-reports: coverage_integration-test.xml +# coverage-reports: coverage_unit-test.xml,coverage_integration-test.xml +# coverage-reports: coverage.xml # coverage-reports: cobertura.xml From e8b3acf8a630f77e75b38f6b636f30364a47ad9f Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 22:09:11 +0800 Subject: [PATCH 106/241] [Test] (config) For testing. --- .../workflows/run_test_items_via_pytest.yaml | 73 ++----------------- 1 file changed, 7 insertions(+), 66 deletions(-) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index 5c6b4a22..aae12f6f 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -57,20 +57,6 @@ on: required: false default: app - secrets: - codecov_token: - description: "The API token for uploading testing coverage report to Codecov." - required: false - coveralls_token: - description: "The API token for uploading testing coverage report to Coveralls." - required: false - codacy_api_token: - description: "The API token for uploading testing coverage report to Codacy." - required: false - codacy_token: - description: "The API token for uploading testing coverage report to Codacy." - required: false - jobs: run_test_items: @@ -134,58 +120,13 @@ jobs: run: pytest ${{ matrix.test-path }} continue-on-error: true - - name: Combine all testing code coverage result files with all test types - run: | - coverage report - coverage xml - - - name: Upload coverage report to Codecov https://codecov.io -# if: ${{ inputs.upload-to-codecov == true }} -#### Way 1 -# run: bash <(curl -s https://codecov.io/bash) -#### Way 2 - run: codecov -t ${{ secrets.codecov_token }} -#### Way 3 -# uses: codecov/codecov-action@v2 -# with: -# file: .coverage -# token: ${{ secrets.codecov_token }} # not required for public repos -# files: ./coverage.xml -## flags: ${{ inputs.codecov_flags }} # optional -## env_vars: OS,PYTHON # optional -## name: ${{ inputs.codecov_name }} # optional -# fail_ci_if_error: true # optional (default = false) -# verbose: true # optional (default = false) + - name: Rename the code coverage result file + run: mv ./.coverage ./.coverage.${{ inputs.test_type }}.${{ matrix.os }}-${{ matrix.python-version }} - - name: Install Python dependencies about tool of Coveralls -# if: ${{ inputs.upload-to-coveralls == true }} - run: pip3 install coveralls - - - name: Upload coverage report to Coveralls https://coveralls.io -# if: ${{ inputs.upload-to-coveralls == true }} - env: - GITHUB_TOKEN: ${{ secrets.coveralls_token }} - run: coveralls --verbose - - - name: Generate testing report for Codacy - run: mv ./coverage.xml ./cobertura.xml - - - name: Upload testing report to Codacy https://app.codacy.com/ -# if: ${{ inputs.upload-to-codacy == true }} - uses: codacy/codacy-coverage-reporter-action@v1 + - name: Upload code coverage result file + uses: actions/upload-artifact@v3 with: - api-token: ${{ secrets.codacy_api_token }} - project-token: ${{ secrets.codacy_token }} -# coverage-reports: coverage.xml - coverage-reports: cobertura.xml - -# - name: Rename the code coverage result file -# run: mv ./.coverage ./.coverage.${{ inputs.test_type }}.${{ matrix.os }}-${{ matrix.python-version }} - -# - name: Upload code coverage result file -# uses: actions/upload-artifact@v3 -# with: -# name: coverage -# path: .coverage.${{ inputs.test_type }}.${{ matrix.os }}-${{ matrix.python-version }} -# if-no-files-found: error + name: coverage + path: .coverage.${{ inputs.test_type }}.${{ matrix.os }}-${{ matrix.python-version }} + if-no-files-found: error From 015364f7210ae761b5566a38504e1c87487bb689 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 22:13:41 +0800 Subject: [PATCH 107/241] [Test] (config) For testing. --- .../workflows/test-reusable-workflows.yaml | 115 ++++++++---------- 1 file changed, 53 insertions(+), 62 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 886ffcec..8596fb93 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -26,20 +26,20 @@ on: jobs: - prep-testbed_unit-test: -# name: Prepare all unit test items - uses: ./.github/workflows/prepare_test_items.yaml - with: - shell_path: scripts/ci/get-unit-test-paths.sh - shell_arg: unix +# prep-testbed_unit-test: +## name: Prepare all unit test items +# uses: ./.github/workflows/prepare_test_items.yaml +# with: +# shell_path: scripts/ci/get-unit-test-paths.sh +# shell_arg: unix prep-testbed_integration-test: -# name: Prepare all integration test items uses: ./.github/workflows/prepare_test_items.yaml with: shell_path: scripts/ci/get-integration-test-paths.sh shell_arg: unix +# name: Prepare all integration test items # run_unit-test: @@ -49,14 +49,9 @@ jobs: # with: # test_type: unit-test # all_test_items_paths: ${{needs.prep-testbed_unit-test.outputs.all_test_items}} -# secrets: -# codecov_token: ${{ secrets.CODECOV_TOKEN }} -# coveralls_token: ${{ secrets.COVERALLS_TOKEN }} -# codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} run_integration-test: -# name: Run all integration test items. This testing would test the code with other resource or system to ensure the features work finely. needs: prep-testbed_integration-test uses: ./.github/workflows/run_test_items_via_pytest.yaml with: @@ -67,11 +62,7 @@ jobs: http_server_port: 30303 http_server_app_module: _http_server.app http_server_enter_point: app - secrets: - codecov_token: ${{ secrets.CODECOV_TOKEN }} - coveralls_token: ${{ secrets.COVERALLS_TOKEN }} -# codacy_api_token: ${{ secrets.CODACY_API_TOKEN }} - codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} +# name: Run all integration test items. This testing would test the code with other resource or system to ensure the features work finely. # unit-test_codecov: @@ -80,16 +71,14 @@ jobs: # uses: ./.github/workflows/organize_and_generate_testing_reports.yaml # with: # test_type: unit-test -## generate_xml_report_finally: false -# -# -# integration-test_codecov: -## name: Organize and generate the testing report and upload it to Codecov -# needs: run_integration-test -# uses: ./.github/workflows/organize_and_generate_testing_reports.yaml -# with: -# test_type: integration-test -## generate_xml_report_finally: false + + + integration-test_codecov: + needs: run_integration-test + uses: ./.github/workflows/organize_and_generate_test_cov_reports.yaml + with: + test_type: integration-test +# name: Organize and generate the testing report and upload it to Codecov # all-test_codecov: @@ -133,41 +122,43 @@ jobs: # codecov_name: smoothcrawler-appintegration_github-actions_test # optional -# codecov_finish: -## name: Organize and generate the testing report and upload it to Codecov -## if: github.ref_name == 'release' || github.ref_name == 'master' -## needs: [unit-test_codecov, integration-test_codecov] -# needs: [all-test_codecov] -# uses: ./.github/workflows/upload_test_cov_report_to_codecov.yaml -# secrets: -# codecov_token: ${{ secrets.CODECOV_TOKEN }} -## with: -## upload-to-codecov: true -## codecov_flags: unit,integration -## codecov_name: smoothcrawler-appintegration_github-actions_test # optional -# -# -# coveralls_finish: -## name: Organize and generate the testing report and upload it to Coveralls -## if: github.ref_name == 'release' || github.ref_name == 'master' -## needs: [unit-test_codecov, integration-test_codecov] -# needs: [all-test_codecov] -# uses: ./.github/workflows/upload_test_cov_report_to_coveralls.yaml -# secrets: -# coveralls_token: ${{ secrets.COVERALLS_TOKEN }} -## with: -## upload-to-coveralls: true -# -# -# codacy_finish: -## name: Upload test report to Codacy to analyse and record code quality -## needs: [unit-test_codecov, integration-test_codecov] -# needs: [all-test_codecov] -# uses: ./.github/workflows/upload_code_report_to_codacy.yaml -# secrets: -# codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} -## with: -## upload-to-codacy: true + codecov_finish: + needs: [integration-test_codecov] + uses: ./.github/workflows/upload_test_cov_report_to_codecov.yaml + secrets: + codecov_token: ${{ secrets.CODECOV_TOKEN }} + with: + upload-to-codecov: true + +# name: Organize and generate the testing report and upload it to Codecov +# if: github.ref_name == 'release' || github.ref_name == 'master' +# needs: [unit-test_codecov, integration-test_codecov] + +# codecov_flags: unit,integration +# codecov_name: smoothcrawler-appintegration_github-actions_test # optional + + + coveralls_finish: + needs: [integration-test_codecov] + uses: ./.github/workflows/upload_test_cov_report_to_coveralls.yaml + secrets: + coveralls_token: ${{ secrets.COVERALLS_TOKEN }} + with: + upload-to-coveralls: true +# name: Organize and generate the testing report and upload it to Coveralls +# if: github.ref_name == 'release' || github.ref_name == 'master' +# needs: [unit-test_codecov, integration-test_codecov] + + + codacy_finish: + needs: [integration-test_codecov] + uses: ./.github/workflows/upload_code_report_to_codacy.yaml + secrets: + codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} + with: + upload-to-codacy: true +# name: Upload test report to Codacy to analyse and record code quality +# needs: [unit-test_codecov, integration-test_codecov] # pre-building_check: From 5eb637198247d7d9d900d9346adaf5355a69c14f Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 22:15:03 +0800 Subject: [PATCH 108/241] [Test] (config) For testing 11. --- .github/workflows/test-reusable-workflows.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 8596fb93..46794e5d 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -124,7 +124,7 @@ jobs: codecov_finish: needs: [integration-test_codecov] - uses: ./.github/workflows/upload_test_cov_report_to_codecov.yaml + uses: ./.github/workflows/upload_test_cov_report.yaml secrets: codecov_token: ${{ secrets.CODECOV_TOKEN }} with: @@ -140,7 +140,7 @@ jobs: coveralls_finish: needs: [integration-test_codecov] - uses: ./.github/workflows/upload_test_cov_report_to_coveralls.yaml + uses: ./.github/workflows/upload_test_cov_report.yaml secrets: coveralls_token: ${{ secrets.COVERALLS_TOKEN }} with: @@ -152,7 +152,7 @@ jobs: codacy_finish: needs: [integration-test_codecov] - uses: ./.github/workflows/upload_code_report_to_codacy.yaml + uses: ./.github/workflows/upload_test_cov_report.yaml secrets: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} with: From ffda444317165cca3a32fa28e7e76b21e2210aff Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 22:25:15 +0800 Subject: [PATCH 109/241] [Test] (config) For testing 11. --- .coveragerc | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 3834c598..00000000 --- a/.coveragerc +++ /dev/null @@ -1,11 +0,0 @@ -# # This test directory for testing to simulate a Python library project structure. - -[run] -parallel = True -relative_files = True -source=./test_gh_workflow - -omit = - */__init__.py - -#ignore_errors = True From 71ad94ef8bcd75603ad1637450630ca24649d94e Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 22:25:33 +0800 Subject: [PATCH 110/241] [Test] (config) For testing 11. --- .coveralls.yml | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 .coveralls.yml diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index 2cef687c..00000000 --- a/.coveralls.yml +++ /dev/null @@ -1,2 +0,0 @@ -service_name: github -repo_token: $COVERALLS_REPO_TOKEN From 46f595c7b321be6adfe1c675ad451770e705b94a Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 22:26:10 +0800 Subject: [PATCH 111/241] [Test] (config) For testing 11. --- sample_Dockerfile | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 sample_Dockerfile diff --git a/sample_Dockerfile b/sample_Dockerfile deleted file mode 100644 index fa6047c6..00000000 --- a/sample_Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -################################################################### -# -# Description: -# Build and run HTTP server for testing -# -################################################################### - -FROM python:3.10 - -WORKDIR ./sample-project/ - -# # Prepare the runtime environment for Python -RUN pip install -U pip - -# # Install the Python dependencies for development -COPY ./requirements/requirements-test.txt ./requirements/ - -RUN pip install -U -r ./requirements/requirements-test.txt - -# # Install some internet tool for debug if it needs -RUN apt-get update && \ - apt-get install -y iputils-ping && \ - apt-get install -y net-tools && \ - apt-get install --no-install-recommends --assume-yes netcat - -# # Copy package code, testing code and scripts to container -COPY ./test/ ./test/ - -CMD python3 ./test/_http_server/app.py From 92367404207d72aac214a2d9d802b2f71c9e88c1 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 22:26:33 +0800 Subject: [PATCH 112/241] [Test] (config) For testing 11. --- codecov.yml | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index 570e5a5c..00000000 --- a/codecov.yml +++ /dev/null @@ -1,5 +0,0 @@ -# # This test directory for testing to simulate a Python library project structure. - -codecov: - token: $CODECOV_TOKEN - max_report_age: off From b339a188cc549aa7fbe353b3bf5bd520d9a36f2e Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 22:27:29 +0800 Subject: [PATCH 113/241] [Test] (config) For testing 13. --- .github/workflows/upload_test_cov_report.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 4fad50dd..5d8b283a 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -81,6 +81,12 @@ jobs: name: test_coverage_report path: ${{ inputs.download_path }} + - name: Download code coverage result files which has be handled by different test type process + uses: actions/download-artifact@v3 + with: + name: test_coverage_xml_report + path: ${{ inputs.download_path }} + - name: Install Python 3.10 uses: actions/setup-python@v2 with: From 59bd0ceac1244eb4d690b68c98ba1920e527c8ec Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 22:29:27 +0800 Subject: [PATCH 114/241] [Test] (config) For testing 14. --- pytest.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest.ini b/pytest.ini index 2f66d7ab..62c7e106 100644 --- a/pytest.ini +++ b/pytest.ini @@ -6,7 +6,7 @@ minversion = 0.1.0 addopts = --cov=./test_gh_workflow - --cov-config=./.coveragerc +; --cov-config=./.coveragerc -r a -v --reruns 3 From cf1698fbcd713724712349b6db62a297bfeef612 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 22:37:21 +0800 Subject: [PATCH 115/241] [Test] (config) For testing with configuration of coverage tool. --- .coveragerc | 30 ++++++++++++++++++++++++++++++ pytest.ini | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..c6cecab1 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,30 @@ +[run] +#parallel = True +relative_files = True +source=./test_gh_workflow + +omit = + */__init__.py + + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + # Don't complain about missing debug-only code: + def __str__ + def __repr__ + if self\.debug + + # Don't complain if tests don't hit defensive assertion code: + raise AssertionError + raise NotImplementedError + + # Don't complain if non-runnable code isn't run: +# if 0: +# if __name__ == .__main__.: + + # Don't complain about abstract methods, they aren't run: + @(abc\.)?abstractmethod + +#ignore_errors = True + diff --git a/pytest.ini b/pytest.ini index 62c7e106..2f66d7ab 100644 --- a/pytest.ini +++ b/pytest.ini @@ -6,7 +6,7 @@ minversion = 0.1.0 addopts = --cov=./test_gh_workflow -; --cov-config=./.coveragerc + --cov-config=./.coveragerc -r a -v --reruns 3 From 460db6fade74cc481d217fbd02230f4fdf67cae6 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 22:41:36 +0800 Subject: [PATCH 116/241] [Test] (config) Comment out setting 'relative_files' in configuration of coverage tool. --- .coveragerc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coveragerc b/.coveragerc index c6cecab1..8494fe7c 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,6 @@ [run] #parallel = True -relative_files = True +#relative_files = True source=./test_gh_workflow omit = From 2ee481699bcb7ade23a8360d3c138b6bd0f8e464 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 22:48:53 +0800 Subject: [PATCH 117/241] [Test] (config) Add setting 'parallel' in configuration of coverage tool. --- .coveragerc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coveragerc b/.coveragerc index 8494fe7c..479fcc1f 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,5 +1,5 @@ [run] -#parallel = True +parallel = True #relative_files = True source=./test_gh_workflow From 078acad5b3729a4f83e959d26f02456eebf7396d Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 22:59:03 +0800 Subject: [PATCH 118/241] [Test] (config) Remove all settings of section 'report' in configuration of coverage tool. --- .coveragerc | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/.coveragerc b/.coveragerc index 479fcc1f..2dfab0db 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,30 +1,6 @@ [run] parallel = True -#relative_files = True source=./test_gh_workflow omit = */__init__.py - - -[report] -# Regexes for lines to exclude from consideration -exclude_lines = - # Don't complain about missing debug-only code: - def __str__ - def __repr__ - if self\.debug - - # Don't complain if tests don't hit defensive assertion code: - raise AssertionError - raise NotImplementedError - - # Don't complain if non-runnable code isn't run: -# if 0: -# if __name__ == .__main__.: - - # Don't complain about abstract methods, they aren't run: - @(abc\.)?abstractmethod - -#ignore_errors = True - From 7a1fd1fb8f3a1af297cb71992b0a6a6646b9f0dc Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 23:03:56 +0800 Subject: [PATCH 119/241] [Test] (config) Test for uploading testing coverage reports feature of Codacy. --- .github/workflows/upload_test_cov_report.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 5d8b283a..371ed671 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -146,7 +146,7 @@ jobs: uses: codacy/codacy-coverage-reporter-action@v1 with: project-token: ${{ secrets.codacy_token }} - coverage-reports: coverage_integration-test.xml + coverage-reports: coverage.xml +# coverage-reports: coverage_integration-test.xml # coverage-reports: coverage_unit-test.xml,coverage_integration-test.xml -# coverage-reports: coverage.xml # coverage-reports: cobertura.xml From 95ea45f2920056a4277dd5f1fced4fe425f5ba7a Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 23:19:48 +0800 Subject: [PATCH 120/241] [Test] (config) Add setting 'branch' in configuration of coverage tool. --- .coveragerc | 1 + 1 file changed, 1 insertion(+) diff --git a/.coveragerc b/.coveragerc index 2dfab0db..b6ca4893 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,4 +1,5 @@ [run] +branch = True parallel = True source=./test_gh_workflow From 367b80c697fba74c2e4aa7801a06ba9370310995 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 23:27:32 +0800 Subject: [PATCH 121/241] [Test] (config) Modify the reusable workflow. --- .github/workflows/test-reusable-workflows.yaml | 7 ++++--- .github/workflows/upload_code_report_to_codacy.yaml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 46794e5d..999e727a 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -152,11 +152,12 @@ jobs: codacy_finish: needs: [integration-test_codecov] - uses: ./.github/workflows/upload_test_cov_report.yaml + uses: ./.github/workflows/upload_code_report_to_codacy.yaml secrets: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} - with: - upload-to-codacy: true +# uses: ./.github/workflows/upload_test_cov_report.yaml +# with: +# upload-to-codacy: true # name: Upload test report to Codacy to analyse and record code quality # needs: [unit-test_codecov, integration-test_codecov] diff --git a/.github/workflows/upload_code_report_to_codacy.yaml b/.github/workflows/upload_code_report_to_codacy.yaml index 40ad5ee6..8c499f72 100644 --- a/.github/workflows/upload_code_report_to_codacy.yaml +++ b/.github/workflows/upload_code_report_to_codacy.yaml @@ -50,6 +50,6 @@ jobs: with: project-token: ${{ secrets.codacy_token }} # coverage-reports: coverage_unit-test.xml,coverage_integration-test.xml - coverage-reports: coverage_all-test.xml + coverage-reports: coverage_integration-test.xml # coverage-reports: cobertura.xml From 780b8562edde1b5840c0ee00b03c14d7d4d59c35 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 25 Aug 2022 23:31:08 +0800 Subject: [PATCH 122/241] [Test] (config) Modify the reusable workflow. --- .github/workflows/upload_code_report_to_codacy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload_code_report_to_codacy.yaml b/.github/workflows/upload_code_report_to_codacy.yaml index 8c499f72..87969d2e 100644 --- a/.github/workflows/upload_code_report_to_codacy.yaml +++ b/.github/workflows/upload_code_report_to_codacy.yaml @@ -42,7 +42,7 @@ jobs: - name: Download testing coverage report uses: actions/download-artifact@v3 with: - name: final_project_testing_coverage_xml_report + name: test_coverage_xml_report path: ${{ inputs.download_path }} - name: Upload testing report to Codacy From e3398f394d875cbdd63f09c8381a8859fe818f9d Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 07:25:33 +0800 Subject: [PATCH 123/241] [Breaking Change] (config) Modify the command line at step 'upload to Codecov' and modify file path at step 'upload to Codacy'. --- .github/workflows/upload_test_cov_report.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 371ed671..d9174591 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -113,7 +113,10 @@ jobs: - name: Upload coverage report to Codecov https://codecov.io if: ${{ inputs.upload-to-codecov == true }} - run: codecov -t ${{ secrets.codecov_token }} + run: | + codecov -t ${{ secrets.codecov_token }} --file coverage_integration-test.xml --flags unit,integration --env OS,PYTHON --name gh_workflow_template --branch develop + +# run: codecov -t ${{ secrets.codecov_token }} #### Way 1 # run: bash <(curl -s https://codecov.io/bash) @@ -146,7 +149,7 @@ jobs: uses: codacy/codacy-coverage-reporter-action@v1 with: project-token: ${{ secrets.codacy_token }} - coverage-reports: coverage.xml + coverage-reports: coverage_integration-test.xml # coverage-reports: coverage_integration-test.xml # coverage-reports: coverage_unit-test.xml,coverage_integration-test.xml # coverage-reports: cobertura.xml From 4593ebf9ef7a9b340c002ad00b948c920ccead75 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 07:26:26 +0800 Subject: [PATCH 124/241] [Breaking Change + Test] (config) Test for uploading test report. --- .../workflows/test-reusable-workflows.yaml | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 999e727a..1dba185f 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -35,11 +35,11 @@ jobs: prep-testbed_integration-test: +# name: Prepare all integration test items uses: ./.github/workflows/prepare_test_items.yaml with: shell_path: scripts/ci/get-integration-test-paths.sh shell_arg: unix -# name: Prepare all integration test items # run_unit-test: @@ -52,6 +52,7 @@ jobs: run_integration-test: +# name: Run all integration test items. This testing would test the code with other resource or system to ensure the features work finely. needs: prep-testbed_integration-test uses: ./.github/workflows/run_test_items_via_pytest.yaml with: @@ -62,7 +63,6 @@ jobs: http_server_port: 30303 http_server_app_module: _http_server.app http_server_enter_point: app -# name: Run all integration test items. This testing would test the code with other resource or system to ensure the features work finely. # unit-test_codecov: @@ -74,11 +74,11 @@ jobs: integration-test_codecov: +# name: Organize and generate the testing report and upload it to Codecov needs: run_integration-test uses: ./.github/workflows/organize_and_generate_test_cov_reports.yaml with: test_type: integration-test -# name: Organize and generate the testing report and upload it to Codecov # all-test_codecov: @@ -123,6 +123,7 @@ jobs: codecov_finish: +# name: Organize and generate the testing report and upload it to Codecov needs: [integration-test_codecov] uses: ./.github/workflows/upload_test_cov_report.yaml secrets: @@ -130,7 +131,6 @@ jobs: with: upload-to-codecov: true -# name: Organize and generate the testing report and upload it to Codecov # if: github.ref_name == 'release' || github.ref_name == 'master' # needs: [unit-test_codecov, integration-test_codecov] @@ -139,26 +139,34 @@ jobs: coveralls_finish: +# name: Organize and generate the testing report and upload it to Coveralls needs: [integration-test_codecov] uses: ./.github/workflows/upload_test_cov_report.yaml secrets: coveralls_token: ${{ secrets.COVERALLS_TOKEN }} with: upload-to-coveralls: true -# name: Organize and generate the testing report and upload it to Coveralls # if: github.ref_name == 'release' || github.ref_name == 'master' # needs: [unit-test_codecov, integration-test_codecov] codacy_finish: +# name: Upload test report to Codacy to analyse and record code quality needs: [integration-test_codecov] - uses: ./.github/workflows/upload_code_report_to_codacy.yaml + uses: ./.github/workflows/upload_test_cov_report.yaml secrets: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} + with: + upload-to-codacy: true + +# needs: [integration-test_codecov] +# uses: ./.github/workflows/upload_code_report_to_codacy.yaml +# secrets: +# codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} + # uses: ./.github/workflows/upload_test_cov_report.yaml # with: # upload-to-codacy: true -# name: Upload test report to Codacy to analyse and record code quality # needs: [unit-test_codecov, integration-test_codecov] From 8469eed0f1e393d77559a58882c7dc4b67b9f468 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 08:03:38 +0800 Subject: [PATCH 125/241] [Breaking Change + Test] (config) Add new option 'verbose' of command line 'codecov'. --- .github/workflows/upload_test_cov_report.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index d9174591..cb274d3d 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -114,7 +114,15 @@ jobs: - name: Upload coverage report to Codecov https://codecov.io if: ${{ inputs.upload-to-codecov == true }} run: | - codecov -t ${{ secrets.codecov_token }} --file coverage_integration-test.xml --flags unit,integration --env OS,PYTHON --name gh_workflow_template --branch develop + codecov \ + -t ${{ secrets.codecov_token }} \ + --file coverage_integration-test.xml \ + --flags unit,integration \ + --env OS,PYTHON \ + --name gh_workflow_template \ + --verbose + +# --branch ${{ github.ref_name }} \ # run: codecov -t ${{ secrets.codecov_token }} From 30110d48064f3deb50774f1f88350675802fdf00 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 08:05:23 +0800 Subject: [PATCH 126/241] [Breaking Change] (config) Remove unused settings. --- .../workflows/test-reusable-workflows.yaml | 61 ++----------------- 1 file changed, 5 insertions(+), 56 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 1dba185f..8977bbff 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -81,49 +81,10 @@ jobs: test_type: integration-test -# all-test_codecov: -## name: Organize and generate the testing report and upload it to Codecov -## needs: [unit-test_codecov, integration-test_codecov] -# needs: [run_unit-test, run_integration-test] -# uses: ./.github/workflows/organize_and_generate_testing_reports.yaml -# with: -# test_type: all-test -# secrets: -# codecov_token: ${{ secrets.CODECOV_TOKEN }} -# coveralls_token: ${{ secrets.COVERALLS_TOKEN }} -# codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} - - -# unit-codecov_finish: -## name: Organize and generate the testing report and upload it to Codecov -## if: github.ref_name == 'release' || github.ref_name == 'master' -# needs: [unit-test_codecov] -# uses: ./.github/workflows/upload_test_report_to_codecov.yaml -# secrets: -# codecov_token: ${{ secrets.CODECOV_TOKEN }} -# with: -# download_path: ./ -# test_type: unit-test -# codecov_flags: unit -# codecov_name: smoothcrawler-appintegration_github-actions_test # optional -# -# -# integration-codecov_finish: -## name: Organize and generate the testing report and upload it to Codecov -## if: github.ref_name == 'release' || github.ref_name == 'master' -# needs: [integration-test_codecov] -# uses: ./.github/workflows/upload_test_report_to_codecov.yaml -# secrets: -# codecov_token: ${{ secrets.CODECOV_TOKEN }} -# with: -# download_path: ./ -# test_type: integration-test -# codecov_flags: integration -# codecov_name: smoothcrawler-appintegration_github-actions_test # optional - - codecov_finish: # name: Organize and generate the testing report and upload it to Codecov +# if: github.ref_name == 'release' || github.ref_name == 'master' +# needs: [unit-test_codecov, integration-test_codecov] needs: [integration-test_codecov] uses: ./.github/workflows/upload_test_cov_report.yaml secrets: @@ -131,27 +92,25 @@ jobs: with: upload-to-codecov: true -# if: github.ref_name == 'release' || github.ref_name == 'master' -# needs: [unit-test_codecov, integration-test_codecov] - # codecov_flags: unit,integration # codecov_name: smoothcrawler-appintegration_github-actions_test # optional coveralls_finish: # name: Organize and generate the testing report and upload it to Coveralls +# if: github.ref_name == 'release' || github.ref_name == 'master' +# needs: [unit-test_codecov, integration-test_codecov] needs: [integration-test_codecov] uses: ./.github/workflows/upload_test_cov_report.yaml secrets: coveralls_token: ${{ secrets.COVERALLS_TOKEN }} with: upload-to-coveralls: true -# if: github.ref_name == 'release' || github.ref_name == 'master' -# needs: [unit-test_codecov, integration-test_codecov] codacy_finish: # name: Upload test report to Codacy to analyse and record code quality +# needs: [unit-test_codecov, integration-test_codecov] needs: [integration-test_codecov] uses: ./.github/workflows/upload_test_cov_report.yaml secrets: @@ -159,16 +118,6 @@ jobs: with: upload-to-codacy: true -# needs: [integration-test_codecov] -# uses: ./.github/workflows/upload_code_report_to_codacy.yaml -# secrets: -# codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} - -# uses: ./.github/workflows/upload_test_cov_report.yaml -# with: -# upload-to-codacy: true -# needs: [unit-test_codecov, integration-test_codecov] - # pre-building_check: ## name: Check about it could work finely by installing the Python package with setup.py file From 8567f554125fbd7ecc6d08e8b5328a7a00347daa Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 08:25:46 +0800 Subject: [PATCH 127/241] [Breaking Change + Test] (config) Add unit test processes. --- .../workflows/test-reusable-workflows.yaml | 47 +++++++++---------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 8977bbff..19be17ba 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -26,12 +26,12 @@ on: jobs: -# prep-testbed_unit-test: -## name: Prepare all unit test items -# uses: ./.github/workflows/prepare_test_items.yaml -# with: -# shell_path: scripts/ci/get-unit-test-paths.sh -# shell_arg: unix + prep-testbed_unit-test: +# name: Prepare all unit test items + uses: ./.github/workflows/prepare_test_items.yaml + with: + shell_path: scripts/ci/get-unit-test-paths.sh + shell_arg: unix prep-testbed_integration-test: @@ -42,13 +42,13 @@ jobs: shell_arg: unix -# run_unit-test: -## name: Run all unit test items -# needs: prep-testbed_unit-test -# uses: ./.github/workflows/run_test_items_via_pytest.yaml -# with: -# test_type: unit-test -# all_test_items_paths: ${{needs.prep-testbed_unit-test.outputs.all_test_items}} + run_unit-test: +# name: Run all unit test items + needs: prep-testbed_unit-test + uses: ./.github/workflows/run_test_items_via_pytest.yaml + with: + test_type: unit-test + all_test_items_paths: ${{needs.prep-testbed_unit-test.outputs.all_test_items}} run_integration-test: @@ -65,12 +65,12 @@ jobs: http_server_enter_point: app -# unit-test_codecov: -## name: Organize and generate the testing report and upload it to Codecov -# needs: run_unit-test -# uses: ./.github/workflows/organize_and_generate_testing_reports.yaml -# with: -# test_type: unit-test + unit-test_codecov: +# name: Organize and generate the testing report and upload it to Codecov + needs: run_unit-test + uses: ./.github/workflows/organize_and_generate_testing_reports.yaml + with: + test_type: unit-test integration-test_codecov: @@ -84,8 +84,7 @@ jobs: codecov_finish: # name: Organize and generate the testing report and upload it to Codecov # if: github.ref_name == 'release' || github.ref_name == 'master' -# needs: [unit-test_codecov, integration-test_codecov] - needs: [integration-test_codecov] + needs: [unit-test_codecov, integration-test_codecov] uses: ./.github/workflows/upload_test_cov_report.yaml secrets: codecov_token: ${{ secrets.CODECOV_TOKEN }} @@ -99,8 +98,7 @@ jobs: coveralls_finish: # name: Organize and generate the testing report and upload it to Coveralls # if: github.ref_name == 'release' || github.ref_name == 'master' -# needs: [unit-test_codecov, integration-test_codecov] - needs: [integration-test_codecov] + needs: [unit-test_codecov, integration-test_codecov] uses: ./.github/workflows/upload_test_cov_report.yaml secrets: coveralls_token: ${{ secrets.COVERALLS_TOKEN }} @@ -110,8 +108,7 @@ jobs: codacy_finish: # name: Upload test report to Codacy to analyse and record code quality -# needs: [unit-test_codecov, integration-test_codecov] - needs: [integration-test_codecov] + needs: [unit-test_codecov, integration-test_codecov] uses: ./.github/workflows/upload_test_cov_report.yaml secrets: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} From a8e5051b8e8787a00d9365346778a74b810504c2 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 08:26:06 +0800 Subject: [PATCH 128/241] [Breaking Change + Test] (config) Adjust the processes. --- .github/workflows/upload_test_cov_report.yaml | 48 +++++++------------ 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index cb274d3d..061001a7 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -72,6 +72,9 @@ jobs: upload_test_cov_report: runs-on: ubuntu-latest steps: + - name: Check the workflow input parameter + uses: actions/checkout@v2 + - name: Checkout uses: actions/checkout@v2 @@ -88,24 +91,29 @@ jobs: path: ${{ inputs.download_path }} - name: Install Python 3.10 + if: ${{ inputs.upload-to-codecov == true || inputs.upload-to-coveralls == true }} uses: actions/setup-python@v2 with: python-version: "3.10" - name: Install Python dependencies about handling testing coverage report + if: ${{ inputs.upload-to-codecov == true || inputs.upload-to-coveralls == true }} run: | python3 -m pip install --upgrade pip pip3 install -U pip pip3 install coverage - - name: Combine all testing code coverage result files with all test types - run: coverage combine .coverage.* - - - name: Report testing coverage of project code - run: coverage report -m - - - name: Report testing coverage of project code - run: coverage xml +# - name: Combine all testing code coverage result files with all test types +# if: ${{ inputs.upload-to-codecov == true || inputs.upload-to-coveralls == true }} +# run: coverage combine .coverage.* +# +# - name: Report testing coverage of project code +# if: ${{ inputs.upload-to-codecov == true || inputs.upload-to-coveralls == true }} +# run: coverage report -m +# +# - name: Generate test coverage report as XML format file +# if: ${{ inputs.upload-to-codecov == true || inputs.upload-to-coveralls == true }} +# run: coverage xml - name: Install Python dependencies about tool of Codecov if: ${{ inputs.upload-to-codecov == true }} @@ -116,32 +124,13 @@ jobs: run: | codecov \ -t ${{ secrets.codecov_token }} \ + --file coverage_unit-test.xml \ --file coverage_integration-test.xml \ --flags unit,integration \ --env OS,PYTHON \ --name gh_workflow_template \ --verbose -# --branch ${{ github.ref_name }} \ - -# run: codecov -t ${{ secrets.codecov_token }} - -#### Way 1 -# run: bash <(curl -s https://codecov.io/bash) -#### Way 2 -# run: codecov -t ${{ secrets.codecov_token }} -#### Way 3 -# uses: codecov/codecov-action@v2 -# with: -# file: .coverage -# token: ${{ secrets.codecov_token }} # not required for public repos -# files: ./coverage.xml -## flags: ${{ inputs.codecov_flags }} # optional -## env_vars: OS,PYTHON # optional -## name: ${{ inputs.codecov_name }} # optional -# fail_ci_if_error: true # optional (default = false) -# verbose: true # optional (default = false) - - name: Install Python dependencies about tool of Coveralls if: ${{ inputs.upload-to-coveralls == true }} run: pip3 install coveralls @@ -157,7 +146,6 @@ jobs: uses: codacy/codacy-coverage-reporter-action@v1 with: project-token: ${{ secrets.codacy_token }} - coverage-reports: coverage_integration-test.xml + coverage-reports: coverage_unit-test.xml,coverage_integration-test.xml # coverage-reports: coverage_integration-test.xml -# coverage-reports: coverage_unit-test.xml,coverage_integration-test.xml # coverage-reports: cobertura.xml From 9c1074a87da8bef63ad61923544844fa29dd8e50 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 08:27:02 +0800 Subject: [PATCH 129/241] [Bug Fix] (config) Call incorrect reusable workflow. --- .github/workflows/test-reusable-workflows.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 19be17ba..85a71b55 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -68,7 +68,7 @@ jobs: unit-test_codecov: # name: Organize and generate the testing report and upload it to Codecov needs: run_unit-test - uses: ./.github/workflows/organize_and_generate_testing_reports.yaml + uses: ./.github/workflows/organize_and_generate_test_cov_reports.yaml with: test_type: unit-test From 26b5097cb42323da5de026356015448cefb43d6a Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 08:41:14 +0800 Subject: [PATCH 130/241] [Breaking Change + Test] (config) Add a step about combining test coverage reports for uploading report to Coveralls. --- .github/workflows/upload_test_cov_report.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 061001a7..38b7a402 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -131,6 +131,10 @@ jobs: --name gh_workflow_template \ --verbose + - name: Combine all testing code coverage result files with all test types + if: ${{ inputs.upload-to-coveralls == true }} + run: coverage combine .coverage.* + - name: Install Python dependencies about tool of Coveralls if: ${{ inputs.upload-to-coveralls == true }} run: pip3 install coveralls @@ -147,5 +151,4 @@ jobs: with: project-token: ${{ secrets.codacy_token }} coverage-reports: coverage_unit-test.xml,coverage_integration-test.xml -# coverage-reports: coverage_integration-test.xml # coverage-reports: cobertura.xml From 10c17df3a3a556c8694caa97e9aaab10698eed1b Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 08:49:35 +0800 Subject: [PATCH 131/241] [Breaking Change] (config) Integrate uploading report to Codacy feature into workflow 'upload_test_cov_report.yaml'. --- .../upload_code_report_to_codacy.yaml | 55 ------------------- 1 file changed, 55 deletions(-) delete mode 100644 .github/workflows/upload_code_report_to_codacy.yaml diff --git a/.github/workflows/upload_code_report_to_codacy.yaml b/.github/workflows/upload_code_report_to_codacy.yaml deleted file mode 100644 index 87969d2e..00000000 --- a/.github/workflows/upload_code_report_to_codacy.yaml +++ /dev/null @@ -1,55 +0,0 @@ -############################################################################ -# -# Workflow Description: -# Upload the testing coverage reports to Codacy. -# -# Workflow input parameters: -# * General arguments: -# * download_path: The path to download testing coverage reports via 'actions/download-artifact@v3'. -# -# * Secret arguments: -# * codacy_token: The API token for uploading testing coverage report to Codacy. -# -# Workflow running output: -# No and do nothing. -# -############################################################################ - -name: Upload code detail report to Codacy - -on: - workflow_call: - inputs: - download_path: - description: "The path to download testing coverage reports via 'actions/download-artifact@v3'." - type: string - required: false - default: ./ - - secrets: - codacy_token: - description: "The API token for uploading testing coverage report to Codacy." - required: true - - -jobs: - upload_code_to_codacy_check_quality: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Download testing coverage report - uses: actions/download-artifact@v3 - with: - name: test_coverage_xml_report - path: ${{ inputs.download_path }} - - - name: Upload testing report to Codacy - uses: codacy/codacy-coverage-reporter-action@v1 - with: - project-token: ${{ secrets.codacy_token }} -# coverage-reports: coverage_unit-test.xml,coverage_integration-test.xml - coverage-reports: coverage_integration-test.xml -# coverage-reports: cobertura.xml - From 499fe06d407770cfbb00b4448c3bd3012212bcda Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 09:43:19 +0800 Subject: [PATCH 132/241] [Breaking Change] (config) Add input parameter checking mechanism and some steps for different test types. --- .github/workflows/upload_test_cov_report.yaml | 89 ++++++++++++------- 1 file changed, 55 insertions(+), 34 deletions(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 38b7a402..67e568e7 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -6,6 +6,7 @@ # Workflow input parameters: # * General arguments: # * download_path: The path to download testing coverage reports via 'actions/download-artifact@v3'. +# * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'. # * upload-to-codecov: If it's true, it would upload testing coverage report for Codecov (https://codecov.io). # * upload-to-coveralls: If it's true, it would upload testing coverage report for Coveralls (https://coveralls.io). # * upload-to-codacy: If it's true, it would upload testing coverage report for Codacy (https://app.codacy.com/). @@ -30,6 +31,10 @@ on: type: string required: false default: ./ + test_type: + description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'." + required: true + type: string upload-to-codecov: description: "If it's true, it would upload testing coverage report for Codecov (https://codecov.io)." type: boolean @@ -45,16 +50,16 @@ on: type: boolean required: false default: false -# codecov_flags: -# description: "The flags of the testing coverage report for Codecov." -# type: string -# required: false -# default: '' -# codecov_name: -# description: "The name of the testing coverage report for Codecov." -# type: string -# required: false -# default: '' + codecov_flags: + description: "The flags of the testing coverage report for Codecov." + type: string + required: false + default: '' + codecov_name: + description: "The name of the testing coverage report for Codecov." + type: string + required: false + default: '' secrets: codecov_token: @@ -73,7 +78,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Check the workflow input parameter - uses: actions/checkout@v2 + uses: | + echo "Check the parameters of uploading report to Codecov ..." + bash ./scripts/ci/check-input-params.sh ${{ inputs.upload-to-codecov }} ${{ secrets.codecov_token }} + + echo "Check the parameters of uploading report to Coveralls ..." + bash ./scripts/ci/check-input-params.sh ${{ inputs.upload-to-coveralls }} ${{ secrets.coveralls_token }} + + echo "Check the parameters of uploading report to Codacy ..." + bash ./scripts/ci/check-input-params.sh ${{ inputs.upload-to-codacy }} ${{ secrets.codacy_token }} - name: Checkout uses: actions/checkout@v2 @@ -101,43 +114,43 @@ jobs: run: | python3 -m pip install --upgrade pip pip3 install -U pip - pip3 install coverage - -# - name: Combine all testing code coverage result files with all test types -# if: ${{ inputs.upload-to-codecov == true || inputs.upload-to-coveralls == true }} -# run: coverage combine .coverage.* -# -# - name: Report testing coverage of project code -# if: ${{ inputs.upload-to-codecov == true || inputs.upload-to-coveralls == true }} -# run: coverage report -m -# -# - name: Generate test coverage report as XML format file -# if: ${{ inputs.upload-to-codecov == true || inputs.upload-to-coveralls == true }} -# run: coverage xml - name: Install Python dependencies about tool of Codecov if: ${{ inputs.upload-to-codecov == true }} run: pip3 install codecov - - name: Upload coverage report to Codecov https://codecov.io - if: ${{ inputs.upload-to-codecov == true }} + - name: Upload coverage report to Codecov https://codecov.io (For Unit-Test or Integration-Test) + if: ${{ inputs.upload-to-codecov == true && (inputs.test_type == 'unit-test' || inputs.test_type == 'integration-test') }} + run: | + codecov \ + -t ${{ secrets.codecov_token }} \ + --file coverage_${{ inputs.test_type }}.xml \ + --flags ${{ inputs.codecov_flags }} \ + --env OS,PYTHON \ + --name ${{ inputs.codecov_name }} \ + --verbose + + - name: Upload coverage report to Codecov https://codecov.io (For all test types) + if: ${{ inputs.upload-to-codecov == true && inputs.test_type == 'all-test' }} run: | codecov \ -t ${{ secrets.codecov_token }} \ --file coverage_unit-test.xml \ --file coverage_integration-test.xml \ - --flags unit,integration \ + --flags ${{ inputs.codecov_flags }} \ --env OS,PYTHON \ - --name gh_workflow_template \ + --name ${{ inputs.codecov_name }} \ --verbose - - name: Combine all testing code coverage result files with all test types + - name: Install Python dependencies about tool of Coveralls if: ${{ inputs.upload-to-coveralls == true }} - run: coverage combine .coverage.* + run: | + pip3 install coveralls + pip3 install coverage - - name: Install Python dependencies about tool of Coveralls + - name: Combine all testing code coverage result files with all test types if: ${{ inputs.upload-to-coveralls == true }} - run: pip3 install coveralls + run: coverage combine .coverage.* - name: Upload coverage report to Coveralls https://coveralls.io if: ${{ inputs.upload-to-coveralls == true }} @@ -145,8 +158,16 @@ jobs: GITHUB_TOKEN: ${{ secrets.coveralls_token }} run: coveralls --verbose - - name: Upload testing report to Codacy https://app.codacy.com/ - if: ${{ inputs.upload-to-codacy == true }} + - name: Upload testing report to Codacy https://app.codacy.com/ (For Unit-Test or Integration-Test) + if: ${{ inputs.upload-to-codacy == true && (inputs.test_type == 'unit-test' || inputs.test_type == 'integration-test') }} + uses: codacy/codacy-coverage-reporter-action@v1 + with: + project-token: coverage_${{ inputs.test_type }}.xml + coverage-reports: coverage_unit-test.xml +# coverage-reports: cobertura.xml + + - name: Upload testing report to Codacy https://app.codacy.com/ (For all test types) + if: ${{ inputs.upload-to-codacy == true && inputs.test_type == 'all-test' }} uses: codacy/codacy-coverage-reporter-action@v1 with: project-token: ${{ secrets.codacy_token }} From 1f9a3f5ed2af7e97f36c39ac18f965c5e66a1a3a Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 09:43:58 +0800 Subject: [PATCH 133/241] [Breaking Change] (config) Add newer workflow parameters. --- .github/workflows/test-reusable-workflows.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 85a71b55..d438909b 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -89,10 +89,10 @@ jobs: secrets: codecov_token: ${{ secrets.CODECOV_TOKEN }} with: + test_type: all-test upload-to-codecov: true - -# codecov_flags: unit,integration -# codecov_name: smoothcrawler-appintegration_github-actions_test # optional + codecov_flags: unit,integration # Required if 'upload-to-codecov' is true + codecov_name: gh_workflow_template # Required if 'upload-to-codecov' is true coveralls_finish: @@ -103,6 +103,7 @@ jobs: secrets: coveralls_token: ${{ secrets.COVERALLS_TOKEN }} with: + test_type: all-test upload-to-coveralls: true @@ -113,6 +114,7 @@ jobs: secrets: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} with: + test_type: all-test upload-to-codacy: true From 38d8dff24a7153075fcc1426407c5685439a0748 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 09:44:34 +0800 Subject: [PATCH 134/241] [New Feature + Test] (config) Add new testing for only one test type scenario. --- .../test-reusable-workflows_one-test.yaml | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 .github/workflows/test-reusable-workflows_one-test.yaml diff --git a/.github/workflows/test-reusable-workflows_one-test.yaml b/.github/workflows/test-reusable-workflows_one-test.yaml new file mode 100644 index 00000000..b915c5f9 --- /dev/null +++ b/.github/workflows/test-reusable-workflows_one-test.yaml @@ -0,0 +1,101 @@ +name: github-action reusable workflows test +on: + push: + branches: + - "develop" + - "release" + - "release-**" + - "release/**" + - "master" + paths-ignore: + - ".gitcommitrules" + - ".gitignore" + - "LICENSE" + - "README.md" + pull_request: + branches: + - "develop" + - "release" + - "release-**" + - "release/**" + paths-ignore: + - ".gitcommitrules" + - ".gitignore" + - "LICENSE" + - "README.md" + +jobs: + + prep-testbed_unit-test: +# name: Prepare all unit test items + uses: ./.github/workflows/prepare_test_items.yaml + with: + shell_path: scripts/ci/get-unit-test-paths.sh + shell_arg: unix + + + run_unit-test: +# name: Run all unit test items + needs: prep-testbed_unit-test + uses: ./.github/workflows/run_test_items_via_pytest.yaml + with: + test_type: unit-test + all_test_items_paths: ${{needs.prep-testbed_unit-test.outputs.all_test_items}} + + + unit-test_codecov: +# name: Organize and generate the testing report and upload it to Codecov + needs: run_unit-test + uses: ./.github/workflows/organize_and_generate_test_cov_reports.yaml + with: + test_type: unit-test + + + codecov_finish: +# name: Organize and generate the testing report and upload it to Codecov +# if: github.ref_name == 'release' || github.ref_name == 'master' + needs: [unit-test_codecov] + uses: ./.github/workflows/upload_test_cov_report.yaml + secrets: + codecov_token: ${{ secrets.CODECOV_TOKEN }} + with: + test_type: unit-test + upload-to-codecov: true + codecov_flags: unit # Required if 'upload-to-codecov' is true + codecov_name: gh_workflow_template # Required if 'upload-to-codecov' is true + + + coveralls_finish: +# name: Organize and generate the testing report and upload it to Coveralls +# if: github.ref_name == 'release' || github.ref_name == 'master' + needs: [unit-test_codecov] + uses: ./.github/workflows/upload_test_cov_report.yaml + secrets: + coveralls_token: ${{ secrets.COVERALLS_TOKEN }} + with: + test_type: unit-test + upload-to-coveralls: true + + + codacy_finish: +# name: Upload test report to Codacy to analyse and record code quality + needs: [unit-test_codecov] + uses: ./.github/workflows/upload_test_cov_report.yaml + secrets: + codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} + with: + test_type: unit-test + upload-to-codacy: true + + +# pre-building_check: +## name: Check about it could work finely by installing the Python package with setup.py file +# needs: [codecov_finish, codacy_finish] +# uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/upload_code_report_to_codacy.yaml +# with: +# python_package_name: smoothcrawler +# test_import_package_code_1: import smoothcrawler as mr +# test_import_package_code_2: from smoothcrawler.crawler import SimpleCrawler +# test_import_package_code_3: from smoothcrawler.components.data import BaseHTTPResponseParser, BaseDataHandler +# test_python_script: ./scripts/test_crawler.py + From 7bd143b5ab72fc308a7a5ae935fd53d443050fa8 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 09:45:50 +0800 Subject: [PATCH 135/241] [Breaking Change] (config) Rename the workflow. --- .github/workflows/test-reusable-workflows.yaml | 2 +- .github/workflows/test-reusable-workflows_one-test.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index d438909b..eeef8496 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -1,4 +1,4 @@ -name: github-action reusable workflows test +name: Github-Action reusable workflows test (multi-tests) on: push: branches: diff --git a/.github/workflows/test-reusable-workflows_one-test.yaml b/.github/workflows/test-reusable-workflows_one-test.yaml index b915c5f9..3c3abf30 100644 --- a/.github/workflows/test-reusable-workflows_one-test.yaml +++ b/.github/workflows/test-reusable-workflows_one-test.yaml @@ -1,4 +1,4 @@ -name: github-action reusable workflows test +name: Github-Action reusable workflows test (one-test) on: push: branches: From bcb58a608ed824575b22aba6c9f700adee3f6b22 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 09:47:17 +0800 Subject: [PATCH 136/241] [Bug Fix] (config) Fix the issue about incorrect YAML key. --- .github/workflows/upload_test_cov_report.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 67e568e7..df88d59e 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -78,7 +78,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check the workflow input parameter - uses: | + run: | echo "Check the parameters of uploading report to Codecov ..." bash ./scripts/ci/check-input-params.sh ${{ inputs.upload-to-codecov }} ${{ secrets.codecov_token }} From d8f9f3800fb6ca2c6635690f1e63dca776ab9dcb Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 09:49:31 +0800 Subject: [PATCH 137/241] [New Feature] (config) Add shell script for checking parameters. --- scripts/ci/check-input-params.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 scripts/ci/check-input-params.sh diff --git a/scripts/ci/check-input-params.sh b/scripts/ci/check-input-params.sh new file mode 100644 index 00000000..15dcce75 --- /dev/null +++ b/scripts/ci/check-input-params.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +#set -ex +upload_report_to_platform_flag=$1 +platform_token=$2 + +echo "🔍 Start to check input parameters ..." +if [ "$upload_report_to_platform_flag" = true ]; then + echo "✅ This using flag of uploading platform is true." + if [ "$platform_token" = "" ]; then + echo "⚠️️ The using flag of uploading to platform is true but it has no Token of it." + echo "❌ It needs a Token to let CI could use it authenticates and uploads report to the platform. Please configure a Token to it." + exit 1 + else + echo "🍻 It has a Token!" + fi +else + echo "💤 It doesn't upload report to this platform." +fi From 7d63f518d2d5ce199ea330805f394006f180979a Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 09:52:28 +0800 Subject: [PATCH 138/241] [Breaking Change] (config) Modify the running steps order. --- .github/workflows/upload_test_cov_report.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index df88d59e..dde6447c 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -77,20 +77,20 @@ jobs: upload_test_cov_report: runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Check the workflow input parameter run: | echo "Check the parameters of uploading report to Codecov ..." - bash ./scripts/ci/check-input-params.sh ${{ inputs.upload-to-codecov }} ${{ secrets.codecov_token }} + bash scripts/ci/check-input-params.sh ${{ inputs.upload-to-codecov }} ${{ secrets.codecov_token }} echo "Check the parameters of uploading report to Coveralls ..." - bash ./scripts/ci/check-input-params.sh ${{ inputs.upload-to-coveralls }} ${{ secrets.coveralls_token }} + bash scripts/ci/check-input-params.sh ${{ inputs.upload-to-coveralls }} ${{ secrets.coveralls_token }} echo "Check the parameters of uploading report to Codacy ..." bash ./scripts/ci/check-input-params.sh ${{ inputs.upload-to-codacy }} ${{ secrets.codacy_token }} - - name: Checkout - uses: actions/checkout@v2 - - name: Download code coverage result files which has be handled by different test type process uses: actions/download-artifact@v3 with: From 0449a7e23bb0f23f1ff10aa2d7fb87a2ee00c106 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 09:53:10 +0800 Subject: [PATCH 139/241] [Breaking Change] (config) Remove unused reusable workflow. --- .../upload_test_cov_report_to_codecov.yaml | 88 ------------------- .../upload_test_cov_report_to_coveralls.yaml | 77 ---------------- 2 files changed, 165 deletions(-) delete mode 100644 .github/workflows/upload_test_cov_report_to_codecov.yaml delete mode 100644 .github/workflows/upload_test_cov_report_to_coveralls.yaml diff --git a/.github/workflows/upload_test_cov_report_to_codecov.yaml b/.github/workflows/upload_test_cov_report_to_codecov.yaml deleted file mode 100644 index b4bb044b..00000000 --- a/.github/workflows/upload_test_cov_report_to_codecov.yaml +++ /dev/null @@ -1,88 +0,0 @@ -############################################################################ -# -# Workflow Description: -# Upload the testing coverage reports to Codacy. -# -# Workflow input parameters: -# * General arguments: -# * download_path: The path to download testing coverage reports via 'actions/download-artifact@v3'. -# -# * Secret arguments: -# * codacy_token: The API token for uploading testing coverage report to Codacy. -# -# Workflow running output: -# No and do nothing. -# -############################################################################ - -name: Upload code detail report to Codacy - -on: - workflow_call: - inputs: - download_path: - description: "The path to download testing coverage reports via 'actions/download-artifact@v3'." - type: string - required: false - default: ./ - - secrets: - codecov_token: - description: "The API token for uploading testing coverage report to Codacy." - required: true - - -jobs: - upload_code_to_codacy_check_quality: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Download testing coverage report - uses: actions/download-artifact@v3 - with: - name: final_project_testing_coverage_report - path: ${{ inputs.download_path }} - - - name: Install Python 3.10 - uses: actions/setup-python@v2 - with: - python-version: "3.10" - - - name: Install Python dependencies about handling testing coverage report - run: | - python3 -m pip install --upgrade pip - pip3 install -U pip - pip3 install coverage - -# - name: Combine all testing code coverage result files with all test types -# run: coverage combine .coverage.* - - - name: Report testing coverage of project code - run: coverage report -m - - - name: Report testing coverage of project code - run: coverage xml - - - name: Install Python dependencies about tool of Codecov -# if: ${{ inputs.upload-to-codecov == true }} - run: pip3 install codecov - - - name: Upload coverage report to Codecov https://codecov.io -# if: ${{ inputs.upload-to-codecov == true }} -#### Way 1 -# run: bash <(curl -s https://codecov.io/bash) -#### Way 2 - run: codecov -t ${{ secrets.codecov_token }} -#### Way 3 -# uses: codecov/codecov-action@v2 -# with: -# file: .coverage -# token: ${{ secrets.codecov_token }} # not required for public repos -# files: ./coverage.xml -## flags: ${{ inputs.codecov_flags }} # optional -## env_vars: OS,PYTHON # optional -## name: ${{ inputs.codecov_name }} # optional -# fail_ci_if_error: true # optional (default = false) -# verbose: true # optional (default = false) diff --git a/.github/workflows/upload_test_cov_report_to_coveralls.yaml b/.github/workflows/upload_test_cov_report_to_coveralls.yaml deleted file mode 100644 index 6484b374..00000000 --- a/.github/workflows/upload_test_cov_report_to_coveralls.yaml +++ /dev/null @@ -1,77 +0,0 @@ -############################################################################ -# -# Workflow Description: -# Upload the testing coverage reports to Codacy. -# -# Workflow input parameters: -# * General arguments: -# * download_path: The path to download testing coverage reports via 'actions/download-artifact@v3'. -# -# * Secret arguments: -# * codacy_token: The API token for uploading testing coverage report to Codacy. -# -# Workflow running output: -# No and do nothing. -# -############################################################################ - -name: Upload code detail report to Codacy - -on: - workflow_call: - inputs: - download_path: - description: "The path to download testing coverage reports via 'actions/download-artifact@v3'." - type: string - required: false - default: ./ - - secrets: - coveralls_token: - description: "The API token for uploading testing coverage report to Codacy." - required: true - - -jobs: - upload_code_to_codacy_check_quality: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Download testing coverage report - uses: actions/download-artifact@v3 - with: - name: final_project_testing_coverage_report - path: ${{ inputs.download_path }} - - - name: Install Python 3.10 - uses: actions/setup-python@v2 - with: - python-version: "3.10" - - - name: Install Python dependencies about handling testing coverage report - run: | - python3 -m pip install --upgrade pip - pip3 install -U pip - pip3 install coverage - -# - name: Combine all testing code coverage result files with all test types -# run: coverage combine .coverage.* - - - name: Report testing coverage of project code - run: coverage report -m - - - name: Report testing coverage of project code - run: coverage xml - - - name: Install Python dependencies about tool of Coveralls -# if: ${{ inputs.upload-to-coveralls == true }} - run: pip3 install coveralls - - - name: Upload coverage report to Coveralls https://coveralls.io -# if: ${{ inputs.upload-to-coveralls == true }} - env: - GITHUB_TOKEN: ${{ secrets.coveralls_token }} - run: coveralls --verbose - From 4ca04920fa7d2e3191d8ac104fc91d73a6c7407d Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 09:53:27 +0800 Subject: [PATCH 140/241] [Breaking Change] (config) Add description of input parameters. --- .github/workflows/organize_and_generate_test_cov_reports.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index 752bf642..30780299 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -9,6 +9,10 @@ # Workflow running output: # No, but it would save the testing coverage reports (coverage.xml) to provide after-process to organize and record. # +# * Upload-Artifact: +# * test_coverage_report: The handled test coverage report (.coverage file). It's file name format would be .coverage.. +# * test_coverage_xml_report: The handled test coverage report (.xml file). It's file name format would be coverage_.xml. +# ############################################################################ name: Organize all testing coverage reports which be tested in many different runtime OS and Python version as a testing coverage report From 05b66cd8d058bb6fbf33bdd2133836f47142278a Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 10:02:38 +0800 Subject: [PATCH 141/241] [Bug Fix] (config) Fix the issue about incorrect parameters. --- .github/workflows/upload_test_cov_report.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index dde6447c..2677a400 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -162,8 +162,8 @@ jobs: if: ${{ inputs.upload-to-codacy == true && (inputs.test_type == 'unit-test' || inputs.test_type == 'integration-test') }} uses: codacy/codacy-coverage-reporter-action@v1 with: - project-token: coverage_${{ inputs.test_type }}.xml - coverage-reports: coverage_unit-test.xml + project-token: ${{ secrets.codacy_token }} + coverage-reports: coverage_${{ inputs.test_type }}.xml # coverage-reports: cobertura.xml - name: Upload testing report to Codacy https://app.codacy.com/ (For all test types) From 5d2feb0ae345e207340f58f138891b759bb48b07 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 10:03:16 +0800 Subject: [PATCH 142/241] [New Feature] (config) Add new option 'debug_mode' for troubleshooting conveniencely. --- .../workflows/run_test_items_via_pytest.yaml | 80 ++++++++++++++++++- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index aae12f6f..cb9357f5 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -56,16 +56,91 @@ on: type: string required: false default: app + debug_mode: + description: "For debug so it's matrix would one has os: ubuntu-22.04 & python-version: '3.10'." + type: boolean + required: false + default: false jobs: run_test_items: + if: ${{ inputs.debug_mode == false }} + runs-on: ${{ matrix.os }} + + strategy: + matrix: + python-version: [3.6,3.7,3.8,3.9,'3.10'] + os: [ubuntu-18.04,ubuntu-20.04,ubuntu-22.04,macos-10.15,macos-11,macos-12] + exclude: + - os: ubuntu-18.04 + python-version: 3.6 + - os: ubuntu-18.04 + python-version: 3.9 + - os: ubuntu-18.04 + python-version: '3.10' + - os: ubuntu-20.04 + python-version: 3.8 + - os: ubuntu-20.04 + python-version: 3.9 + - os: ubuntu-22.04 + python-version: 3.6 + - os: macos-10.15 + python-version: 3.6 + - os: macos-10.15 + python-version: 3.8 + - os: macos-11 + python-version: 3.6 + - os: macos-11 + python-version: 3.9 + - os: macos-12 + python-version: 3.6 + test-path: ${{fromJson(inputs.all_test_items_paths)}} + + steps: + - uses: actions/checkout@v2 + + - name: Install Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + pip install -U pip + pip install -U -r ./requirements/requirements.txt + pip install -U -r ./requirements/requirements-test.txt + + - name: Setup and run HTTP server for testing + if: ${{ inputs.setup_http_server == true }} + run: gunicorn --bind ${{ inputs.http_server_host }}:${{ inputs.http_server_port }} '${{ inputs.http_server_app_module }}:${{ inputs.http_server_enter_point }}' --daemon + + - name: Test to send HTTP request to sample HTTP server + if: ${{ inputs.setup_http_server == true }} + run: curl "http://${{ inputs.http_server_host }}:${{ inputs.http_server_port }}/exchangeReport/STOCK_DAY?response=json&date=20170101&stockNo=2331" + + - name: Run tests with pytest + run: pytest ${{ matrix.test-path }} + continue-on-error: true + + - name: Rename the code coverage result file + run: mv ./.coverage ./.coverage.${{ inputs.test_type }}.${{ matrix.os }}-${{ matrix.python-version }} + + - name: Upload code coverage result file + uses: actions/upload-artifact@v3 + with: + name: coverage + path: .coverage.${{ inputs.test_type }}.${{ matrix.os }}-${{ matrix.python-version }} + if-no-files-found: error + + + run_test_items_with_debug_mode: + if: ${{ inputs.debug_mode == true }} runs-on: ${{ matrix.os }} strategy: matrix: -# python-version: [3.6,3.7,3.8,3.9,'3.10'] -# os: [ubuntu-18.04,ubuntu-20.04,ubuntu-22.04,macos-10.15,macos-11,macos-12] python-version: ['3.10'] os: [ubuntu-22.04] exclude: @@ -129,4 +204,3 @@ jobs: name: coverage path: .coverage.${{ inputs.test_type }}.${{ matrix.os }}-${{ matrix.python-version }} if-no-files-found: error - From 715ac4508fc5f05ae5a1f4cde14d800e4f4a9019 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 10:04:52 +0800 Subject: [PATCH 143/241] [Breaking Change] (config) Add new parameter of reusable workflow 'run_test_items_via_pytest'. --- .github/workflows/test-reusable-workflows.yaml | 2 ++ .github/workflows/test-reusable-workflows_one-test.yaml | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index eeef8496..bea7252f 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -49,6 +49,7 @@ jobs: with: test_type: unit-test all_test_items_paths: ${{needs.prep-testbed_unit-test.outputs.all_test_items}} + debug_mode: true run_integration-test: @@ -63,6 +64,7 @@ jobs: http_server_port: 30303 http_server_app_module: _http_server.app http_server_enter_point: app + debug_mode: true unit-test_codecov: diff --git a/.github/workflows/test-reusable-workflows_one-test.yaml b/.github/workflows/test-reusable-workflows_one-test.yaml index 3c3abf30..4aaefb87 100644 --- a/.github/workflows/test-reusable-workflows_one-test.yaml +++ b/.github/workflows/test-reusable-workflows_one-test.yaml @@ -41,6 +41,7 @@ jobs: with: test_type: unit-test all_test_items_paths: ${{needs.prep-testbed_unit-test.outputs.all_test_items}} + debug_mode: true unit-test_codecov: From f1c67aa361f146e050d9fb2baecf6fe3a1e5b39a Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 13:26:06 +0800 Subject: [PATCH 144/241] [Breaking Change] (config) Add description of input parameters. --- .../workflows/run_test_items_via_pytest.yaml | 3 ++- .github/workflows/upload_test_cov_report.yaml | 22 ++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index cb9357f5..798b7dd2 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -12,6 +12,7 @@ # * http_server_port: The port number of HTTP server. # * http_server_app_module: The module path of HTTP server. # * http_server_enter_point: The object about the web application. +# * debug_mode: For debug, so it's matrix would one has os: ubuntu-22.04 & python-version: '3.10'. # # Workflow running output: # No, but it would save the testing coverage reports to provide after-process to organize and record. @@ -57,7 +58,7 @@ on: required: false default: app debug_mode: - description: "For debug so it's matrix would one has os: ubuntu-22.04 & python-version: '3.10'." + description: "For debug, so it's matrix would one has os: ubuntu-22.04 & python-version: '3.10'." type: boolean required: false default: false diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 2677a400..fa3d4c3f 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -8,6 +8,8 @@ # * download_path: The path to download testing coverage reports via 'actions/download-artifact@v3'. # * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'. # * upload-to-codecov: If it's true, it would upload testing coverage report for Codecov (https://codecov.io). +# * codecov_flags: The flags of the testing coverage report for Codecov. This option would be required if 'upload-to-codecov' is true.. +# * codecov_name: The name of the testing coverage report for Codecov. This option would be required if 'upload-to-codecov' is true. # * upload-to-coveralls: If it's true, it would upload testing coverage report for Coveralls (https://coveralls.io). # * upload-to-codacy: If it's true, it would upload testing coverage report for Codacy (https://app.codacy.com/). # @@ -40,6 +42,16 @@ on: type: boolean required: false default: false + codecov_flags: + description: "The flags of the testing coverage report for Codecov. This option would be required if 'upload-to-codecov' is true." + type: string + required: false + default: '' + codecov_name: + description: "The name of the testing coverage report for Codecov. This option would be required if 'upload-to-codecov' is true." + type: string + required: false + default: '' upload-to-coveralls: description: "If it's true, it would upload testing coverage report for Coveralls (https://coveralls.io)." type: boolean @@ -50,16 +62,6 @@ on: type: boolean required: false default: false - codecov_flags: - description: "The flags of the testing coverage report for Codecov." - type: string - required: false - default: '' - codecov_name: - description: "The name of the testing coverage report for Codecov." - type: string - required: false - default: '' secrets: codecov_token: From 4f7b1b8cf1269b34b6fd329cd9343fd94225a1e8 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 14:28:40 +0800 Subject: [PATCH 145/241] [Breaking Change] (config) Add description of input parameters. --- .github/workflows/upload_test_cov_report.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index fa3d4c3f..8a73cbb0 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -8,7 +8,7 @@ # * download_path: The path to download testing coverage reports via 'actions/download-artifact@v3'. # * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'. # * upload-to-codecov: If it's true, it would upload testing coverage report for Codecov (https://codecov.io). -# * codecov_flags: The flags of the testing coverage report for Codecov. This option would be required if 'upload-to-codecov' is true.. +# * codecov_flags: The flags of the testing coverage report for Codecov. This option would be required if 'upload-to-codecov' is true. # * codecov_name: The name of the testing coverage report for Codecov. This option would be required if 'upload-to-codecov' is true. # * upload-to-coveralls: If it's true, it would upload testing coverage report for Coveralls (https://coveralls.io). # * upload-to-codacy: If it's true, it would upload testing coverage report for Codacy (https://app.codacy.com/). From 8a4f519cf2fa6a4b187c82d53ade398cc363902d Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 15:12:25 +0800 Subject: [PATCH 146/241] [Docs] (config) Format the description area. --- .github/workflows/organize_and_generate_test_cov_reports.yaml | 4 ++-- .github/workflows/run_test_items_via_pytest.yaml | 4 ++-- .github/workflows/upload_test_cov_report.yaml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index 30780299..882968b7 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -1,4 +1,4 @@ -############################################################################ +################################################################################################################################### # # Workflow Description: # Organize all the testing coverage reports. (it would save reports by 'actions/upload-artifact@v3'). @@ -13,7 +13,7 @@ # * test_coverage_report: The handled test coverage report (.coverage file). It's file name format would be .coverage.. # * test_coverage_xml_report: The handled test coverage report (.xml file). It's file name format would be coverage_.xml. # -############################################################################ +################################################################################################################################### name: Organize all testing coverage reports which be tested in many different runtime OS and Python version as a testing coverage report diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index 798b7dd2..ca9c9e86 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -1,4 +1,4 @@ -############################################################################ +############################################################################################################# # # Workflow Description: # Run testing by specific type with all test items via PyTest and generate its testing @@ -17,7 +17,7 @@ # Workflow running output: # No, but it would save the testing coverage reports to provide after-process to organize and record. # -############################################################################ +############################################################################################################# name: Run test items via PyTest diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 8a73cbb0..534384f5 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -1,4 +1,4 @@ -############################################################################ +################################################################################################################################### # # Workflow Description: # Upload the testing coverage reports to Codecov. @@ -21,7 +21,7 @@ # Workflow running output: # No and do nothing. # -############################################################################ +################################################################################################################################### name: Upload test report to Codecov From e448ad1d6ea53fdc2cccbcb595d53f9ebf8c1cb9 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 17:25:23 +0800 Subject: [PATCH 147/241] [Breaking Change] (config) Modify the testing HTTP server module path. --- .github/workflows/test-reusable-workflows.yaml | 2 +- {_http_server => test/_http_server}/app.py | 0 {_http_server => test/_http_server}/test_data.json | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename {_http_server => test/_http_server}/app.py (100%) rename {_http_server => test/_http_server}/test_data.json (100%) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index bea7252f..301a938e 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -62,7 +62,7 @@ jobs: setup_http_server: true http_server_host: 0.0.0.0 http_server_port: 30303 - http_server_app_module: _http_server.app + http_server_app_module: test._http_server.app http_server_enter_point: app debug_mode: true diff --git a/_http_server/app.py b/test/_http_server/app.py similarity index 100% rename from _http_server/app.py rename to test/_http_server/app.py diff --git a/_http_server/test_data.json b/test/_http_server/test_data.json similarity index 100% rename from _http_server/test_data.json rename to test/_http_server/test_data.json From 1f93a7e7cf18c1861dcfa4c312c1776c1e259a0c Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 22:04:07 +0800 Subject: [PATCH 148/241] [Breaking Change] (config) Add a step to download shell script for checking input parameters. --- .github/workflows/upload_test_cov_report.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 534384f5..b83755d3 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -82,13 +82,16 @@ jobs: - name: Checkout uses: actions/checkout@v2 + - name: Download shell script for checking input parameters + run: curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Workflow-Template-Python/develop/scripts/ci/check-input-params.sh --output ./scripts/ci/check-input-params.sh + - name: Check the workflow input parameter run: | echo "Check the parameters of uploading report to Codecov ..." - bash scripts/ci/check-input-params.sh ${{ inputs.upload-to-codecov }} ${{ secrets.codecov_token }} + bash ./scripts/ci/check-input-params.sh ${{ inputs.upload-to-codecov }} ${{ secrets.codecov_token }} echo "Check the parameters of uploading report to Coveralls ..." - bash scripts/ci/check-input-params.sh ${{ inputs.upload-to-coveralls }} ${{ secrets.coveralls_token }} + bash ./scripts/ci/check-input-params.sh ${{ inputs.upload-to-coveralls }} ${{ secrets.coveralls_token }} echo "Check the parameters of uploading report to Codacy ..." bash ./scripts/ci/check-input-params.sh ${{ inputs.upload-to-codacy }} ${{ secrets.codacy_token }} From 5d4c9ba316a07da35cb97e2a81623826d360adf9 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Fri, 26 Aug 2022 22:39:12 +0800 Subject: [PATCH 149/241] [Breaking Change] (config) Remove unused setting. --- .../workflows/run_test_items_via_pytest.yaml | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index ca9c9e86..6c1cac7b 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -144,29 +144,6 @@ jobs: matrix: python-version: ['3.10'] os: [ubuntu-22.04] - exclude: - - os: ubuntu-18.04 - python-version: 3.6 - - os: ubuntu-18.04 - python-version: 3.9 - - os: ubuntu-18.04 - python-version: '3.10' - - os: ubuntu-20.04 - python-version: 3.8 - - os: ubuntu-20.04 - python-version: 3.9 - - os: ubuntu-22.04 - python-version: 3.6 - - os: macos-10.15 - python-version: 3.6 - - os: macos-10.15 - python-version: 3.8 - - os: macos-11 - python-version: 3.6 - - os: macos-11 - python-version: 3.9 - - os: macos-12 - python-version: 3.6 test-path: ${{fromJson(inputs.all_test_items_paths)}} steps: From 5fabf61af2731cba65fcf8a46b25206aac4facaf Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sat, 27 Aug 2022 08:54:14 +0800 Subject: [PATCH 150/241] [Breaking Change] (config) Add description about uploading file info. --- .github/workflows/run_test_items_via_pytest.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index 6c1cac7b..082274db 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -1,4 +1,4 @@ -############################################################################################################# +################################################################################################################################# # # Workflow Description: # Run testing by specific type with all test items via PyTest and generate its testing @@ -17,7 +17,11 @@ # Workflow running output: # No, but it would save the testing coverage reports to provide after-process to organize and record. # -############################################################################################################# +# * Upload-Artifact: +# * coverage: The test coverage report which be generated by PyTest, and it's recorded after run test done. +# The file name format would be .coverage..- +# +################################################################################################################################# name: Run test items via PyTest From 881eb7aa5656b29dd83733ac0c0a96ce7a3e0330 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sat, 27 Aug 2022 09:03:15 +0800 Subject: [PATCH 151/241] [Docs] (docs) Update the information of README. --- README.md | 220 +++++++++++++++++++++++++++++------------------------- 1 file changed, 118 insertions(+), 102 deletions(-) diff --git a/README.md b/README.md index 4b10a159..c2b85500 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # GitHub Action - Workflow template for Python library -[![github-action reusable workflows test](https://github.com/Chisanan232/GitHub-Action-Template-Python/actions/workflows/test-reusable-workflows.yaml/badge.svg)](https://github.com/Chisanan232/GitHub-Action-Template-Python/actions/workflows/test-reusable-workflows.yaml) +[![Github-Action reusable workflows test (one-test)](https://github.com/Chisanan232/GitHub-Action-Template-Python/actions/workflows/test-reusable-workflows_one-test.yaml/badge.svg)](https://github.com/Chisanan232/GitHub-Action-Template-Python/actions/workflows/test-reusable-workflows_one-test.yaml) +[![Github-Action reusable workflows test (multi-tests)](https://github.com/Chisanan232/GitHub-Action-Template-Python/actions/workflows/test-reusable-workflows.yaml/badge.svg)](https://github.com/Chisanan232/GitHub-Action-Template-Python/actions/workflows/test-reusable-workflows.yaml) [![Release](https://img.shields.io/github/release/Chisanan232/GitHub-Action-Template-Python.svg?label=Release&logo=github)](https://github.com/Chisanan232/GitHub-Action-Template-Python/releases) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?logo=apache)](https://opensource.org/licenses/Apache-2.0) @@ -26,20 +27,19 @@ The usage of each workflow template. * [_prepare_test_items.yaml_](#prepare_test_itemsyaml) * [_run_test_items_via_pytest.yaml_](#run_test_items_via_pytestyaml) -* [_organize_and_generate_testing_coverage_reports.yaml_](#organize_and_generate_testing_coverage_reportsyaml) -* [_upload_test_report_to_codecov.yaml_](#upload_test_report_to_codecovyaml) -* [_upload_code_report_to_codacy.yaml_](#upload_code_report_to_codacyyaml) +* [_organize_and_generate_test_cov_reports.yaml_](#organize_and_generate_test_cov_reportsyaml) +* [_upload_test_cov_report.yaml_](#upload_test_cov_reportyaml) -#### _prepare_test_items.yaml_ +### _prepare_test_items.yaml_ * Description: Prepare the test items. * Options: -| option name | option is optional or required | function content | -|-------------|--------------------------------|------------------------------------------------------| -| shell_path | Required | The path shell script for getting the testing items. | -| shell_arg | Required | Input arguments of the shell script. | +| option name | data type | optional or required | function content | +|-------------|-----------|----------------------|------------------------------------------------------| +| shell_path | string | Required | The path shell script for getting the testing items. | +| shell_arg | string | Required | Input arguments of the shell script. | * Output: * all_test_items: All the test items it would run. @@ -61,25 +61,30 @@ And we could get this workflow output result via keyword _all_test_items_.
-#### _run_test_items_via_pytest.yaml_ +### _run_test_items_via_pytest.yaml_ * Description: Run testing by specific type with all test items via PyTest and generate its testing coverage report (it would save reports by _actions/upload-artifact@v3_). * Options: -| option name | option is optional or required | function content | -|-------------------------|--------------------------------------|--------------------------------------------------------------------------------------------| -| test_type | Required | The testing type. In generally, it only has 2 options: _unit-test_ and _integration-test_. | -| all_test_items_paths | Required | The target paths of test items under test. | -| setup_http_server | Optional, Default value is _false_ | If it's true, it would set up and run HTTP server for testing. | -| http_server_host | Optional, Default value is _0.0.0.0_ | The host IPv4 address of HTTP server. | -| http_server_port | Optional, Default value is _12345_ | The port number of HTTP server. | -| http_server_app_module | Optional, Default value is _app_ | The module path of HTTP server. | -| http_server_enter_point | Optional, Default value is _app_ | The object about the web application. | +| option name | data type | optional or required | function content | +|-------------------------|-----------|--------------------------------------|--------------------------------------------------------------------------------------------| +| test_type | string | Required | The testing type. In generally, it only has 2 options: _unit-test_ and _integration-test_. | +| all_test_items_paths | string | Required | The target paths of test items under test. | +| setup_http_server | string | Optional, Default value is _false_ | If it's true, it would set up and run HTTP server for testing. | +| http_server_host | string | Optional, Default value is _0.0.0.0_ | The host IPv4 address of HTTP server. | +| http_server_port | string | Optional, Default value is _12345_ | The port number of HTTP server. | +| http_server_app_module | string | Optional, Default value is _app_ | The module path of HTTP server. | +| http_server_enter_point | string | Optional, Default value is _app_ | The object about the web application. | +| debug_mode | boolean | Optional, Default value is _false_ | For debug, so it's matrix would one has os: ubuntu-22.04 & python-version: 3.10. | * Output: No, but it would save the testing coverage reports to provide after-process to organize and record. +| Upload-Artifact name | description | +|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| coverage | The test coverage report which be generated by PyTest, and it's recorded after run test done. The file name format would be .coverage..- | + * How to use it? ```yaml @@ -109,18 +114,23 @@ is provided by previous workflow? That is all testing items.
-#### _organize_and_generate_testing_coverage_reports.yaml_ +### _organize_and_generate_test_cov_reports.yaml_ * Description: Organize all the testing coverage reports which be generated in different runtime OS with Python version. (it would save reports by _actions/upload-artifact@v3_). * Options: -| option name | option is optional or required | function content | -|-----------------------------|--------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| test_type | Required | The testing type. In generally, it only has 2 options: _unit-test_ and _integration-test_. | +| option name | data type | optional or required | function content | +|-------------|-----------|----------------------|--------------------------------------------------------------------------------------------| +| test_type | string | Required | The testing type. In generally, it only has 2 options: _unit-test_ and _integration-test_. | * Output: -No, but it would save the testing coverage reports (coverage_.xml) to provide after-process to organize and record. +No, but it would save the testing coverage reports to provide after-process to organize and record. + +| Upload-Artifact name | description | +|--------------------------|-----------------------------------------------------------------------------------------------------------------| +| test_coverage_report | The handled test coverage report (.coverage file). It's file name format would be .coverage.. | +| test_coverage_xml_report | The handled test coverage report (.xml file). It's file name format would be coverage_.xml. | * How to use it? @@ -128,7 +138,7 @@ No, but it would save the testing coverage reports (coverage_.xml) to unit-test_codecov: # name: Organize and generate the testing report and upload it to Codecov needs: run_unit-test - uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/organize_and_generate_testing_coverage_reports.yaml@master + uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/organize_and_generate_test_cov_reports.yaml@master with: test_type: unit-test ``` @@ -137,7 +147,7 @@ It would upload the organized report via _actions/upload-artifact@v3_. And it do
-#### _upload_test_report_to_codecov.yaml_ +### _upload_test_cov_report.yaml_ * Description: Upload the testing coverage reports to Codecov. * Options: @@ -146,65 +156,23 @@ It has 2 different types option could use: _General option_: -| option name | option is optional or required | function content | -|---------------|--------------------------------|--------------------------------------------------------------------------------------------| -| download_path | Required | The path to download testing coverage reports via _actions/download-artifact@v3_. | -| test_type | Required | The testing type. In generally, it only has 2 options: _unit-test_ and _integration-test_. | -| codecov_flags | Required | The flags of the testing coverage report for Codecov. | -| codecov_name | Required | The name of the testing coverage report for Codecov. | - -_Secret option_: - -| option name | option is optional or required | function content | -|---------------|--------------------------------|-----------------------------------------------------------------| -| codecov_token | Required | The API token for uploading testing coverage report to Codecov. | - -* Output: - -Nothing. - -* How to use it? - -Before run this workflow, please make sure testing coverage report is ready. - -```yaml - codecov_finish: -# name: Organize and generate the testing report and upload it to Codecov - needs: [unit-test_codecov] - uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/upload_test_report_to_codecov.yaml@master - secrets: - codecov_token: ${{ secrets.CODECOV_TOKEN }} - with: - download_path: ./ - codecov_flags: unittests - codecov_name: smoothcrawler-cluster_github-actions_test # optional -``` - -* The badges would be generated after this workflow done: - -[![codecov](https://codecov.io/gh/Chisanan232/GitHub-Action-Template-Python/branch/master/graph/badge.svg?token=wbPgJ4wxOl)](https://codecov.io/gh/Chisanan232/GitHub-Action-Template-Python) - -
- -#### _upload_code_report_to_codacy.yaml_ - -* Description: Upload the testing coverage reports to Codacy. -* Options: - -It has 2 different types option could use: - -_General option_: - -| option name | option is optional or required | function content | -|---------------|--------------------------------|--------------------------------------------------------------------------------------------| -| download_path | Optional | The path to download testing coverage reports via _actions/download-artifact@v3_. | -| test_type | Required | The testing type. In generally, it only has 2 options: _unit-test_ and _integration-test_. | +| option name | data type | optional or required | function content | +|---------------------|-----------|------------------------------------------|---------------------------------------------------------------------------------------------------------------------| +| download_path | string | Optional. Default value is './'. | The path to download testing coverage reports via _actions/download-artifact@v3_. | +| test_type | string | Required | The testing type. In generally, it only has 2 options: _unit-test_ and _integration-test_. | +| upload-to-codecov | boolean | Optional. Default value is _false_. | If it's true, it would upload testing coverage report for Codecov (https://codecov.io). | +| codecov_flags | string | Optional. Default value is empty string. | The flags of the testing coverage report for Codecov. This option would be required if _upload-to-codecov_ is true. | +| codecov_name | string | Optional. Default value is empty string. | The name of the testing coverage report for Codecov. This option would be required if _upload-to-codecov_ is true. | +| upload-to-coveralls | boolean | Optional. Default value is _false_. | If it's true, it would upload testing coverage report for Coveralls (https://coveralls.io). | +| upload-to-codacy | boolean | Optional. Default value is _false_. | If it's true, it would upload testing coverage report for Codacy (https://app.codacy.com/). | _Secret option_: -| option name | option is optional or required | function content | -|--------------|--------------------------------|----------------------------------------------------------------| -| codacy_token | Required | The API token for uploading testing coverage report to Codacy. | +| option name | option is optional or required | function content | +|-----------------|------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------| +| codecov_token | Optional. Default value is empty string. | The API token for uploading testing coverage report to Codecov. This option would be required if _upload-to-codecov_ is true. | +| coveralls_token | Optional. Default value is empty string. | The API token for uploading testing coverage report to Coveralls. This option would be required if _upload-to-coveralls_ is true. | +| codacy_token | Optional. Default value is empty string. | The API token for uploading testing coverage report to Codacy. This option would be required if _upload-to-codacy_ is true. | * Output: @@ -212,23 +180,71 @@ Nothing. * How to use it? -Before run this workflow, please make sure testing coverage report is ready. - -```yaml - codacy_finish: -# name: Upload test report to Codacy to analyse and record code quality - needs: [unit-test_codecov] - uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/upload_code_report_to_codacy.yaml@master - secrets: - codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} - with: - download_path: ./ - test_type: all-test -``` - -* The badges would be generated after this workflow done: - -[![Codacy Badge](https://app.codacy.com/project/badge/Grade/e8bfcd5830ba4232b45aca7c2d3e6310)](https://www.codacy.com/gh/Chisanan232/GitHub-Action-Template-Python/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Chisanan232/GitHub-Action-Template-Python&utm_campaign=Badge_Grade) -[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/e8bfcd5830ba4232b45aca7c2d3e6310)](https://www.codacy.com/gh/Chisanan232/GitHub-Action-Template-Python/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Chisanan232/GitHub-Action-Template-Python&utm_campaign=Badge_Coverage) - -
+ ⚠️ Before run this reusable workflow, please make sure testing coverage report is ready.
+ + ❔What format of test coverage report it could use? Different platform would need different format. But basically, it only accepts 2 types: _.coverage_ & _.xml_. + + 👀 This reusable work flow would check the input parameters first. The specific platform token shouldn't be empty where uploading flag is true. + + * Uploading test coverage report to **_Codecov_** (accepted report format: _.xml_) + + In Codecov case, it would need other 2 necessary options _codecov_flags_ & _codecov_name_. + + ```yaml + codecov_finish: + # name: Organize and generate the testing report and upload it to Codecov + needs: [unit-test_codecov] + uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/upload_test_cov_report.yaml@master + secrets: + codecov_token: ${{ secrets.CODECOV_TOKEN }} + with: + test_type: unit-test + upload-to-codecov: true + codecov_flags: unittests + codecov_name: smoothcrawler-cluster_github-actions_test # optional + ``` + + The badge it generates: + + [![codecov](https://codecov.io/gh/Chisanan232/GitHub-Action-Template-Python/branch/master/graph/badge.svg?token=wbPgJ4wxOl)](https://codecov.io/gh/Chisanan232/GitHub-Action-Template-Python) + + * Uploading test coverage report to **_Coveralls_** (accepted report format: _.coverage_) + + In Coveralls case, the Python tool _coveralls_ only accept _.coverage_ type report so that it would do coverage process again (integrate all test types report into one report). + + ```yaml + codecov_finish: + # name: Organize and generate the testing report and upload it to Coveralls + needs: [unit-test_codecov] + uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/upload_test_cov_report.yaml@master + secrets: + coveralls_token: ${{ secrets.COVERALLS_TOKEN }} + with: + test_type: unit-test + upload-to-coveralls: true + ``` + + The badge it generates: + + [![Coverage Status](https://coveralls.io/repos/github/Chisanan232/GitHub-Action-Template-Python/badge.svg?branch=master)](https://coveralls.io/github/Chisanan232/GitHub-Action-Template-Python?branch=master) + + * Uploading test coverage report to **_Codacy_** (accepted report format: _.xml_) + + In Codacy case, please use **CODACY_PROJECT_TOKEN**, not **CODACY_API_TOKEN**. + + ```yaml + codecov_finish: + # name: Organize and generate the testing report and upload it to Codacy + needs: [unit-test_codecov] + uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/upload_test_cov_report.yaml@master + secrets: + codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} + with: + test_type: unit-test + upload-to-codacy: true + ``` + + The badge it generates: + + [![Codacy Badge](https://app.codacy.com/project/badge/Grade/e8bfcd5830ba4232b45aca7c2d3e6310)](https://www.codacy.com/gh/Chisanan232/GitHub-Action-Template-Python/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Chisanan232/GitHub-Action-Template-Python&utm_campaign=Badge_Grade) + [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/e8bfcd5830ba4232b45aca7c2d3e6310)](https://www.codacy.com/gh/Chisanan232/GitHub-Action-Template-Python/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Chisanan232/GitHub-Action-Template-Python&utm_campaign=Badge_Coverage) From 66884a0ba8f3e1789a78792e6f6580bcfc385b66 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sat, 27 Aug 2022 09:11:59 +0800 Subject: [PATCH 152/241] [Docs] (docs) Fix some dispay issue. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c2b85500..f0e4651f 100644 --- a/README.md +++ b/README.md @@ -81,9 +81,9 @@ And we could get this workflow output result via keyword _all_test_items_. No, but it would save the testing coverage reports to provide after-process to organize and record. -| Upload-Artifact name | description | -|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| coverage | The test coverage report which be generated by PyTest, and it's recorded after run test done. The file name format would be .coverage..- | +| Upload-Artifact name | description | +|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| coverage | The test coverage report which be generated by PyTest, and it's recorded after run test done. The file name format would be .coverage..- | * How to use it? From 8c917f64cd65ee1c5bce9b96148cd4d21a02c318 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sat, 27 Aug 2022 09:25:26 +0800 Subject: [PATCH 153/241] [Docs] (docs) Fix some dispay issue. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f0e4651f..ea1784e3 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ And we could get this workflow output result via keyword _all_test_items_. | http_server_port | string | Optional, Default value is _12345_ | The port number of HTTP server. | | http_server_app_module | string | Optional, Default value is _app_ | The module path of HTTP server. | | http_server_enter_point | string | Optional, Default value is _app_ | The object about the web application. | -| debug_mode | boolean | Optional, Default value is _false_ | For debug, so it's matrix would one has os: ubuntu-22.04 & python-version: 3.10. | +| debug_mode | boolean | Optional, Default value is _false_ | For debug, so it's matrix would only has one os: ubuntu-22.04 & one python-version: 3.10. | * Output: @@ -159,7 +159,7 @@ _General option_: | option name | data type | optional or required | function content | |---------------------|-----------|------------------------------------------|---------------------------------------------------------------------------------------------------------------------| | download_path | string | Optional. Default value is './'. | The path to download testing coverage reports via _actions/download-artifact@v3_. | -| test_type | string | Required | The testing type. In generally, it only has 2 options: _unit-test_ and _integration-test_. | +| test_type | string | Required | The testing type. In generally, it only has 3 options: _unit-test_, _integration-test_ and _all-type_. | | upload-to-codecov | boolean | Optional. Default value is _false_. | If it's true, it would upload testing coverage report for Codecov (https://codecov.io). | | codecov_flags | string | Optional. Default value is empty string. | The flags of the testing coverage report for Codecov. This option would be required if _upload-to-codecov_ is true. | | codecov_name | string | Optional. Default value is empty string. | The name of the testing coverage report for Codecov. This option would be required if _upload-to-codecov_ is true. | @@ -200,8 +200,8 @@ Nothing. with: test_type: unit-test upload-to-codecov: true - codecov_flags: unittests - codecov_name: smoothcrawler-cluster_github-actions_test # optional + codecov_flags: unittests # required if upload-to-codecov is true + codecov_name: smoothcrawler-cluster_github-actions_test # required if upload-to-codecov is true ``` The badge it generates: From 89dc16cc22af2a486a62cc2359b1778f234de23c Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sat, 27 Aug 2022 11:23:36 +0800 Subject: [PATCH 154/241] [Docs] (docs) Add GitHub release note info. [skip ci] --- .github/release-notes.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/release-notes.md diff --git a/.github/release-notes.md b/.github/release-notes.md new file mode 100644 index 00000000..753535fa --- /dev/null +++ b/.github/release-notes.md @@ -0,0 +1,17 @@ +### 🎉🎊🍾 New feature +
+ +1. Add new options about set up and run a sample HTTP server for testing if it needs in some testing scenario (_run_test_items_via_pytest.yaml_). + +### 🛠⚙️🔩 **Breaking Change** +
+ +1. Integrate the feature about organizing and generating testing coverage reports into a reusable workflow. So workflow could be shorter and clear (_organize_and_generate_test_cov_reports.yaml_). +2. Integrate all the uploading test coverage report features into a reusable workflow (_upload_test_cov_report.yaml_). +3. Update document README. +4. Move the PR template to **_.github_** directory (for working finely). + +### ⚒⚒💣 **Bug Fix** +
+ +1. Fix the issue about uploading test coverage report cannot work at all. From a9172bfcac956ef203831996ab43eb1c26a6740e Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sat, 27 Aug 2022 11:25:20 +0800 Subject: [PATCH 155/241] [Breaking Change] (config) Comment out the job 'codecov_finish'. --- .../test-reusable-workflows_one-test.yaml | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-reusable-workflows_one-test.yaml b/.github/workflows/test-reusable-workflows_one-test.yaml index 4aaefb87..9075c6e5 100644 --- a/.github/workflows/test-reusable-workflows_one-test.yaml +++ b/.github/workflows/test-reusable-workflows_one-test.yaml @@ -52,18 +52,18 @@ jobs: test_type: unit-test - codecov_finish: -# name: Organize and generate the testing report and upload it to Codecov -# if: github.ref_name == 'release' || github.ref_name == 'master' - needs: [unit-test_codecov] - uses: ./.github/workflows/upload_test_cov_report.yaml - secrets: - codecov_token: ${{ secrets.CODECOV_TOKEN }} - with: - test_type: unit-test - upload-to-codecov: true - codecov_flags: unit # Required if 'upload-to-codecov' is true - codecov_name: gh_workflow_template # Required if 'upload-to-codecov' is true +# codecov_finish: +## name: Organize and generate the testing report and upload it to Codecov +## if: github.ref_name == 'release' || github.ref_name == 'master' +# needs: [unit-test_codecov] +# uses: ./.github/workflows/upload_test_cov_report.yaml +# secrets: +# codecov_token: ${{ secrets.CODECOV_TOKEN }} +# with: +# test_type: unit-test +# upload-to-codecov: true +# codecov_flags: unit # Required if 'upload-to-codecov' is true +# codecov_name: gh_workflow_template # Required if 'upload-to-codecov' is true coveralls_finish: From ada423c28c8985b0cc8604f20b1faf2250824395 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 14:29:35 +0800 Subject: [PATCH 156/241] [New Feature] (config) Add GitHub release title info. --- .github/release-title.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/release-title.md diff --git a/.github/release-title.md b/.github/release-title.md new file mode 100644 index 00000000..112843c8 --- /dev/null +++ b/.github/release-title.md @@ -0,0 +1 @@ +v2.0.0 - More short and clear <0001f9f9>🍻 \ No newline at end of file From a72e5c5b7698b10dcffbf9dcd8c9279485b9ef23 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 14:31:35 +0800 Subject: [PATCH 157/241] [New Feature] (scripts) Add shell script for building git tag and creating GitHub release. --- .../build_get-tag_or_create_github-release.sh | 242 ++++++++++++++++++ 1 file changed, 242 insertions(+) create mode 100644 scripts/ci/build_get-tag_or_create_github-release.sh diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh new file mode 100644 index 00000000..b9934429 --- /dev/null +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -0,0 +1,242 @@ +#!/usr/bin/env bash + +#set -ex + +# Check whether it has 'release-notes.md' or 'release-title.md' in the target directory '.github'. +has_release_notes=$(ls .github | grep -E "release-notes.md") +has_release_title=$(ls .github | grep -E "release-title.md") +if [ "$has_release_notes" == "" ]; then + echo "It should have *release-notes.md* in '.github' directory of your project in HitHub." + exit 1 +fi +if [ "$has_release_title" == "" ]; then + echo "It should have *release-title.md* in '.github' directory of your project in HitHub." + exit 1 +fi + + +# # # # python-package or github-action-reusable-workflow +release_type=$1 + +if [ "$release_type" == 'python-package' ]; then + # # # # The name of Python package + python_pkg_name=$2 + # # # # For development and troubleshooting + debug_mode=$4 +elif [ "$release_type" == 'github-action-reusable-workflow' ]; then + python_pkg_name="" + debug_mode=$2 +else + echo "Currently, it only has 2 release type: 'python-package' or 'github-action-reusable-workflow'." + exit 1 +fi + +if [ "$release_type" == "" ]; then + echo "The argument 'release_type' (first argument) cannot be empty." + exit 1 +fi + + +# # # # From the PEP440: Software version style rule +# # # +# # # The version setting 1: version format +# # Simple “major.minor” versioning: (general-2) +# 0.1, 0.2, 0.3, 1.0, 1.1 +# # Simple “major.minor.micro” versioning: (general-3) +# 1.0.0, 1.0.1, 1.0.2, 1.1.0 +# # Date based releases, using an incrementing serial within each year, skipping zero: (date-based) +# 2012.1, 2012.2, ..., 2012.15, 2013.1, 2013.2 +# # # The version setting 2: version evolution +# # “major.minor” versioning with alpha, beta and candidate pre-releases: (sema) +# 0.9, 1.0a1, 1.0a2, 1.0b1, 1.0rc1, 1.0 +# # “major.minor” versioning with developmental releases, release candidates and post-releases for minor corrections: (dev) +# 0.9, 1.0.dev1, 1.0.dev2, 1.0.dev3, 1.0c1, 1.0, 1.0.post1, 1.1.dev1 +software_version_format=$3 + +declare version_reg +declare software_version_reg +declare python_version_reg + +if [ "$release_type" == 'python-package' ]; then + + if [ "$python_pkg_name" == "" ]; then + echo "The argument 'python_pkg_name' (second argument) cannot be empty if option 'release_type' (first argument) is 'python-package'." + exit 1 + fi + + if [ "$software_version_format" == "general-2" ]; then + version_reg="[0-9]\.[0-9]" + elif [ "$software_version_format" == "general-3" ]; then + version_reg="[0-9]\.[0-9]\.[0-9]" + elif [ "$software_version_format" == "date-based" ]; then + version_reg="[0-9]{4}\.([0-9]{1,})+" + else + # Default value + version_reg="[0-9]\.[0-9]\.[0-9]" + fi + + software_version_reg="$version_reg*([\.,-]*([a-zA-Z]{1,})*([0-9]{0,})*){0,}" + python_version_reg="__version__ = \"$software_version_reg\"" + +fi + +#if [ "$release_type" == 'python-package' ]; then +# if [ "$software_version_evolution" == "sema" ]; then +# echo "*-*([a-zA-Z]{1,})*([0-9]{0,})" +# elif [ "$software_version_evolution" == "dev" ]; then +# echo "*[\.,-]*([a-zA-Z]{1,})*([0-9]{0,})" +# else +# # Default value +# echo "" +# fi +#fi + + +current_branch=$(git branch --show-current) + +build_git_tag_or_github_release() { + # Generate the new version from previous tag + current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) + if [ "$current_ver" == "" ]; then + current_ver=0 + fi + new_ver=$(( current_ver + 1 )) + new_tag='v'$new_ver'.0.0' + + # git event: push + # all branch -> Build tag + # master branch -> Build tag and create release + + if [ "$debug_mode" == true ]; then + echo " 🔍👀[DEBUG MODE] Build git tag $new_tag in git branch '$current_branch'." + else + git tag -a "$new_tag" -m "$new_tag" + fi + + echo "Build git tag which named '$new_tag' with current branch '$current_branch' successfully!" + if [ "$current_branch" == "master" ]; then + release_title=$(cat .github/release-title.md) + + if [ "$debug_mode" == true ]; then + echo " 🔍👀[DEBUG MODE] Create GitHub release with tag '$new_tag' and title '$release_title' in git branch '$current_branch'." + else + gh release create "$new_tag" --title "$release_title" --notes-file .github/release-notes.md + fi + + echo "Create GitHub release with title '$release_title' successfully!" + fi +} + + +# The truly running implementation of shell script +if [ "$release_type" == 'python-package' ]; then + + # # # # For Python package release + echo 'do python package release' + + git_tag=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]*" | grep -o '[0-9]\.[0-9]\.[0-9]*') + github_release=$(curl -s https://api.github.com/repos/Chisanan232/GitHub-Action_Workflow-Template-Python/releases/latest | jq -r '.tag_name') + # shellcheck disable=SC2002 + pkg_version=$(cat ./"$python_pkg_name"/__pkg_info__.py | grep -E "$python_version_reg" | grep -E -o "$software_version_reg") + + build_git_tag=false + create_github_release=false + + # 1. Compare the Python source code version and git tag, GitHub release version. + if [ "$pkg_version" == "$git_tag" ]; then + echo "Version of git tag info are the same. So it verifies it has built and pushed before." + else + echo "Version of git tag info are different. So it verifies it doesn't build and push before." + build_git_tag=true + fi + + if [ "$current_branch" == "master" ] && [ "$pkg_version" == "$github_release" ]; then + echo "Version of GitHub release info are the same. So it verifies it has built and pushed before." + else + echo "Version of GitHub release info are different. So it verifies it doesn't build and push before." + create_github_release=true + fi + + if [ "$build_git_tag" == true ] || [ "$create_github_release" == true ]; then + + echo "pkg_version: $pkg_version" +# is_pre_release_version=$(echo $pkg_version | sed -n 's/.*\([a-zA-Z][0-9]*\)/\1/p') + is_pre_release_version=$(echo $pkg_version | grep -E -o '([\.-]*([a-zA-Z]{1,})+([0-9]{0,})*){1,}') + echo "is_pre_release_version: $is_pre_release_version" + if [ "$is_pre_release_version" == "" ]; then + echo "The version is not a pre-release." +# build_tag_and_create_release_and_push_pypi=true + # do different things with different ranches + # git event: push + # all branch -> Build tag + # master branch -> Build tag and create release + echo "build tag and create GitHub release, also push code to PyPi" + build_git_tag_or_github_release + echo "Done! This is Official-Release so please push source code to PyPi." + echo "[Final Running Result] Official-Release" + else + echo "The version is a pre-release." +# build_tag_and_create_release_only=true + # do different things with different ranches + # git event: push + # all branch -> Build tag + # master branch -> Build tag and create release + echo "build tag and create GitHub release only" + build_git_tag_or_github_release + echo "Done! This is Pre-Release so please don't push this to PyPi." + echo "[Final Running Result] Pre-Release" + fi + + fi + + # 1. -> Same -> 1-1. Does it have built and pushed before?. + # 1. -> No (In generally, it should no) -> 1-2. Is it a pre-release version in source code? + + # 1-1. Yes, it has built and pushed. -> Doesn't do anything. + # 1-1. No, it doesn't build and push before. -> Build and push directly. + + # 1-2. Yes, it's pre-release. -> Doesn't build and push. Just build git tag and GitHub release. + # 1-2. No, it's not pre-release. -> It means that it's official version, e.g., 1.3.2 version. So it should build git tag and GitHub release first, and build and push. + +elif [ "$release_type" == 'github-action-reusable-workflow' ]; then + + echo 'do github-action-reusable-workflow release' + # # # # For GitHub Action reusable workflow template release + # 1. Compare whether the release-notes.md has different or not. + # Note 1: Diff a specific file with currently latest tag and previous one commit + # https://stackoverflow.com/questions/3338126/how-do-i-diff-the-same-file-between-two-different-commits-on-the-same-branch + # Note 2: Show the output result in stdout directly + # https://stackoverflow.com/questions/17077973/how-to-make-git-diff-write-to-stdout + # Note 3: Here code should be considered what git tag on master branch so we need to verify the info on master branch. + release_notes_has_diff=$(git diff master HEAD~1 .github/release-notes.md | cat) + if [ "$release_notes_has_diff" != "" ]; then + # 1. Yes, it has different. -> Build git tag, GitHub release and version branch + build_git_tag_or_github_release + echo "Done! This is Official-Release of GitHub Action reusable workflow, please create a version branch of it." + echo "[Final Running Result] Official-Release" + +# current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) +# if [ "$current_ver" == "" ]; then +# current_ver=0 +# fi +# new_ver=$(( current_ver + 1 )) +# # Return the new version as output +# # git event: push +# # all branch -> Build tag +# # master branch -> Build tag and create release +# new_tag='v'$new_ver'.0.0' +# git tag -a "$new_tag" -m "$new_tag" +# echo "Build git tag which named '$new_tag' with current branch '$current_branch' successfully!" +# if [ "$current_branch" == "master" ]; then +# release_title=$(cat .github/release-title.md) +# gh release create "$new_tag" --title "$release_title" --notes-file .github/release-notes.md +# echo "Create GitHub release with title '$release_title' successfully!" +# fi + else + # 1. No, do nothing. + # Return nothing output + echo "Release note file doesn't change. Don't do anything." + echo "[Final Running Result] Pre-Release" + fi + +fi From d79278bf9d78b5d22775c17163950dd04f6bc050 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 14:32:26 +0800 Subject: [PATCH 158/241] [New Feature] (code) Add sample source code about Python library source code module '__pkg_info__'. --- test_gh_workflow/__pkg_info__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 test_gh_workflow/__pkg_info__.py diff --git a/test_gh_workflow/__pkg_info__.py b/test_gh_workflow/__pkg_info__.py new file mode 100644 index 00000000..02ca93b3 --- /dev/null +++ b/test_gh_workflow/__pkg_info__.py @@ -0,0 +1 @@ +__version__ = "0.2.0-alpha1.post1" From 810c86413a8917ff984b7fad6ab7d2bc2d8f786b Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 14:47:44 +0800 Subject: [PATCH 159/241] [New Feature] (config) Add a new setting file for controlling whether it should build git tag, create GitHub release or not. --- .github/release-auto-flag.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/release-auto-flag.txt diff --git a/.github/release-auto-flag.txt b/.github/release-auto-flag.txt new file mode 100644 index 00000000..f32a5804 --- /dev/null +++ b/.github/release-auto-flag.txt @@ -0,0 +1 @@ +true \ No newline at end of file From be9cee98df350341e003b12348f14b08123aed21 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 14:50:41 +0800 Subject: [PATCH 160/241] [New Feature] (script) Add a mechanism about it would check the boolean value in file 'release-auto-flag.txt' to let it decides that whether it should run or not. --- scripts/ci/build_get-tag_or_create_github-release.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index b9934429..3fb34068 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -3,6 +3,18 @@ #set -ex # Check whether it has 'release-notes.md' or 'release-title.md' in the target directory '.github'. +has_auto_release_flag=$(ls .github | grep -E "release-auto-flag.txt") +if [ "$has_auto_release_flag" == "" ]; then + echo "It should have *release-auto-flag.txt* in '.github' directory of your project in HitHub." + exit 0 +else + auto_release_flag=$(cat .github/release-auto-flag.txt) + if [ "$auto_release_flag" == false ]; then + echo "Auto-release flag is 'false' so it won't build git tag or create GitHub release." + exit 0 + fi +fi + has_release_notes=$(ls .github | grep -E "release-notes.md") has_release_title=$(ls .github | grep -E "release-title.md") if [ "$has_release_notes" == "" ]; then From 13f34bf3ca8d2d3fb8cc8692614dd751f5e70c9f Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 19:00:42 +0800 Subject: [PATCH 161/241] [Breaking Change] (config) Add process about exporting release type as environment variable. --- scripts/ci/build_get-tag_or_create_github-release.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 3fb34068..9e31f63d 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -106,6 +106,8 @@ fi current_branch=$(git branch --show-current) +declare new_ver + build_git_tag_or_github_release() { # Generate the new version from previous tag current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) @@ -123,6 +125,7 @@ build_git_tag_or_github_release() { echo " 🔍👀[DEBUG MODE] Build git tag $new_tag in git branch '$current_branch'." else git tag -a "$new_tag" -m "$new_tag" + git push -u origin --tags fi echo "Build git tag which named '$new_tag' with current branch '$current_branch' successfully!" @@ -185,6 +188,7 @@ if [ "$release_type" == 'python-package' ]; then echo "build tag and create GitHub release, also push code to PyPi" build_git_tag_or_github_release echo "Done! This is Official-Release so please push source code to PyPi." + export RELEASE_TYPE="Official" echo "[Final Running Result] Official-Release" else echo "The version is a pre-release." @@ -196,6 +200,7 @@ if [ "$release_type" == 'python-package' ]; then echo "build tag and create GitHub release only" build_git_tag_or_github_release echo "Done! This is Pre-Release so please don't push this to PyPi." + export RELEASE_TYPE="Pre" echo "[Final Running Result] Pre-Release" fi @@ -225,6 +230,7 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then # 1. Yes, it has different. -> Build git tag, GitHub release and version branch build_git_tag_or_github_release echo "Done! This is Official-Release of GitHub Action reusable workflow, please create a version branch of it." + export RELEASE_TYPE="$new_ver" echo "[Final Running Result] Official-Release" # current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) @@ -248,6 +254,7 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then # 1. No, do nothing. # Return nothing output echo "Release note file doesn't change. Don't do anything." + export RELEASE_TYPE="Pre" echo "[Final Running Result] Pre-Release" fi From 823ac1d2cabfd31dcc3138499c61f34389e8b7b7 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 19:01:35 +0800 Subject: [PATCH 162/241] [New Feature] (config) Add shell script for creating new git branch by the tagged commit. --- scripts/ci/deployment_new_version_workflow.sh | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 scripts/ci/deployment_new_version_workflow.sh diff --git a/scripts/ci/deployment_new_version_workflow.sh b/scripts/ci/deployment_new_version_workflow.sh new file mode 100644 index 00000000..2e5fcaef --- /dev/null +++ b/scripts/ci/deployment_new_version_workflow.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +debug_mode=$1 + +final_release_type=$RELEASE_TYPE +if [ "$final_release_type" == "Pre" ]; then + echo "It detects Pre-Release flag." +else + echo "It detects Official-Release flag." + if [ "$debug_mode" == true ]; then + echo " 🔍👀[DEBUG MODE] Create new git branch for the new version." + else + echo "Add git remote reference." + git remote add github-action_workflow-template https://github.com/Chisanan232/GitHub-Action-Template-Python.git + echo "Check all git remote reference." + git remote -v + echo "Create a new git branch as version." + git checkout -b "v$final_release_type" + echo "Push the source code as a branch with one specific version to the GitHub." + git push -u github-action_workflow-template "v$final_release_type" + fi +fi + +echo "Done!" From 5e893ed2b45e6a43a3ab895d800493d21ae258b6 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 19:02:39 +0800 Subject: [PATCH 163/241] [New Feature] (config) Add jobs in CI/CD about afterhandle if testing is pass. --- .../workflows/test-reusable-workflows.yaml | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 301a938e..459571aa 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -120,6 +120,79 @@ jobs: upload-to-codacy: true + build_git-tag_and_create_github-release: +# name: Build git tag and GitHub release if it needs + needs: [codecov_finish, coveralls_finish, codacy_finish] + runs-on: ubuntu-latest + env: + RELEASE_TYPE: Initial + outputs: + release_type: ${{ steps.release_checking.outputs.run_result }} + steps: + - uses: actions/checkout@v2 + + - name: Build git tag and create GitHub release + id: release_checking + run: bash ./scripts/ci/build_get-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true' + + - name: Build git tag and create GitHub release + id: release_checking + run: echo "::set-output name=run_result::$(echo $RELEASE_TYPE)" + + + deploy_as_new_branch: +# name: Create new git branch by the tagged commit + needs: build_git-tag_and_create_github-release + if: ${{ needs.build_git-tag_and_create_github-release.outputs.release_type != 'Pre' }} + steps: + - uses: actions/checkout@v2 + + - name: Create new git branch by the tagged commit + run: bash ./scripts/ci/deployment_new_version_workflow.sh 'github-action-reusable-workflow' 'true' + + +# create_version_tag: +# if: github.ref_name == 'release' || github.event == 'push' +# name: Build a tag in GitHub +# needs: [codecov_finish, coveralls_finish, codacy_finish] +# steps: +# - name: Get the latest version of package from '__pgk_info__' module +# run: cat ./test_gh_workflow/__pkg_info__.py | grep -e '__version__ = "[0-9].[0-9].[0-9]*"' | grep -o '[0-9].[0-9].[0-9]*' +# +# - name: Get the latest git tag +# run: git describe --tag --abbrev=0 --match "v[0-9].[0-9].[0-9]*" +# +# - name: Tag a version info on the latest commit +# run: git tag -a 'v2.0.0' -m 'Refactor and integrate the configurations to let configurations be more shorter and clear.' +# +# - name: Release the source code with the tag and release note +# run: gh release create v2.0.0 --title 'v2.0.0 - More shorter and clear <0001f9f9>🍻' --notes-file .github/release-notes.md +# +# +# build_version_branch: +# if: github.ref_name == 'master' || github.event == 'push' +# name: Build a Git branch as version in GitHub +# needs: [codecov_finish, coveralls_finish, codacy_finish] +# steps: +# - name: Check whether it has a git tag on the latest commit or not. +# run: | +# git tag +# +# - name: Do something +# run: | +# echo "Add git remote reference" +# git remote add github-action_workflow-template https://github.com/Chisanan232/GitHub-Action-Template-Python.git +# +# echo "Verify the git remote info ..." +# git remote -v +# +# echo "Create and switch git branch with version" +# git checkout -b v2 +# +# echo "Push the project to GitHub as the branch" +# git push -u github-action_workflow-template v2 + + # pre-building_check: ## name: Check about it could work finely by installing the Python package with setup.py file # needs: [codecov_finish, codacy_finish] From 4666244725bc0230bd63c789f2b81a3e886643c7 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 19:05:04 +0800 Subject: [PATCH 164/241] [Bug Fix] (config) Fix the issue about losing 'runs-on'. --- .github/workflows/test-reusable-workflows.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 459571aa..5233644f 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -143,6 +143,7 @@ jobs: deploy_as_new_branch: # name: Create new git branch by the tagged commit needs: build_git-tag_and_create_github-release + runs-on: ubuntu-latest if: ${{ needs.build_git-tag_and_create_github-release.outputs.release_type != 'Pre' }} steps: - uses: actions/checkout@v2 From 833b5bfd70e51f149469716b5bec2ca2a99449cb Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 19:05:55 +0800 Subject: [PATCH 165/241] [Bug Fix] (config) Fix the issue about duplicated id. --- .github/workflows/test-reusable-workflows.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 5233644f..d4c5b054 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -132,7 +132,6 @@ jobs: - uses: actions/checkout@v2 - name: Build git tag and create GitHub release - id: release_checking run: bash ./scripts/ci/build_get-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true' - name: Build git tag and create GitHub release From 9f2fa94032dbab1492b60ed34d376b005740a6d1 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 19:18:52 +0800 Subject: [PATCH 166/241] [Test] (config) Test for assigning environment variable. --- scripts/ci/build_get-tag_or_create_github-release.sh | 12 ++++++++---- scripts/ci/deployment_new_version_workflow.sh | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 9e31f63d..89b6e6f1 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -188,7 +188,8 @@ if [ "$release_type" == 'python-package' ]; then echo "build tag and create GitHub release, also push code to PyPi" build_git_tag_or_github_release echo "Done! This is Official-Release so please push source code to PyPi." - export RELEASE_TYPE="Official" +# RELEASE_TYPE="Official"; export RELEASE_TYPE + echo "Official" >> $RELEASE_TYPE echo "[Final Running Result] Official-Release" else echo "The version is a pre-release." @@ -200,7 +201,8 @@ if [ "$release_type" == 'python-package' ]; then echo "build tag and create GitHub release only" build_git_tag_or_github_release echo "Done! This is Pre-Release so please don't push this to PyPi." - export RELEASE_TYPE="Pre" +# RELEASE_TYPE="Pre"; export RELEASE_TYPE + echo "Pre" >> $RELEASE_TYPE echo "[Final Running Result] Pre-Release" fi @@ -230,7 +232,8 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then # 1. Yes, it has different. -> Build git tag, GitHub release and version branch build_git_tag_or_github_release echo "Done! This is Official-Release of GitHub Action reusable workflow, please create a version branch of it." - export RELEASE_TYPE="$new_ver" +# RELEASE_TYPE="$new_ver"; export RELEASE_TYPE + echo "$new_ver" >> $RELEASE_TYPE echo "[Final Running Result] Official-Release" # current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) @@ -254,7 +257,8 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then # 1. No, do nothing. # Return nothing output echo "Release note file doesn't change. Don't do anything." - export RELEASE_TYPE="Pre" +# RELEASE_TYPE="Pre"; export RELEASE_TYPE + echo "Pre" >> $RELEASE_TYPE echo "[Final Running Result] Pre-Release" fi diff --git a/scripts/ci/deployment_new_version_workflow.sh b/scripts/ci/deployment_new_version_workflow.sh index 2e5fcaef..39a33752 100644 --- a/scripts/ci/deployment_new_version_workflow.sh +++ b/scripts/ci/deployment_new_version_workflow.sh @@ -8,7 +8,7 @@ if [ "$final_release_type" == "Pre" ]; then else echo "It detects Official-Release flag." if [ "$debug_mode" == true ]; then - echo " 🔍👀[DEBUG MODE] Create new git branch for the new version." + echo " 🔍👀[DEBUG MODE] Create new git branch for the new version $final_release_type." else echo "Add git remote reference." git remote add github-action_workflow-template https://github.com/Chisanan232/GitHub-Action-Template-Python.git From fe3dd244b6e6782650bf60dc7ffa959f293a46ab Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 21:38:08 +0800 Subject: [PATCH 167/241] [Bug Fix] (config) Fix the issue about fatal: ambiguous argument 'master': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]' --- scripts/ci/build_get-tag_or_create_github-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 89b6e6f1..7cd3aae6 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -227,7 +227,7 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then # Note 2: Show the output result in stdout directly # https://stackoverflow.com/questions/17077973/how-to-make-git-diff-write-to-stdout # Note 3: Here code should be considered what git tag on master branch so we need to verify the info on master branch. - release_notes_has_diff=$(git diff master HEAD~1 .github/release-notes.md | cat) + release_notes_has_diff=$(git diff master HEAD~1 -- .github/release-notes.md | cat) if [ "$release_notes_has_diff" != "" ]; then # 1. Yes, it has different. -> Build git tag, GitHub release and version branch build_git_tag_or_github_release From 928f7f9067cdca20b32df0d7b49897a6dd7eebb7 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 21:39:02 +0800 Subject: [PATCH 168/241] [Breaking Change + Test] (config) Modify setting about environment variable. --- .github/workflows/test-reusable-workflows.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index d4c5b054..d095626f 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -134,7 +134,7 @@ jobs: - name: Build git tag and create GitHub release run: bash ./scripts/ci/build_get-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true' - - name: Build git tag and create GitHub release + - name: Export the running result as environment variable 'RELEASE_TYPE' id: release_checking run: echo "::set-output name=run_result::$(echo $RELEASE_TYPE)" @@ -142,11 +142,12 @@ jobs: deploy_as_new_branch: # name: Create new git branch by the tagged commit needs: build_git-tag_and_create_github-release + if: ${{ needs.build_git-tag_and_create_github-release.outputs.release_type != 'Initial' && needs.build_git-tag_and_create_github-release.outputs.release_type != 'Pre' }} runs-on: ubuntu-latest - if: ${{ needs.build_git-tag_and_create_github-release.outputs.release_type != 'Pre' }} + env: + RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.release_type }} steps: - uses: actions/checkout@v2 - - name: Create new git branch by the tagged commit run: bash ./scripts/ci/deployment_new_version_workflow.sh 'github-action-reusable-workflow' 'true' From f7fd83b56beafcf52a23bbbaf42e01d6d84fc805 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 21:39:06 +0800 Subject: [PATCH 169/241] [Breaking Change + Test] (config) Modify setting about environment variable. --- .github/workflows/test-reusable-workflows.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index d095626f..08c47bdf 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -148,6 +148,7 @@ jobs: RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.release_type }} steps: - uses: actions/checkout@v2 + - name: Create new git branch by the tagged commit run: bash ./scripts/ci/deployment_new_version_workflow.sh 'github-action-reusable-workflow' 'true' From 8c923908178b80d4fbe3e0fd8a1edf55f9261c62 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 21:39:54 +0800 Subject: [PATCH 170/241] [Breaking Change + Test] (config) Modify setting about environment variable. --- .github/workflows/test-reusable-workflows.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 08c47bdf..779d54fc 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -148,7 +148,7 @@ jobs: RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.release_type }} steps: - uses: actions/checkout@v2 - + - name: Create new git branch by the tagged commit run: bash ./scripts/ci/deployment_new_version_workflow.sh 'github-action-reusable-workflow' 'true' From b07a0f2a7f625b3a69364128a280032b390f2545 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 21:47:08 +0800 Subject: [PATCH 171/241] [Breaking Change + Test] (config) Add initialing git branch process. --- scripts/ci/build_get-tag_or_create_github-release.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 7cd3aae6..737b892e 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -227,6 +227,12 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then # Note 2: Show the output result in stdout directly # https://stackoverflow.com/questions/17077973/how-to-make-git-diff-write-to-stdout # Note 3: Here code should be considered what git tag on master branch so we need to verify the info on master branch. + # Note 4: We should initial a git branch 'master' to provide git diff feature working + echo "Initial and switch to git branch 'master'." + git checkout -b master + echo "Switch back to git branch '$current_branch'." + git switch "$current_branch" + echo "Check the different between current git branch and master branch." release_notes_has_diff=$(git diff master HEAD~1 -- .github/release-notes.md | cat) if [ "$release_notes_has_diff" != "" ]; then # 1. Yes, it has different. -> Build git tag, GitHub release and version branch From 9098bb64c51385738c58ac54ba03c2e39b675ece Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 21:57:54 +0800 Subject: [PATCH 172/241] [Breaking Change + Test] (config) Add process about running git command lines to verify some info. --- scripts/ci/build_get-tag_or_create_github-release.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 737b892e..c90a6306 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -104,7 +104,13 @@ fi #fi -current_branch=$(git branch --show-current) +#current_branch=$(git branch --show-current) +echo "Verify the git branch info" +git branch --list +echo "Get the current git branch info" +current_branch=$(git branch --list | cat | grep -E '\* ([a-zA-Z0-9]{1,16})' | grep -E -o '([a-zA-Z0-9]{1,16})') +echo "Current git branch: $current_branch" + declare new_ver From 1861d3569d91413a1960c9101b68f2a05c56c9e9 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 22:05:22 +0800 Subject: [PATCH 173/241] [Bug Fix + Test] (config) Fix the issue about 'git diff'. --- scripts/ci/build_get-tag_or_create_github-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index c90a6306..1254ce70 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -239,7 +239,7 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then echo "Switch back to git branch '$current_branch'." git switch "$current_branch" echo "Check the different between current git branch and master branch." - release_notes_has_diff=$(git diff master HEAD~1 -- .github/release-notes.md | cat) + release_notes_has_diff=$(git diff master "$current_branch" -- .github/release-notes.md | cat) if [ "$release_notes_has_diff" != "" ]; then # 1. Yes, it has different. -> Build git tag, GitHub release and version branch build_git_tag_or_github_release From 33c1988fa6736f59e3f6c94a4a70eb12b0b62f23 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 22:06:23 +0800 Subject: [PATCH 174/241] [Breaking Change + Test] (config) Modify the if-condition of job-running. --- .github/workflows/test-reusable-workflows.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 779d54fc..38f33773 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -122,6 +122,7 @@ jobs: build_git-tag_and_create_github-release: # name: Build git tag and GitHub release if it needs + if: github.event == 'push' needs: [codecov_finish, coveralls_finish, codacy_finish] runs-on: ubuntu-latest env: @@ -141,8 +142,10 @@ jobs: deploy_as_new_branch: # name: Create new git branch by the tagged commit + if: ${{ github.event == 'push' && \ + needs.build_git-tag_and_create_github-release.outputs.release_type != 'Initial' && \ + needs.build_git-tag_and_create_github-release.outputs.release_type != 'Pre' }} needs: build_git-tag_and_create_github-release - if: ${{ needs.build_git-tag_and_create_github-release.outputs.release_type != 'Initial' && needs.build_git-tag_and_create_github-release.outputs.release_type != 'Pre' }} runs-on: ubuntu-latest env: RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.release_type }} From 7167431866be77f0de10711810ca1b36744716a9 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 22:08:18 +0800 Subject: [PATCH 175/241] [Bug Fix] (config) Fix the incorrect syntax issue. --- .github/workflows/test-reusable-workflows.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 38f33773..5af1b891 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -142,8 +142,8 @@ jobs: deploy_as_new_branch: # name: Create new git branch by the tagged commit - if: ${{ github.event == 'push' && \ - needs.build_git-tag_and_create_github-release.outputs.release_type != 'Initial' && \ + if: ${{ github.event == 'push' && + needs.build_git-tag_and_create_github-release.outputs.release_type != 'Initial' && needs.build_git-tag_and_create_github-release.outputs.release_type != 'Pre' }} needs: build_git-tag_and_create_github-release runs-on: ubuntu-latest From 631a6c3893e2196901bece1fc6c1dd893807f730 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 22:27:17 +0800 Subject: [PATCH 176/241] [Bug Fix] (config) Fix the issue about incorrect usage of GitHub Action context. --- .github/workflows/test-reusable-workflows.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 5af1b891..2f5e3ee0 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -122,7 +122,7 @@ jobs: build_git-tag_and_create_github-release: # name: Build git tag and GitHub release if it needs - if: github.event == 'push' + if: github.event_name == 'push' needs: [codecov_finish, coveralls_finish, codacy_finish] runs-on: ubuntu-latest env: @@ -142,7 +142,7 @@ jobs: deploy_as_new_branch: # name: Create new git branch by the tagged commit - if: ${{ github.event == 'push' && + if: ${{ github.event_name == 'push' && needs.build_git-tag_and_create_github-release.outputs.release_type != 'Initial' && needs.build_git-tag_and_create_github-release.outputs.release_type != 'Pre' }} needs: build_git-tag_and_create_github-release From 7d83d9cc6f4f0e929264900c57820df2dd43eac4 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 22:38:48 +0800 Subject: [PATCH 177/241] [Test] (config) Test for building tag feature. --- .github/workflows/test-reusable-workflows.yaml | 4 +++- scripts/ci/build_get-tag_or_create_github-release.sh | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 2f5e3ee0..3bbe1348 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -137,7 +137,9 @@ jobs: - name: Export the running result as environment variable 'RELEASE_TYPE' id: release_checking - run: echo "::set-output name=run_result::$(echo $RELEASE_TYPE)" + run: | + echo "RELEASE_TYPE: $RELEASE_TYPE" + echo "::set-output name=run_result::$(echo $RELEASE_TYPE)" deploy_as_new_branch: diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 1254ce70..792262ef 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -240,6 +240,7 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then git switch "$current_branch" echo "Check the different between current git branch and master branch." release_notes_has_diff=$(git diff master "$current_branch" -- .github/release-notes.md | cat) + echo "release_notes_has_diff: $release_notes_has_diff" if [ "$release_notes_has_diff" != "" ]; then # 1. Yes, it has different. -> Build git tag, GitHub release and version branch build_git_tag_or_github_release From ab470c5613b96d4e7b05e4f630bcca6715c6a1da Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 22:57:51 +0800 Subject: [PATCH 178/241] [Test] (config) Test for building tag feature. --- scripts/ci/build_get-tag_or_create_github-release.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 792262ef..98bb1329 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -236,8 +236,12 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then # Note 4: We should initial a git branch 'master' to provide git diff feature working echo "Initial and switch to git branch 'master'." git checkout -b master + git pull echo "Switch back to git branch '$current_branch'." git switch "$current_branch" + echo "+++++++++++++++++++++++++++++++++++" + git diff master "$current_branch" -- .github/release-notes.md | cat + echo "+++++++++++++++++++++++++++++++++++" echo "Check the different between current git branch and master branch." release_notes_has_diff=$(git diff master "$current_branch" -- .github/release-notes.md | cat) echo "release_notes_has_diff: $release_notes_has_diff" From 4ea5817b12e0ffea0c2e7ba4e7df183d78ddb34e Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 23:03:50 +0800 Subject: [PATCH 179/241] [Test] (config) Test for building tag feature. --- scripts/ci/build_get-tag_or_create_github-release.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 98bb1329..6b77b3c3 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -236,11 +236,10 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then # Note 4: We should initial a git branch 'master' to provide git diff feature working echo "Initial and switch to git branch 'master'." git checkout -b master - git pull echo "Switch back to git branch '$current_branch'." git switch "$current_branch" echo "+++++++++++++++++++++++++++++++++++" - git diff master "$current_branch" -- .github/release-notes.md | cat + git diff origin/master "$current_branch" -- .github/release-notes.md | cat echo "+++++++++++++++++++++++++++++++++++" echo "Check the different between current git branch and master branch." release_notes_has_diff=$(git diff master "$current_branch" -- .github/release-notes.md | cat) From 2deff112ff9f139930f026ab03124bc79768e765 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 23:08:33 +0800 Subject: [PATCH 180/241] [Test] (config) Test for building tag feature. --- scripts/ci/build_get-tag_or_create_github-release.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 6b77b3c3..60ef70fc 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -107,6 +107,8 @@ fi #current_branch=$(git branch --show-current) echo "Verify the git branch info" git branch --list +echo "Verify the git remote info" +git remote -v echo "Get the current git branch info" current_branch=$(git branch --list | cat | grep -E '\* ([a-zA-Z0-9]{1,16})' | grep -E -o '([a-zA-Z0-9]{1,16})') echo "Current git branch: $current_branch" From 7062a8b30a047a21edc90e7e9d466af9b81fa438 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 23:12:31 +0800 Subject: [PATCH 181/241] [Test] (config) Test for building tag feature. --- scripts/ci/build_get-tag_or_create_github-release.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 60ef70fc..0ee7f960 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -236,10 +236,10 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then # https://stackoverflow.com/questions/17077973/how-to-make-git-diff-write-to-stdout # Note 3: Here code should be considered what git tag on master branch so we need to verify the info on master branch. # Note 4: We should initial a git branch 'master' to provide git diff feature working - echo "Initial and switch to git branch 'master'." - git checkout -b master - echo "Switch back to git branch '$current_branch'." - git switch "$current_branch" +# echo "Initial and switch to git branch 'master'." +# git checkout -b master +# echo "Switch back to git branch '$current_branch'." +# git switch "$current_branch" echo "+++++++++++++++++++++++++++++++++++" git diff origin/master "$current_branch" -- .github/release-notes.md | cat echo "+++++++++++++++++++++++++++++++++++" From 0e710ed744ed46a9ee97d12655a04657d2e2fde2 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 23:17:47 +0800 Subject: [PATCH 182/241] [Test] (config) Test for building tag feature. --- scripts/ci/build_get-tag_or_create_github-release.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 0ee7f960..6867886f 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -241,7 +241,9 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then # echo "Switch back to git branch '$current_branch'." # git switch "$current_branch" echo "+++++++++++++++++++++++++++++++++++" - git diff origin/master "$current_branch" -- .github/release-notes.md | cat + git diff "$current_branch" origin/master -- .github/release-notes.md | cat + echo "+++++++++++++++++++++++++++++++++++" + git diff origin/master -- .github/release-notes.md | cat echo "+++++++++++++++++++++++++++++++++++" echo "Check the different between current git branch and master branch." release_notes_has_diff=$(git diff master "$current_branch" -- .github/release-notes.md | cat) From ffce745bdeb53b607444fbb12c8ae17926e087ea Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Sun, 28 Aug 2022 23:22:08 +0800 Subject: [PATCH 183/241] [Test] (config) Test for building tag feature. --- scripts/ci/build_get-tag_or_create_github-release.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 6867886f..88e8f0d9 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -107,6 +107,8 @@ fi #current_branch=$(git branch --show-current) echo "Verify the git branch info" git branch --list +echo "Verify all the git branch info" +git branch -a echo "Verify the git remote info" git remote -v echo "Get the current git branch info" @@ -241,9 +243,11 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then # echo "Switch back to git branch '$current_branch'." # git switch "$current_branch" echo "+++++++++++++++++++++++++++++++++++" - git diff "$current_branch" origin/master -- .github/release-notes.md | cat + git diff remotes/origin/master "$current_branch" -- .github/release-notes.md | cat echo "+++++++++++++++++++++++++++++++++++" - git diff origin/master -- .github/release-notes.md | cat + git diff "$current_branch" remotes/origin/master -- .github/release-notes.md | cat + echo "+++++++++++++++++++++++++++++++++++" + git diff remotes/origin/master -- .github/release-notes.md | cat echo "+++++++++++++++++++++++++++++++++++" echo "Check the different between current git branch and master branch." release_notes_has_diff=$(git diff master "$current_branch" -- .github/release-notes.md | cat) From 71ecf00073da8b821a1df6b1d0fbfc0c91a2e8f9 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 09:25:49 +0800 Subject: [PATCH 184/241] [Test] (config) Test for building tag feature. --- .../build_get-tag_or_create_github-release.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 88e8f0d9..06f61877 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -243,12 +243,24 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then # echo "Switch back to git branch '$current_branch'." # git switch "$current_branch" echo "+++++++++++++++++++++++++++++++++++" - git diff remotes/origin/master "$current_branch" -- .github/release-notes.md | cat + git diff --name-only remotes/origin/master "$current_branch" -- .github/release-notes.md | cat echo "+++++++++++++++++++++++++++++++++++" - git diff "$current_branch" remotes/origin/master -- .github/release-notes.md | cat + git diff --name-only "$current_branch" remotes/origin/master -- .github/release-notes.md | cat echo "+++++++++++++++++++++++++++++++++++" - git diff remotes/origin/master -- .github/release-notes.md | cat + git diff --name-only remotes/origin/master -- .github/release-notes.md | cat echo "+++++++++++++++++++++++++++++++++++" + + echo "run git fetch" + git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* + + echo "+++++++++++++++++++++++++++++++++++" + git diff --name-only remotes/origin/master "$current_branch" -- .github/release-notes.md | cat + echo "+++++++++++++++++++++++++++++++++++" + git diff --name-only "$current_branch" remotes/origin/master -- .github/release-notes.md | cat + echo "+++++++++++++++++++++++++++++++++++" + git diff --name-only remotes/origin/master -- .github/release-notes.md | cat + echo "+++++++++++++++++++++++++++++++++++" + echo "Check the different between current git branch and master branch." release_notes_has_diff=$(git diff master "$current_branch" -- .github/release-notes.md | cat) echo "release_notes_has_diff: $release_notes_has_diff" From e7682612ed671871591f79d50f862c0fd76d1b0d Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 09:28:53 +0800 Subject: [PATCH 185/241] [Test] (config) Test for building tag feature. --- scripts/ci/build_get-tag_or_create_github-release.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 06f61877..165bb4c7 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -253,12 +253,17 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then echo "run git fetch" git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* + echo "Verify all the git branch info" + git branch -a + echo "Verify the git remote info" + git remote -v + echo "+++++++++++++++++++++++++++++++++++" - git diff --name-only remotes/origin/master "$current_branch" -- .github/release-notes.md | cat + git diff origin/master "$current_branch" -- .github/release-notes.md | cat echo "+++++++++++++++++++++++++++++++++++" - git diff --name-only "$current_branch" remotes/origin/master -- .github/release-notes.md | cat + git diff "$current_branch" origin/master -- .github/release-notes.md | cat echo "+++++++++++++++++++++++++++++++++++" - git diff --name-only remotes/origin/master -- .github/release-notes.md | cat + git diff origin/master -- .github/release-notes.md | cat echo "+++++++++++++++++++++++++++++++++++" echo "Check the different between current git branch and master branch." From f3610422f946bd815066c55c0f1a400af25ab8bb Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 09:36:23 +0800 Subject: [PATCH 186/241] [Breaking Change + Test] (config) Add git fetch process before git diff. --- .../build_get-tag_or_create_github-release.sh | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 165bb4c7..060eac91 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -242,33 +242,19 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then # git checkout -b master # echo "Switch back to git branch '$current_branch'." # git switch "$current_branch" - echo "+++++++++++++++++++++++++++++++++++" - git diff --name-only remotes/origin/master "$current_branch" -- .github/release-notes.md | cat - echo "+++++++++++++++++++++++++++++++++++" - git diff --name-only "$current_branch" remotes/origin/master -- .github/release-notes.md | cat - echo "+++++++++++++++++++++++++++++++++++" - git diff --name-only remotes/origin/master -- .github/release-notes.md | cat - echo "+++++++++++++++++++++++++++++++++++" - - echo "run git fetch" + echo "Run git fetch to sync upstream with latest project in GitHub" git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* - echo "Verify all the git branch info" + echo "Verify all the git branch info again after git fetch." git branch -a - echo "Verify the git remote info" - git remote -v - echo "+++++++++++++++++++++++++++++++++++" - git diff origin/master "$current_branch" -- .github/release-notes.md | cat - echo "+++++++++++++++++++++++++++++++++++" - git diff "$current_branch" origin/master -- .github/release-notes.md | cat - echo "+++++++++++++++++++++++++++++++++++" - git diff origin/master -- .github/release-notes.md | cat - echo "+++++++++++++++++++++++++++++++++++" + echo "Verify the git remote info again after git fetch." + git remote -v echo "Check the different between current git branch and master branch." - release_notes_has_diff=$(git diff master "$current_branch" -- .github/release-notes.md | cat) + release_notes_has_diff=$(git diff origin/master "$current_branch" -- .github/release-notes.md | cat) echo "release_notes_has_diff: $release_notes_has_diff" + if [ "$release_notes_has_diff" != "" ]; then # 1. Yes, it has different. -> Build git tag, GitHub release and version branch build_git_tag_or_github_release From 81ec7ea2d37b4cdc74a060ab7a0fad4ebd2e78ce Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 09:36:56 +0800 Subject: [PATCH 187/241] [Breaking Change] (config) Add if-condition that it only runs if current git branch is master. --- .github/workflows/test-reusable-workflows.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 3bbe1348..ee7b5a3b 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -144,7 +144,8 @@ jobs: deploy_as_new_branch: # name: Create new git branch by the tagged commit - if: ${{ github.event_name == 'push' && + if: ${{ github.ref_name == 'master' && + github.event_name == 'push' && needs.build_git-tag_and_create_github-release.outputs.release_type != 'Initial' && needs.build_git-tag_and_create_github-release.outputs.release_type != 'Pre' }} needs: build_git-tag_and_create_github-release From 38480e76e350aaee1c4a9cef49b9af77ec639345 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 09:43:20 +0800 Subject: [PATCH 188/241] [Test] (config) Test for setting environment variable feature. --- .../ci/build_get-tag_or_create_github-release.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 060eac91..ef37471e 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -237,11 +237,9 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then # Note 2: Show the output result in stdout directly # https://stackoverflow.com/questions/17077973/how-to-make-git-diff-write-to-stdout # Note 3: Here code should be considered what git tag on master branch so we need to verify the info on master branch. - # Note 4: We should initial a git branch 'master' to provide git diff feature working -# echo "Initial and switch to git branch 'master'." -# git checkout -b master -# echo "Switch back to git branch '$current_branch'." -# git switch "$current_branch" + # Note 4: We should git fetch to provide git diff feature working + # https://github.com/actions/checkout/issues/160 + echo "Run git fetch to sync upstream with latest project in GitHub" git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* @@ -260,7 +258,15 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then build_git_tag_or_github_release echo "Done! This is Official-Release of GitHub Action reusable workflow, please create a version branch of it." # RELEASE_TYPE="$new_ver"; export RELEASE_TYPE +# echo "$new_ver" >> $RELEASE_TYPE + echo "Set environment variable in GitHub" + export RELEASE_TYPE="$new_ver" + echo $RELEASE_TYPE + + echo "Set environment variable in GitHub" echo "$new_ver" >> $RELEASE_TYPE + echo $RELEASE_TYPE + echo "[Final Running Result] Official-Release" # current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) From 01bc3243551b82150c6c90f703d1edca4b45d5c5 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 09:47:46 +0800 Subject: [PATCH 189/241] [Test] (config) Test for setting environment variable feature. --- .github/workflows/test-reusable-workflows.yaml | 16 ++++++++++------ .../ci/build_get-tag_or_create_github-release.sh | 6 +++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index ee7b5a3b..29ff5bfb 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -133,14 +133,18 @@ jobs: - uses: actions/checkout@v2 - name: Build git tag and create GitHub release - run: bash ./scripts/ci/build_get-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true' - - - name: Export the running result as environment variable 'RELEASE_TYPE' - id: release_checking - run: | - echo "RELEASE_TYPE: $RELEASE_TYPE" + run: | + bash ./scripts/ci/build_get-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true' + echo "Shell script done. Start to set environment variable." + echo "[Final in job.steps.step] RELEASE_TYPE: $RELEASE_TYPE" echo "::set-output name=run_result::$(echo $RELEASE_TYPE)" +# - name: Export the running result as environment variable 'RELEASE_TYPE' +# id: release_checking +# run: | +# echo "RELEASE_TYPE: $RELEASE_TYPE" +# echo "::set-output name=run_result::$(echo $RELEASE_TYPE)" + deploy_as_new_branch: # name: Create new git branch by the tagged commit diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index ef37471e..613af188 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -263,9 +263,9 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then export RELEASE_TYPE="$new_ver" echo $RELEASE_TYPE - echo "Set environment variable in GitHub" - echo "$new_ver" >> $RELEASE_TYPE - echo $RELEASE_TYPE +# echo "Set environment variable in GitHub" +# echo "$new_ver" >> $RELEASE_TYPE +# echo $RELEASE_TYPE echo "[Final Running Result] Official-Release" From 542311b272e393b9383f48941ca36984344818a5 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 09:51:25 +0800 Subject: [PATCH 190/241] [Test] (config) Test for setting environment variable feature. --- .github/workflows/test-reusable-workflows.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 29ff5bfb..3d434672 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -125,8 +125,8 @@ jobs: if: github.event_name == 'push' needs: [codecov_finish, coveralls_finish, codacy_finish] runs-on: ubuntu-latest - env: - RELEASE_TYPE: Initial +# env: +# RELEASE_TYPE: Initial outputs: release_type: ${{ steps.release_checking.outputs.run_result }} steps: @@ -148,7 +148,7 @@ jobs: deploy_as_new_branch: # name: Create new git branch by the tagged commit - if: ${{ github.ref_name == 'master' && + if: ${{ #github.ref_name == 'master' && github.event_name == 'push' && needs.build_git-tag_and_create_github-release.outputs.release_type != 'Initial' && needs.build_git-tag_and_create_github-release.outputs.release_type != 'Pre' }} From 99f606b5a59a7b7e5e615dc8b930b50a4864e7dd Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 09:53:49 +0800 Subject: [PATCH 191/241] [Test] (config) Test for setting environment variable feature. --- .github/workflows/test-reusable-workflows.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 3d434672..9cad4be6 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -148,8 +148,7 @@ jobs: deploy_as_new_branch: # name: Create new git branch by the tagged commit - if: ${{ #github.ref_name == 'master' && - github.event_name == 'push' && + if: ${{ github.event_name == 'push' && needs.build_git-tag_and_create_github-release.outputs.release_type != 'Initial' && needs.build_git-tag_and_create_github-release.outputs.release_type != 'Pre' }} needs: build_git-tag_and_create_github-release From d25d9abb7aa4a417bdba4baf4250e8b958e58248 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 10:01:47 +0800 Subject: [PATCH 192/241] [Test] (config) Test for setting environment variable feature. --- .github/workflows/test-reusable-workflows.yaml | 6 +++--- scripts/ci/build_get-tag_or_create_github-release.sh | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 9cad4be6..a4eb3322 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -136,8 +136,8 @@ jobs: run: | bash ./scripts/ci/build_get-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true' echo "Shell script done. Start to set environment variable." - echo "[Final in job.steps.step] RELEASE_TYPE: $RELEASE_TYPE" - echo "::set-output name=run_result::$(echo $RELEASE_TYPE)" +# echo "::set-output name=run_result::$(echo $RELEASE_TYPE)" + echo ${{ outputs.release_type }} # - name: Export the running result as environment variable 'RELEASE_TYPE' # id: release_checking @@ -159,7 +159,7 @@ jobs: - uses: actions/checkout@v2 - name: Create new git branch by the tagged commit - run: bash ./scripts/ci/deployment_new_version_workflow.sh 'github-action-reusable-workflow' 'true' + run: bash ./scripts/ci/deployment_new_version_workflow.sh 'true' # create_version_tag: diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 613af188..e0ef8152 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -262,6 +262,7 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then echo "Set environment variable in GitHub" export RELEASE_TYPE="$new_ver" echo $RELEASE_TYPE + echo "::set-output name=run_result::$(echo $RELEASE_TYPE)" # echo "Set environment variable in GitHub" # echo "$new_ver" >> $RELEASE_TYPE From a07e95b926f91b25bdd04b78f9c2d59f0917530f Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 10:03:21 +0800 Subject: [PATCH 193/241] [Test] (config) Test for setting environment variable feature. --- .github/workflows/test-reusable-workflows.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index a4eb3322..37cadefb 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -137,7 +137,7 @@ jobs: bash ./scripts/ci/build_get-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true' echo "Shell script done. Start to set environment variable." # echo "::set-output name=run_result::$(echo $RELEASE_TYPE)" - echo ${{ outputs.release_type }} + echo "::get-output name=run_result" # - name: Export the running result as environment variable 'RELEASE_TYPE' # id: release_checking From 08eac59c926092de3e6013eb82a353433b7656b3 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 10:04:48 +0800 Subject: [PATCH 194/241] [Test] (config) Test for setting environment variable feature. --- .github/workflows/test-reusable-workflows.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 37cadefb..830f2afe 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -135,9 +135,9 @@ jobs: - name: Build git tag and create GitHub release run: | bash ./scripts/ci/build_get-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true' - echo "Shell script done. Start to set environment variable." +# echo "Shell script done. Start to set environment variable." # echo "::set-output name=run_result::$(echo $RELEASE_TYPE)" - echo "::get-output name=run_result" +# echo "::get-output name=run_result" # - name: Export the running result as environment variable 'RELEASE_TYPE' # id: release_checking From e23df82bac77ff166e6c5f8786a2293064e60d5a Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 10:14:27 +0800 Subject: [PATCH 195/241] [Test] (config) Test for setting environment variable feature. --- .../workflows/test-reusable-workflows.yaml | 20 +++++++++---------- .../build_get-tag_or_create_github-release.sh | 3 +-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 830f2afe..937109a2 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -133,17 +133,15 @@ jobs: - uses: actions/checkout@v2 - name: Build git tag and create GitHub release - run: | - bash ./scripts/ci/build_get-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true' -# echo "Shell script done. Start to set environment variable." -# echo "::set-output name=run_result::$(echo $RELEASE_TYPE)" -# echo "::get-output name=run_result" - -# - name: Export the running result as environment variable 'RELEASE_TYPE' -# id: release_checking -# run: | -# echo "RELEASE_TYPE: $RELEASE_TYPE" -# echo "::set-output name=run_result::$(echo $RELEASE_TYPE)" + run: release=$(bash ./scripts/ci/build_get-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true') + + - name: Export the running result as environment variable 'RELEASE_TYPE' + id: release_checking + run: | + echo "release: $release" + release_version=$(echo "$release" | grep -E "\[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") + echo "release_version: $release_version" + echo "::set-output name=run_result::$(echo $release_version)" deploy_as_new_branch: diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index e0ef8152..a88107d8 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -262,13 +262,12 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then echo "Set environment variable in GitHub" export RELEASE_TYPE="$new_ver" echo $RELEASE_TYPE - echo "::set-output name=run_result::$(echo $RELEASE_TYPE)" # echo "Set environment variable in GitHub" # echo "$new_ver" >> $RELEASE_TYPE # echo $RELEASE_TYPE - echo "[Final Running Result] Official-Release" + echo "[Final Running Result] Official-Release and version: $new_ver" # current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) # if [ "$current_ver" == "" ]; then From 6e9007aa7b078018609ba86362194cce086e85e7 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 10:20:47 +0800 Subject: [PATCH 196/241] [Test] (config) Test for setting environment variable feature. --- scripts/ci/build_get-tag_or_create_github-release.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index a88107d8..97ccbe07 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -106,9 +106,9 @@ fi #current_branch=$(git branch --show-current) echo "Verify the git branch info" -git branch --list +git branch --list | cat echo "Verify all the git branch info" -git branch -a +git branch -a | cat echo "Verify the git remote info" git remote -v echo "Get the current git branch info" @@ -244,7 +244,7 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* echo "Verify all the git branch info again after git fetch." - git branch -a + git branch -a | cat echo "Verify the git remote info again after git fetch." git remote -v From f265023c1caa8b5303d9f17f7211956bb465db3f Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 10:40:46 +0800 Subject: [PATCH 197/241] [Test] (config) Test for setting environment variable feature. --- .github/workflows/test-reusable-workflows.yaml | 4 +++- .../build_get-tag_or_create_github-release.sh | 18 ------------------ 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 937109a2..9f331ebb 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -133,7 +133,9 @@ jobs: - uses: actions/checkout@v2 - name: Build git tag and create GitHub release - run: release=$(bash ./scripts/ci/build_get-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true') + run: | + release=$(bash ./scripts/ci/build_get-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true') + echo "release: $release" - name: Export the running result as environment variable 'RELEASE_TYPE' id: release_checking diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 97ccbe07..60126c36 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -190,7 +190,6 @@ if [ "$release_type" == 'python-package' ]; then echo "is_pre_release_version: $is_pre_release_version" if [ "$is_pre_release_version" == "" ]; then echo "The version is not a pre-release." -# build_tag_and_create_release_and_push_pypi=true # do different things with different ranches # git event: push # all branch -> Build tag @@ -198,12 +197,9 @@ if [ "$release_type" == 'python-package' ]; then echo "build tag and create GitHub release, also push code to PyPi" build_git_tag_or_github_release echo "Done! This is Official-Release so please push source code to PyPi." -# RELEASE_TYPE="Official"; export RELEASE_TYPE - echo "Official" >> $RELEASE_TYPE echo "[Final Running Result] Official-Release" else echo "The version is a pre-release." -# build_tag_and_create_release_only=true # do different things with different ranches # git event: push # all branch -> Build tag @@ -211,8 +207,6 @@ if [ "$release_type" == 'python-package' ]; then echo "build tag and create GitHub release only" build_git_tag_or_github_release echo "Done! This is Pre-Release so please don't push this to PyPi." -# RELEASE_TYPE="Pre"; export RELEASE_TYPE - echo "Pre" >> $RELEASE_TYPE echo "[Final Running Result] Pre-Release" fi @@ -257,16 +251,6 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then # 1. Yes, it has different. -> Build git tag, GitHub release and version branch build_git_tag_or_github_release echo "Done! This is Official-Release of GitHub Action reusable workflow, please create a version branch of it." -# RELEASE_TYPE="$new_ver"; export RELEASE_TYPE -# echo "$new_ver" >> $RELEASE_TYPE - echo "Set environment variable in GitHub" - export RELEASE_TYPE="$new_ver" - echo $RELEASE_TYPE - -# echo "Set environment variable in GitHub" -# echo "$new_ver" >> $RELEASE_TYPE -# echo $RELEASE_TYPE - echo "[Final Running Result] Official-Release and version: $new_ver" # current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) @@ -290,8 +274,6 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then # 1. No, do nothing. # Return nothing output echo "Release note file doesn't change. Don't do anything." -# RELEASE_TYPE="Pre"; export RELEASE_TYPE - echo "Pre" >> $RELEASE_TYPE echo "[Final Running Result] Pre-Release" fi From 45b388b39e01ba32163ac9b481b20a715e38ce5a Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 10:45:02 +0800 Subject: [PATCH 198/241] [Test] (config) Test for setting environment variable feature. --- .github/workflows/test-reusable-workflows.yaml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 9f331ebb..0e9619fa 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -136,15 +136,18 @@ jobs: run: | release=$(bash ./scripts/ci/build_get-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true') echo "release: $release" - - - name: Export the running result as environment variable 'RELEASE_TYPE' - id: release_checking - run: | - echo "release: $release" release_version=$(echo "$release" | grep -E "\[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") echo "release_version: $release_version" echo "::set-output name=run_result::$(echo $release_version)" +# - name: Export the running result as environment variable 'RELEASE_TYPE' +# id: release_checking +# run: | +# echo "release: $release" +# release_version=$(echo "$release" | grep -E "\[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") +# echo "release_version: $release_version" +# echo "::set-output name=run_result::$(echo $release_version)" + deploy_as_new_branch: # name: Create new git branch by the tagged commit From a01dd72b8cc495852d06b3e9e68444fd9480c781 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 10:48:35 +0800 Subject: [PATCH 199/241] [Test] (config) Test for setting environment variable feature. --- .github/workflows/test-reusable-workflows.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 0e9619fa..ffa2e178 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -133,6 +133,7 @@ jobs: - uses: actions/checkout@v2 - name: Build git tag and create GitHub release + id: release_checking run: | release=$(bash ./scripts/ci/build_get-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true') echo "release: $release" From 879642289710c258cb0fdda9145037a84def9a36 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 10:59:53 +0800 Subject: [PATCH 200/241] [Test] (config) Test for getting and calculating get tag.. --- .github/workflows/test-reusable-workflows.yaml | 8 -------- scripts/ci/build_get-tag_or_create_github-release.sh | 4 ++++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index ffa2e178..716b3481 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -141,14 +141,6 @@ jobs: echo "release_version: $release_version" echo "::set-output name=run_result::$(echo $release_version)" -# - name: Export the running result as environment variable 'RELEASE_TYPE' -# id: release_checking -# run: | -# echo "release: $release" -# release_version=$(echo "$release" | grep -E "\[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") -# echo "release_version: $release_version" -# echo "::set-output name=run_result::$(echo $release_version)" - deploy_as_new_branch: # name: Create new git branch by the tagged commit diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 60126c36..d2fad312 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -120,6 +120,10 @@ declare new_ver build_git_tag_or_github_release() { # Generate the new version from previous tag + git_ver_desc=$(git describe --tag --abbrev=0) + git_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]") + echo "git_ver_desc: $git_ver_desc" + echo "git_ver: $git_ver" current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) if [ "$current_ver" == "" ]; then current_ver=0 From 0f9a724e1fbf54d05ac5b75e10660005ffb8dde9 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Mon, 29 Aug 2022 11:27:10 +0800 Subject: [PATCH 201/241] [Breaking Change + Test] (config) Modify the implementation of getting version by git or github tag. --- .../build_get-tag_or_create_github-release.sh | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index d2fad312..085d4d17 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -116,6 +116,26 @@ current_branch=$(git branch --list | cat | grep -E '\* ([a-zA-Z0-9]{1,16})' | gr echo "Current git branch: $current_branch" +declare tag_version + +get_latest_version_by_git_tag() { + # # # # The types to get version by tag: 'git' or 'github' + get_version_type=$1 + + if [ "$get_version_type" == "git" ]; then + echo "" + tag_version=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]*" | grep -E -o '[0-9]\.[0-9]\.[0-9]*') + elif [ "$get_version_type" == "github" ]; then + echo "" + github_release=$(curl -s https://api.github.com/repos/Chisanan232/GitHub-Action_Workflow-Template-Python/releases/latest | jq -r '.tag_name') + tag_version=$(echo "$github_release" | grep -E -o '[0-9]\.[0-9]\.[0-9]*') + else + echo "" + exit 1 + fi +} + + declare new_ver build_git_tag_or_github_release() { @@ -124,7 +144,12 @@ build_git_tag_or_github_release() { git_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]") echo "git_ver_desc: $git_ver_desc" echo "git_ver: $git_ver" - current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) + + get_latest_version_by_git_tag 'github' + current_ver=$(echo "$tag_version" | head -n1 | cut -d "." -f1) + echo "current_ver: $current_ver" + +# current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) if [ "$current_ver" == "" ]; then current_ver=0 fi From 4feb2c7d38f9bc5d91f67efa16c78dfe40aec497 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 30 Aug 2022 09:19:15 +0800 Subject: [PATCH 202/241] [Breaking Change] (config) Remove unused setting. --- .../workflows/test-reusable-workflows.yaml | 66 ++++--------------- 1 file changed, 12 insertions(+), 54 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 716b3481..fa680d6d 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -120,6 +120,18 @@ jobs: upload-to-codacy: true +# pre-building_check: +## name: Check about it could work finely by installing the Python package with setup.py file +# needs: [codecov_finish, codacy_finish] +# uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/upload_code_report_to_codacy.yaml +# with: +# python_package_name: smoothcrawler +# test_import_package_code_1: import smoothcrawler as mr +# test_import_package_code_2: from smoothcrawler.crawler import SimpleCrawler +# test_import_package_code_3: from smoothcrawler.components.data import BaseHTTPResponseParser, BaseDataHandler +# test_python_script: ./scripts/test_crawler.py + + build_git-tag_and_create_github-release: # name: Build git tag and GitHub release if it needs if: github.event_name == 'push' @@ -157,57 +169,3 @@ jobs: - name: Create new git branch by the tagged commit run: bash ./scripts/ci/deployment_new_version_workflow.sh 'true' - -# create_version_tag: -# if: github.ref_name == 'release' || github.event == 'push' -# name: Build a tag in GitHub -# needs: [codecov_finish, coveralls_finish, codacy_finish] -# steps: -# - name: Get the latest version of package from '__pgk_info__' module -# run: cat ./test_gh_workflow/__pkg_info__.py | grep -e '__version__ = "[0-9].[0-9].[0-9]*"' | grep -o '[0-9].[0-9].[0-9]*' -# -# - name: Get the latest git tag -# run: git describe --tag --abbrev=0 --match "v[0-9].[0-9].[0-9]*" -# -# - name: Tag a version info on the latest commit -# run: git tag -a 'v2.0.0' -m 'Refactor and integrate the configurations to let configurations be more shorter and clear.' -# -# - name: Release the source code with the tag and release note -# run: gh release create v2.0.0 --title 'v2.0.0 - More shorter and clear <0001f9f9>🍻' --notes-file .github/release-notes.md -# -# -# build_version_branch: -# if: github.ref_name == 'master' || github.event == 'push' -# name: Build a Git branch as version in GitHub -# needs: [codecov_finish, coveralls_finish, codacy_finish] -# steps: -# - name: Check whether it has a git tag on the latest commit or not. -# run: | -# git tag -# -# - name: Do something -# run: | -# echo "Add git remote reference" -# git remote add github-action_workflow-template https://github.com/Chisanan232/GitHub-Action-Template-Python.git -# -# echo "Verify the git remote info ..." -# git remote -v -# -# echo "Create and switch git branch with version" -# git checkout -b v2 -# -# echo "Push the project to GitHub as the branch" -# git push -u github-action_workflow-template v2 - - -# pre-building_check: -## name: Check about it could work finely by installing the Python package with setup.py file -# needs: [codecov_finish, codacy_finish] -# uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/upload_code_report_to_codacy.yaml -# with: -# python_package_name: smoothcrawler -# test_import_package_code_1: import smoothcrawler as mr -# test_import_package_code_2: from smoothcrawler.crawler import SimpleCrawler -# test_import_package_code_3: from smoothcrawler.components.data import BaseHTTPResponseParser, BaseDataHandler -# test_python_script: ./scripts/test_crawler.py - From 6903c58f33b70d881be0773752b2064a77f2b996 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 30 Aug 2022 09:21:10 +0800 Subject: [PATCH 203/241] [Breaking Change + Test] (config) Refactor shell script 1. Rename the variable which is input option to be named as 'Input_Arg_XXXX' format. 2. Remove some unused script. 3. Let some logic to be a function to handle. --- .../build_get-tag_or_create_github-release.sh | 200 +++++++++--------- 1 file changed, 104 insertions(+), 96 deletions(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 085d4d17..c5797b8b 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -28,23 +28,26 @@ fi # # # # python-package or github-action-reusable-workflow -release_type=$1 +Input_Arg_Release_Type=$1 -if [ "$release_type" == 'python-package' ]; then +if [ "$Input_Arg_Release_Type" == 'python-package' ]; then # # # # The name of Python package - python_pkg_name=$2 + Input_Arg_Python_Pkg_Name=$2 # # # # For development and troubleshooting - debug_mode=$4 -elif [ "$release_type" == 'github-action-reusable-workflow' ]; then - python_pkg_name="" - debug_mode=$2 + Input_Arg_Debug_Mode=$4 +elif [ "$Input_Arg_Release_Type" == 'github-action-reusable-workflow' ]; then + Input_Arg_Python_Pkg_Name="" + Input_Arg_Debug_Mode=$2 else echo "Currently, it only has 2 release type: 'python-package' or 'github-action-reusable-workflow'." exit 1 fi +if [ "$Input_Arg_Debug_Mode" == "" ]; then + Input_Arg_Debug_Mode=true +fi -if [ "$release_type" == "" ]; then - echo "The argument 'release_type' (first argument) cannot be empty." +if [ "$Input_Arg_Release_Type" == "" ]; then + echo "The argument 'Input_Arg_Release_Type' (first argument) cannot be empty." exit 1 fi @@ -63,36 +66,36 @@ fi # 0.9, 1.0a1, 1.0a2, 1.0b1, 1.0rc1, 1.0 # # “major.minor” versioning with developmental releases, release candidates and post-releases for minor corrections: (dev) # 0.9, 1.0.dev1, 1.0.dev2, 1.0.dev3, 1.0c1, 1.0, 1.0.post1, 1.1.dev1 -software_version_format=$3 +Input_Arg_Software_Version_Format=$3 -declare version_reg -declare software_version_reg -declare python_version_reg +declare Software_Version_Reg +declare Python_Version_Reg -if [ "$release_type" == 'python-package' ]; then +if [ "$Input_Arg_Release_Type" == 'python-package' ]; then - if [ "$python_pkg_name" == "" ]; then - echo "The argument 'python_pkg_name' (second argument) cannot be empty if option 'release_type' (first argument) is 'python-package'." + if [ "$Input_Arg_Python_Pkg_Name" == "" ]; then + echo "The argument 'Input_Arg_Python_Pkg_Name' (second argument) cannot be empty if option 'Input_Arg_Release_Type' (first argument) is 'python-package'." exit 1 fi - if [ "$software_version_format" == "general-2" ]; then + declare version_reg + if [ "$Input_Arg_Software_Version_Format" == "general-2" ]; then version_reg="[0-9]\.[0-9]" - elif [ "$software_version_format" == "general-3" ]; then + elif [ "$Input_Arg_Software_Version_Format" == "general-3" ]; then version_reg="[0-9]\.[0-9]\.[0-9]" - elif [ "$software_version_format" == "date-based" ]; then + elif [ "$Input_Arg_Software_Version_Format" == "date-based" ]; then version_reg="[0-9]{4}\.([0-9]{1,})+" else # Default value version_reg="[0-9]\.[0-9]\.[0-9]" fi - software_version_reg="$version_reg*([\.,-]*([a-zA-Z]{1,})*([0-9]{0,})*){0,}" - python_version_reg="__version__ = \"$software_version_reg\"" + Software_Version_Reg="$version_reg*([\.,-]*([a-zA-Z]{1,})*([0-9]{0,})*){0,}" + Python_Version_Reg="__version__ = \"$Software_Version_Reg\"" fi -#if [ "$release_type" == 'python-package' ]; then +#if [ "$Input_Arg_Release_Type" == 'python-package' ]; then # if [ "$software_version_evolution" == "sema" ]; then # echo "*-*([a-zA-Z]{1,})*([0-9]{0,})" # elif [ "$software_version_evolution" == "dev" ]; then @@ -104,31 +107,33 @@ fi #fi -#current_branch=$(git branch --show-current) -echo "Verify the git branch info" -git branch --list | cat -echo "Verify all the git branch info" -git branch -a | cat -echo "Verify the git remote info" -git remote -v -echo "Get the current git branch info" -current_branch=$(git branch --list | cat | grep -E '\* ([a-zA-Z0-9]{1,16})' | grep -E -o '([a-zA-Z0-9]{1,16})') -echo "Current git branch: $current_branch" +#Current_Branch=$(git branch --show-current) +# # # # For debug +#echo "Verify the git branch info" +#git branch --list | cat +#echo "Verify all the git branch info" +#git branch -a | cat +#echo "Verify the git remote info" +#git remote -v +#echo "Get the current git branch info" +# This is the global value to provide after-handle to use +Current_Branch=$(git branch --list | cat | grep -E '\* ([a-zA-Z0-9]{1,16})' | grep -E -o '([a-zA-Z0-9]{1,16})') +echo "Current git branch: $Current_Branch" -declare tag_version +declare Tag_Version # This is the return value of function 'get_latest_version_by_git_tag' get_latest_version_by_git_tag() { # # # # The types to get version by tag: 'git' or 'github' get_version_type=$1 if [ "$get_version_type" == "git" ]; then echo "" - tag_version=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]*" | grep -E -o '[0-9]\.[0-9]\.[0-9]*') + Tag_Version=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]*" | grep -E -o '[0-9]\.[0-9]\.[0-9]*') elif [ "$get_version_type" == "github" ]; then echo "" github_release=$(curl -s https://api.github.com/repos/Chisanan232/GitHub-Action_Workflow-Template-Python/releases/latest | jq -r '.tag_name') - tag_version=$(echo "$github_release" | grep -E -o '[0-9]\.[0-9]\.[0-9]*') + Tag_Version=$(echo "$github_release" | grep -E -o '[0-9]\.[0-9]\.[0-9]*') else echo "" exit 1 @@ -136,45 +141,66 @@ get_latest_version_by_git_tag() { } -declare new_ver +describe New_Release_Version, New_Release_Tag +generate_new_version_as_tag() { + project_type=$1 + if [ "$project_type" == "python" ]; then + echo "" + New_Release_Version=$(cat ./"$Input_Arg_Python_Pkg_Name"/__pkg_info__.py | grep -E "$Python_Version_Reg" | grep -E -o "$Software_Version_Reg") + elif [ "$project_type" == "github-action_reusable-workflow" ]; then + echo "" + # Generate the new version from previous tag + get_latest_version_by_git_tag 'github' + current_ver=$(echo "$Tag_Version" | head -n1 | cut -d "." -f1) + echo "current_ver: $current_ver" -build_git_tag_or_github_release() { - # Generate the new version from previous tag - git_ver_desc=$(git describe --tag --abbrev=0) - git_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]") - echo "git_ver_desc: $git_ver_desc" - echo "git_ver: $git_ver" - - get_latest_version_by_git_tag 'github' - current_ver=$(echo "$tag_version" | head -n1 | cut -d "." -f1) - echo "current_ver: $current_ver" - -# current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) - if [ "$current_ver" == "" ]; then - current_ver=0 +# current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) + if [ "$current_ver" == "" ]; then + current_ver=0 + fi + New_Release_Version=$(( current_ver + 1 )) fi - new_ver=$(( current_ver + 1 )) - new_tag='v'$new_ver'.0.0' + + New_Release_Tag='v'$New_Release_Version'.0.0' +} + + +declare New_Ver # This is the return value of function 'build_git_tag_or_github_release' +build_git_tag_or_github_release() { +# # Generate the new version from previous tag +# get_latest_version_by_git_tag 'github' +# current_ver=$(echo "$Tag_Version" | head -n1 | cut -d "." -f1) +# echo "current_ver: $current_ver" +# +## current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) +# if [ "$current_ver" == "" ]; then +# current_ver=0 +# fi +# New_Ver=$(( current_ver + 1 )) +# new_tag='v'$New_Ver'.0.0' + + project_type=$1 + generate_new_version_as_tag project_type # git event: push # all branch -> Build tag # master branch -> Build tag and create release - if [ "$debug_mode" == true ]; then - echo " 🔍👀[DEBUG MODE] Build git tag $new_tag in git branch '$current_branch'." + if [ "$Input_Arg_Debug_Mode" == true ]; then + echo " 🔍👀[DEBUG MODE] Build git tag $New_Release_Tag in git branch '$Current_Branch'." else - git tag -a "$new_tag" -m "$new_tag" + git tag -a "$New_Release_Tag" -m "$New_Release_Tag" git push -u origin --tags fi - echo "Build git tag which named '$new_tag' with current branch '$current_branch' successfully!" - if [ "$current_branch" == "master" ]; then + echo "Build git tag which named '$New_Release_Tag' with current branch '$Current_Branch' successfully!" + if [ "$Current_Branch" == "master" ]; then release_title=$(cat .github/release-title.md) - if [ "$debug_mode" == true ]; then - echo " 🔍👀[DEBUG MODE] Create GitHub release with tag '$new_tag' and title '$release_title' in git branch '$current_branch'." + if [ "$Input_Arg_Debug_Mode" == true ]; then + echo " 🔍👀[DEBUG MODE] Create GitHub release with tag '$New_Release_Tag' and title '$release_title' in git branch '$Current_Branch'." else - gh release create "$new_tag" --title "$release_title" --notes-file .github/release-notes.md + gh release create "$New_Release_Tag" --title "$release_title" --notes-file .github/release-notes.md fi echo "Create GitHub release with title '$release_title' successfully!" @@ -183,7 +209,7 @@ build_git_tag_or_github_release() { # The truly running implementation of shell script -if [ "$release_type" == 'python-package' ]; then +if [ "$Input_Arg_Release_Type" == 'python-package' ]; then # # # # For Python package release echo 'do python package release' @@ -191,7 +217,7 @@ if [ "$release_type" == 'python-package' ]; then git_tag=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]*" | grep -o '[0-9]\.[0-9]\.[0-9]*') github_release=$(curl -s https://api.github.com/repos/Chisanan232/GitHub-Action_Workflow-Template-Python/releases/latest | jq -r '.tag_name') # shellcheck disable=SC2002 - pkg_version=$(cat ./"$python_pkg_name"/__pkg_info__.py | grep -E "$python_version_reg" | grep -E -o "$software_version_reg") + pkg_version=$(cat ./"$Input_Arg_Python_Pkg_Name"/__pkg_info__.py | grep -E "$Python_Version_Reg" | grep -E -o "$Software_Version_Reg") build_git_tag=false create_github_release=false @@ -204,13 +230,22 @@ if [ "$release_type" == 'python-package' ]; then build_git_tag=true fi - if [ "$current_branch" == "master" ] && [ "$pkg_version" == "$github_release" ]; then + if [ "$Current_Branch" == "master" ] && [ "$pkg_version" == "$github_release" ]; then echo "Version of GitHub release info are the same. So it verifies it has built and pushed before." else echo "Version of GitHub release info are different. So it verifies it doesn't build and push before." create_github_release=true fi + # 1. -> Same -> 1-1. Does it have built and pushed before?. + # 1. -> No (In generally, it should no) -> 1-2. Is it a pre-release version in source code? + + # 1-1. Yes, it has built and pushed. -> Doesn't do anything. + # 1-1. No, it doesn't build and push before. -> Build and push directly. + + # 1-2. Yes, it's pre-release. -> Doesn't build and push. Just build git tag and GitHub release. + # 1-2. No, it's not pre-release. -> It means that it's official version, e.g., 1.3.2 version. So it should build git tag and GitHub release first, and build and push. + if [ "$build_git_tag" == true ] || [ "$create_github_release" == true ]; then echo "pkg_version: $pkg_version" @@ -224,7 +259,7 @@ if [ "$release_type" == 'python-package' ]; then # all branch -> Build tag # master branch -> Build tag and create release echo "build tag and create GitHub release, also push code to PyPi" - build_git_tag_or_github_release + build_git_tag_or_github_release "python" echo "Done! This is Official-Release so please push source code to PyPi." echo "[Final Running Result] Official-Release" else @@ -234,23 +269,14 @@ if [ "$release_type" == 'python-package' ]; then # all branch -> Build tag # master branch -> Build tag and create release echo "build tag and create GitHub release only" - build_git_tag_or_github_release + build_git_tag_or_github_release "python" echo "Done! This is Pre-Release so please don't push this to PyPi." echo "[Final Running Result] Pre-Release" fi fi - # 1. -> Same -> 1-1. Does it have built and pushed before?. - # 1. -> No (In generally, it should no) -> 1-2. Is it a pre-release version in source code? - - # 1-1. Yes, it has built and pushed. -> Doesn't do anything. - # 1-1. No, it doesn't build and push before. -> Build and push directly. - - # 1-2. Yes, it's pre-release. -> Doesn't build and push. Just build git tag and GitHub release. - # 1-2. No, it's not pre-release. -> It means that it's official version, e.g., 1.3.2 version. So it should build git tag and GitHub release first, and build and push. - -elif [ "$release_type" == 'github-action-reusable-workflow' ]; then +elif [ "$Input_Arg_Release_Type" == 'github-action-reusable-workflow' ]; then echo 'do github-action-reusable-workflow release' # # # # For GitHub Action reusable workflow template release @@ -273,32 +299,14 @@ elif [ "$release_type" == 'github-action-reusable-workflow' ]; then git remote -v echo "Check the different between current git branch and master branch." - release_notes_has_diff=$(git diff origin/master "$current_branch" -- .github/release-notes.md | cat) + release_notes_has_diff=$(git diff origin/master "$Current_Branch" -- .github/release-notes.md | cat) echo "release_notes_has_diff: $release_notes_has_diff" if [ "$release_notes_has_diff" != "" ]; then # 1. Yes, it has different. -> Build git tag, GitHub release and version branch - build_git_tag_or_github_release + build_git_tag_or_github_release "github-action_reusable-workflow" echo "Done! This is Official-Release of GitHub Action reusable workflow, please create a version branch of it." - echo "[Final Running Result] Official-Release and version: $new_ver" - -# current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) -# if [ "$current_ver" == "" ]; then -# current_ver=0 -# fi -# new_ver=$(( current_ver + 1 )) -# # Return the new version as output -# # git event: push -# # all branch -> Build tag -# # master branch -> Build tag and create release -# new_tag='v'$new_ver'.0.0' -# git tag -a "$new_tag" -m "$new_tag" -# echo "Build git tag which named '$new_tag' with current branch '$current_branch' successfully!" -# if [ "$current_branch" == "master" ]; then -# release_title=$(cat .github/release-title.md) -# gh release create "$new_tag" --title "$release_title" --notes-file .github/release-notes.md -# echo "Create GitHub release with title '$release_title' successfully!" -# fi + echo "[Final Running Result] Official-Release and version: $New_Release_Version" else # 1. No, do nothing. # Return nothing output From 63f6984a7ceafcfbfa351c3aedb5fc9d9336680a Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 30 Aug 2022 09:25:52 +0800 Subject: [PATCH 204/241] [Bug Fix] (script) Fix the issue about declare. --- scripts/ci/build_get-tag_or_create_github-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index c5797b8b..2067a438 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -141,7 +141,7 @@ get_latest_version_by_git_tag() { } -describe New_Release_Version, New_Release_Tag +declare New_Release_Version, New_Release_Tag generate_new_version_as_tag() { project_type=$1 if [ "$project_type" == "python" ]; then From 8f11b2b1ebb17595f1459d9fbecd236727ee2ef3 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 30 Aug 2022 09:29:58 +0800 Subject: [PATCH 205/241] [Bug Fix] (script) Fix the issue about declare. --- scripts/ci/build_get-tag_or_create_github-release.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 2067a438..63f0d3da 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -141,7 +141,8 @@ get_latest_version_by_git_tag() { } -declare New_Release_Version, New_Release_Tag +declare New_Release_Version +declare New_Release_Tag generate_new_version_as_tag() { project_type=$1 if [ "$project_type" == "python" ]; then From 7e1cd0d4f5948de0b2bf440088319f6b7379a370 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 30 Aug 2022 09:41:49 +0800 Subject: [PATCH 206/241] [Bug Fix] (script) Fix the issue about declare. --- scripts/ci/build_get-tag_or_create_github-release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index 63f0d3da..a129c59d 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -166,7 +166,7 @@ generate_new_version_as_tag() { } -declare New_Ver # This is the return value of function 'build_git_tag_or_github_release' +#declare New_Ver # This is the return value of function 'build_git_tag_or_github_release' build_git_tag_or_github_release() { # # Generate the new version from previous tag # get_latest_version_by_git_tag 'github' @@ -181,7 +181,7 @@ build_git_tag_or_github_release() { # new_tag='v'$New_Ver'.0.0' project_type=$1 - generate_new_version_as_tag project_type + generate_new_version_as_tag "$project_type" # git event: push # all branch -> Build tag From 15e7098c43373ad8a606732ad6aa40c8c9b1814e Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 30 Aug 2022 09:46:46 +0800 Subject: [PATCH 207/241] [Breaking Change] (script) Remove unused script. --- .../build_get-tag_or_create_github-release.sh | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index a129c59d..c4b44feb 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -141,8 +141,8 @@ get_latest_version_by_git_tag() { } -declare New_Release_Version -declare New_Release_Tag +declare New_Release_Version # This is the return value of function 'generate_new_version_as_tag' +declare New_Release_Tag # This is the return value of function 'generate_new_version_as_tag' generate_new_version_as_tag() { project_type=$1 if [ "$project_type" == "python" ]; then @@ -166,27 +166,14 @@ generate_new_version_as_tag() { } -#declare New_Ver # This is the return value of function 'build_git_tag_or_github_release' build_git_tag_or_github_release() { -# # Generate the new version from previous tag -# get_latest_version_by_git_tag 'github' -# current_ver=$(echo "$Tag_Version" | head -n1 | cut -d "." -f1) -# echo "current_ver: $current_ver" -# -## current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) -# if [ "$current_ver" == "" ]; then -# current_ver=0 -# fi -# New_Ver=$(( current_ver + 1 )) -# new_tag='v'$New_Ver'.0.0' - - project_type=$1 - generate_new_version_as_tag "$project_type" - # git event: push # all branch -> Build tag # master branch -> Build tag and create release + project_type=$1 + generate_new_version_as_tag "$project_type" + if [ "$Input_Arg_Debug_Mode" == true ]; then echo " 🔍👀[DEBUG MODE] Build git tag $New_Release_Tag in git branch '$Current_Branch'." else From 1e01d17caec32211332f36f8becce53aae398646 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 30 Aug 2022 09:49:35 +0800 Subject: [PATCH 208/241] [Breaking Change] (config) Modify the final output message. --- .github/workflows/test-reusable-workflows.yaml | 2 +- scripts/ci/build_get-tag_or_create_github-release.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index fa680d6d..e494f04b 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -149,7 +149,7 @@ jobs: run: | release=$(bash ./scripts/ci/build_get-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true') echo "release: $release" - release_version=$(echo "$release" | grep -E "\[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") + release_version=$(echo "$release" | grep -E "\[GitHub Action - Reusable workflow\] \[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") echo "release_version: $release_version" echo "::set-output name=run_result::$(echo $release_version)" diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_get-tag_or_create_github-release.sh index c4b44feb..70a6cefb 100644 --- a/scripts/ci/build_get-tag_or_create_github-release.sh +++ b/scripts/ci/build_get-tag_or_create_github-release.sh @@ -249,7 +249,7 @@ if [ "$Input_Arg_Release_Type" == 'python-package' ]; then echo "build tag and create GitHub release, also push code to PyPi" build_git_tag_or_github_release "python" echo "Done! This is Official-Release so please push source code to PyPi." - echo "[Final Running Result] Official-Release" + echo "[Python] [Final Running Result] Official-Release" else echo "The version is a pre-release." # do different things with different ranches @@ -259,7 +259,7 @@ if [ "$Input_Arg_Release_Type" == 'python-package' ]; then echo "build tag and create GitHub release only" build_git_tag_or_github_release "python" echo "Done! This is Pre-Release so please don't push this to PyPi." - echo "[Final Running Result] Pre-Release" + echo "[Python] [Final Running Result] Pre-Release" fi fi @@ -294,12 +294,12 @@ elif [ "$Input_Arg_Release_Type" == 'github-action-reusable-workflow' ]; then # 1. Yes, it has different. -> Build git tag, GitHub release and version branch build_git_tag_or_github_release "github-action_reusable-workflow" echo "Done! This is Official-Release of GitHub Action reusable workflow, please create a version branch of it." - echo "[Final Running Result] Official-Release and version: $New_Release_Version" + echo "[GitHub Action - Reusable workflow] [Final Running Result] Official-Release and version: $New_Release_Version" else # 1. No, do nothing. # Return nothing output echo "Release note file doesn't change. Don't do anything." - echo "[Final Running Result] Pre-Release" + echo "[GitHub Action - Reusable workflow] [Final Running Result] Pre-Release" fi fi From 3f495a54600328152cc5a2fb4ec25c9ea61bf69a Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Tue, 30 Aug 2022 15:19:56 +0800 Subject: [PATCH 209/241] [Refactor] (config) Rename the reusable workflow name to be more clear. --- .github/workflows/test-reusable-workflows.yaml | 4 +--- ...b-release.sh => build_git-tag_or_create_github-release.sh} | 0 2 files changed, 1 insertion(+), 3 deletions(-) rename scripts/ci/{build_get-tag_or_create_github-release.sh => build_git-tag_or_create_github-release.sh} (100%) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index e494f04b..e98599c4 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -137,8 +137,6 @@ jobs: if: github.event_name == 'push' needs: [codecov_finish, coveralls_finish, codacy_finish] runs-on: ubuntu-latest -# env: -# RELEASE_TYPE: Initial outputs: release_type: ${{ steps.release_checking.outputs.run_result }} steps: @@ -147,7 +145,7 @@ jobs: - name: Build git tag and create GitHub release id: release_checking run: | - release=$(bash ./scripts/ci/build_get-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true') + release=$(bash ./scripts/ci/build_git-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true') echo "release: $release" release_version=$(echo "$release" | grep -E "\[GitHub Action - Reusable workflow\] \[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") echo "release_version: $release_version" diff --git a/scripts/ci/build_get-tag_or_create_github-release.sh b/scripts/ci/build_git-tag_or_create_github-release.sh similarity index 100% rename from scripts/ci/build_get-tag_or_create_github-release.sh rename to scripts/ci/build_git-tag_or_create_github-release.sh From 297388a51c36d4248ccecc05f62e0983683de41c Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 09:16:41 +0800 Subject: [PATCH 210/241] [New Feature] (config) Add new workflow about building git tag and creating GitHub release. --- ...ild_git-tag_and_create_github-release.yaml | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/build_git-tag_and_create_github-release.yaml diff --git a/.github/workflows/build_git-tag_and_create_github-release.yaml b/.github/workflows/build_git-tag_and_create_github-release.yaml new file mode 100644 index 00000000..1ad82b86 --- /dev/null +++ b/.github/workflows/build_git-tag_and_create_github-release.yaml @@ -0,0 +1,82 @@ +############################################################################################## +# +# Workflow Description: +# Build a git tag on a specific commit in every git branch. And create GitHub release if current git branch is 'master'. +# +# Workflow input parameters: +# * General arguments: +# * project_type: Different project type would get the software version info in different way. +# * activate_git_event: Which git event should activate the workflow. +# * debug_mode: It would run the tasks as log message, doesn't essentially run feature if this option is true. +# +# Workflow running output: +# Yes, it has running result output. The output is the release version. +# +############################################################################################## + +name: Build git tag and create GitHub release with software version + +on: + workflow_call: + inputs: + project_type: + description: "Different project type would get the software version info in different way." + required: true + type: string # Option: python, github-action_reusable-workflow + activate_git_event: + description: "Which git event should activate the workflow." + type: string + required: false + default: push + debug_mode: + description: "It would run the tasks as log message, doesn't essentially run feature if this option is true." + type: boolean + required: false + default: false + + outputs: + release_version: + description: "The version which would be build as git tag and create GitHub release version title." + value: ${{ jobs.build_git-tag_and_create_github-release.outputs.matrix }} + + +jobs: + build_git-tag_and_create_github-release: +# name: Build git tag and GitHub release if it needs + if: ${{ github.event_name == inputs.activate_git_event }} + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.release_checking.outputs.release_version }} + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Download shell script for checking input parameters + run: curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Workflow-Template-Python/develop/scripts/ci/build_git-tag_or_create_github-release.sh --output ./scripts/ci/build_git-tag_or_create_github-release.sh + + # This flow for the project type is Python project + - name: Build git tag and create GitHub release + if: ${{ inputs.project_type == 'python' }} + id: release_checking + run: | + release=$(bash ./scripts/ci/build_git-tag_or_create_github-release.sh 'python-package' $PYTHON_PACKAGE_NAME $SOFTWARE_VERSION_STYLE ${{ inputs.debug_mode }}) + echo "release: $release" + + release_version=$(echo "$release" | grep -E "\[Python\] \[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") + echo "release_version: $release_version" + + echo "::set-output name=release_version::$(echo $release_version)" + + # This flow for the project type is GitHub Action reusable workflow + - name: Build git tag and create GitHub release + if: ${{ inputs.project_type == 'github-action_reusable-workflow' }} + id: release_checking + run: | + release=$(bash ./scripts/ci/build_git-tag_or_create_github-release.sh 'github-action-reusable-workflow' ${{ inputs.debug_mode }}) + echo "release: $release" + + release_version=$(echo "$release" | grep -E "\[GitHub Action - Reusable workflow\] \[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") + echo "release_version: $release_version" + + echo "::set-output name=release_version::$(echo $release_version)" + From 81bf785bd524a9096d7adc9214a898cdb0cd0372 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 09:17:30 +0800 Subject: [PATCH 211/241] [Breaking Change] (config) Modify to use reusable workflow to build git tag and create GitHub release. --- .../workflows/test-reusable-workflows.yaml | 46 ++++++++++++------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index e98599c4..bc1540f8 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -136,31 +136,43 @@ jobs: # name: Build git tag and GitHub release if it needs if: github.event_name == 'push' needs: [codecov_finish, coveralls_finish, codacy_finish] - runs-on: ubuntu-latest - outputs: - release_type: ${{ steps.release_checking.outputs.run_result }} - steps: - - uses: actions/checkout@v2 + uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml + with: + project_type: github-action_reusable-workflow + activate_git_event: push + debug_mode: true - - name: Build git tag and create GitHub release - id: release_checking - run: | - release=$(bash ./scripts/ci/build_git-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true') - echo "release: $release" - release_version=$(echo "$release" | grep -E "\[GitHub Action - Reusable workflow\] \[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") - echo "release_version: $release_version" - echo "::set-output name=run_result::$(echo $release_version)" +# runs-on: ubuntu-latest +# outputs: +# release_type: ${{ steps.release_checking.outputs.run_result }} +# steps: +# - uses: actions/checkout@v2 +# +# - name: Build git tag and create GitHub release +# id: release_checking +# run: | +# release=$(bash ./scripts/ci/build_git-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true') +# echo "release: $release" +# +# release_version=$(echo "$release" | grep -E "\[GitHub Action - Reusable workflow\] \[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") +# echo "release_version: $release_version" +# +# echo "::set-output name=run_result::$(echo $release_version)" deploy_as_new_branch: # name: Create new git branch by the tagged commit - if: ${{ github.event_name == 'push' && - needs.build_git-tag_and_create_github-release.outputs.release_type != 'Initial' && - needs.build_git-tag_and_create_github-release.outputs.release_type != 'Pre' }} +# if: ${{ github.event_name == 'push' && +# needs.build_git-tag_and_create_github-release.outputs.release_type != 'Initial' && +# needs.build_git-tag_and_create_github-release.outputs.release_type != 'Pre' }} needs: build_git-tag_and_create_github-release + if: ${{ github.event_name == 'push' && + needs.build_git-tag_and_create_github-release.outputs.release_version != 'Initial' && + needs.build_git-tag_and_create_github-release.outputs.release_version != 'Pre' }} runs-on: ubuntu-latest env: - RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.release_type }} +# RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.release_type }} + RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.release_version }} steps: - uses: actions/checkout@v2 From f908eb47d140169274ee813ba724531c08e2027e Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 09:17:48 +0800 Subject: [PATCH 212/241] [Breaking Change] (config) Modify to use reusable workflow to build git tag and create GitHub release. --- .../test-reusable-workflows_one-test.yaml | 46 +++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-reusable-workflows_one-test.yaml b/.github/workflows/test-reusable-workflows_one-test.yaml index 9075c6e5..434f1468 100644 --- a/.github/workflows/test-reusable-workflows_one-test.yaml +++ b/.github/workflows/test-reusable-workflows_one-test.yaml @@ -89,9 +89,32 @@ jobs: upload-to-codacy: true -# pre-building_check: -## name: Check about it could work finely by installing the Python package with setup.py file -# needs: [codecov_finish, codacy_finish] + build_git-tag_and_create_github-release: +# name: Build git tag and GitHub release if it needs + if: github.event_name == 'push' + needs: [codecov_finish, coveralls_finish, codacy_finish] + env: + # The environment variables for integration test. + PYTHON_PACKAGE_NAME: test_gh_workflow + SOFTWARE_VERSION_STYLE: general-3 + uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml + with: + project_type: python-package + activate_git_event: push + debug_mode: true + + + pre-building_check: +# name: Check about it could work finely by installing the Python package with setup.py file + needs: build_git-tag_and_create_github-release + if: github.event_name == 'push' + runs-on: ubuntu-latest + steps: + - name: For testing about getting the software version info + run: | + echo "Release version: ${{ needs.build_git-tag_and_create_github-release.outputs.release_version }}" + +# if: github.event_name == 'push' && (github.ref_name == 'release' || github.ref_name == 'master') # uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/upload_code_report_to_codacy.yaml # with: # python_package_name: smoothcrawler @@ -100,3 +123,20 @@ jobs: # test_import_package_code_3: from smoothcrawler.components.data import BaseHTTPResponseParser, BaseDataHandler # test_python_script: ./scripts/test_crawler.py + +# compile_and_build_python_pkg: +## name: Compile the Python source code and build it as Python package files +# if: github.event_name == 'push' && github.ref_name == 'master' +# needs: pre-building_check +# uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/build_package.yaml + + +# push_python_pkg_to_pypi: +## name: Upload the Python package files which has been compiled to PyPi +# if: github.event_name == 'push' && github.ref_name == 'master' +# needs: compile_and_build_python_pkg +# uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/push_pkg_to_pypi.yaml +# secrets: +# pypi_user: ${{ secrets.PYPI_USERNAME }} +# pypi_token: ${{ secrets.PYPI_PASSWORD }} + From b14613d53919daa30ce4907132019dd3031b205f Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 10:08:56 +0800 Subject: [PATCH 213/241] [Breaking Change] (script) Modify the order of input arguments. --- scripts/ci/build_git-tag_or_create_github-release.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/ci/build_git-tag_or_create_github-release.sh b/scripts/ci/build_git-tag_or_create_github-release.sh index 70a6cefb..48d6fd50 100644 --- a/scripts/ci/build_git-tag_or_create_github-release.sh +++ b/scripts/ci/build_git-tag_or_create_github-release.sh @@ -29,15 +29,18 @@ fi # # # # python-package or github-action-reusable-workflow Input_Arg_Release_Type=$1 +Input_Arg_Debug_Mode=$2 if [ "$Input_Arg_Release_Type" == 'python-package' ]; then # # # # The name of Python package - Input_Arg_Python_Pkg_Name=$2 + Input_Arg_Python_Pkg_Name=$3 # # # # For development and troubleshooting - Input_Arg_Debug_Mode=$4 +# Input_Arg_Debug_Mode=$4 + Input_Arg_Software_Version_Format=$4 elif [ "$Input_Arg_Release_Type" == 'github-action-reusable-workflow' ]; then Input_Arg_Python_Pkg_Name="" - Input_Arg_Debug_Mode=$2 + Input_Arg_Software_Version_Format="" +# Input_Arg_Debug_Mode=$2 else echo "Currently, it only has 2 release type: 'python-package' or 'github-action-reusable-workflow'." exit 1 @@ -66,7 +69,7 @@ fi # 0.9, 1.0a1, 1.0a2, 1.0b1, 1.0rc1, 1.0 # # “major.minor” versioning with developmental releases, release candidates and post-releases for minor corrections: (dev) # 0.9, 1.0.dev1, 1.0.dev2, 1.0.dev3, 1.0c1, 1.0, 1.0.post1, 1.1.dev1 -Input_Arg_Software_Version_Format=$3 +#Input_Arg_Software_Version_Format=$3 declare Software_Version_Reg declare Python_Version_Reg From ea3770eeeb9c301aba9929368de013a25afc328c Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 10:09:36 +0800 Subject: [PATCH 214/241] [Bug Fix] (config) Fix the issue about duplicated ID. --- ...ild_git-tag_and_create_github-release.yaml | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build_git-tag_and_create_github-release.yaml b/.github/workflows/build_git-tag_and_create_github-release.yaml index 1ad82b86..c6e3b7e8 100644 --- a/.github/workflows/build_git-tag_and_create_github-release.yaml +++ b/.github/workflows/build_git-tag_and_create_github-release.yaml @@ -35,9 +35,12 @@ on: default: false outputs: - release_version: + python_release_version: description: "The version which would be build as git tag and create GitHub release version title." - value: ${{ jobs.build_git-tag_and_create_github-release.outputs.matrix }} + value: ${{ jobs.build_git-tag_and_create_github-release.outputs.matrix_python }} + github-action_reusable_workflow_release_version: + description: "The version which would be build as git tag and create GitHub release version title." + value: ${{ jobs.build_git-tag_and_create_github-release.outputs.matrix_github_action_reusable_workflow }} jobs: @@ -46,7 +49,8 @@ jobs: if: ${{ github.event_name == inputs.activate_git_event }} runs-on: ubuntu-latest outputs: - matrix: ${{ steps.release_checking.outputs.release_version }} + matrix_python: ${{ steps.release_checking.outputs.release_version }} + matrix_github_action_reusable_workflow: ${{ steps.release_checking.outputs.release_version }} steps: - name: Checkout uses: actions/checkout@v2 @@ -56,23 +60,23 @@ jobs: # This flow for the project type is Python project - name: Build git tag and create GitHub release - if: ${{ inputs.project_type == 'python' }} - id: release_checking + if: ${{ inputs.project_type == 'python-package' }} + id: python_release run: | - release=$(bash ./scripts/ci/build_git-tag_or_create_github-release.sh 'python-package' $PYTHON_PACKAGE_NAME $SOFTWARE_VERSION_STYLE ${{ inputs.debug_mode }}) + release=$(bash ./scripts/ci/build_git-tag_or_create_github-release.sh ${{ inputs.project_type }} ${{ inputs.debug_mode }} $PYTHON_PACKAGE_NAME $SOFTWARE_VERSION_STYLE) echo "release: $release" - release_version=$(echo "$release" | grep -E "\[Python\] \[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") + release_version=$(echo "$release" | grep -E "\[Python\] \[Final Running Result\] ((Official\-Release)|(Pre\-Release))" | grep -E -o "((Official\-Release)|(Pre\-Release))") echo "release_version: $release_version" echo "::set-output name=release_version::$(echo $release_version)" # This flow for the project type is GitHub Action reusable workflow - name: Build git tag and create GitHub release - if: ${{ inputs.project_type == 'github-action_reusable-workflow' }} - id: release_checking + if: ${{ inputs.project_type == 'github-action-reusable-workflow' }} + id: github_action_reusable_workflow_release run: | - release=$(bash ./scripts/ci/build_git-tag_or_create_github-release.sh 'github-action-reusable-workflow' ${{ inputs.debug_mode }}) + release=$(bash ./scripts/ci/build_git-tag_or_create_github-release.sh ${{ inputs.project_type }} ${{ inputs.debug_mode }}) echo "release: $release" release_version=$(echo "$release" | grep -E "\[GitHub Action - Reusable workflow\] \[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") From 803d28628e5ddf657139cc5c437a4ddab0395e50 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 10:10:04 +0800 Subject: [PATCH 215/241] [Bug Fix] (config) Fix the issue about duplicated ID and modify usage in caller. --- .github/workflows/test-reusable-workflows.yaml | 8 ++++---- .github/workflows/test-reusable-workflows_one-test.yaml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index bc1540f8..01f18a4d 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -138,7 +138,7 @@ jobs: needs: [codecov_finish, coveralls_finish, codacy_finish] uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml with: - project_type: github-action_reusable-workflow + project_type: github-action-reusable-workflow activate_git_event: push debug_mode: true @@ -167,12 +167,12 @@ jobs: # needs.build_git-tag_and_create_github-release.outputs.release_type != 'Pre' }} needs: build_git-tag_and_create_github-release if: ${{ github.event_name == 'push' && - needs.build_git-tag_and_create_github-release.outputs.release_version != 'Initial' && - needs.build_git-tag_and_create_github-release.outputs.release_version != 'Pre' }} + needs.build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version != 'Initial' && + needs.build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version != 'Pre' }} runs-on: ubuntu-latest env: # RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.release_type }} - RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.release_version }} + RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version }} steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/test-reusable-workflows_one-test.yaml b/.github/workflows/test-reusable-workflows_one-test.yaml index 434f1468..1b7b4d6d 100644 --- a/.github/workflows/test-reusable-workflows_one-test.yaml +++ b/.github/workflows/test-reusable-workflows_one-test.yaml @@ -112,7 +112,7 @@ jobs: steps: - name: For testing about getting the software version info run: | - echo "Release version: ${{ needs.build_git-tag_and_create_github-release.outputs.release_version }}" + echo "Release version: ${{ needs.build_git-tag_and_create_github-release.outputs.python_release_version }}" # if: github.event_name == 'push' && (github.ref_name == 'release' || github.ref_name == 'master') # uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/upload_code_report_to_codacy.yaml From 905e3fda7a4e114c4428488e17f7643f1fff9087 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 10:31:36 +0800 Subject: [PATCH 216/241] [Breaking Change + Test] (config) Test for reusable workflow feature. --- .../workflows/build_git-tag_and_create_github-release.yaml | 2 +- .github/workflows/test-reusable-workflows.yaml | 4 ++-- .github/workflows/test-reusable-workflows_one-test.yaml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_git-tag_and_create_github-release.yaml b/.github/workflows/build_git-tag_and_create_github-release.yaml index c6e3b7e8..74b0b5e0 100644 --- a/.github/workflows/build_git-tag_and_create_github-release.yaml +++ b/.github/workflows/build_git-tag_and_create_github-release.yaml @@ -46,7 +46,7 @@ on: jobs: build_git-tag_and_create_github-release: # name: Build git tag and GitHub release if it needs - if: ${{ github.event_name == inputs.activate_git_event }} + if: github.event_name == ${{ inputs.activate_git_event }} runs-on: ubuntu-latest outputs: matrix_python: ${{ steps.release_checking.outputs.release_version }} diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 01f18a4d..1ef6bfcd 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -134,12 +134,12 @@ jobs: build_git-tag_and_create_github-release: # name: Build git tag and GitHub release if it needs - if: github.event_name == 'push' +# if: github.event_name == 'push' needs: [codecov_finish, coveralls_finish, codacy_finish] uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml with: project_type: github-action-reusable-workflow - activate_git_event: push +# activate_git_event: push debug_mode: true # runs-on: ubuntu-latest diff --git a/.github/workflows/test-reusable-workflows_one-test.yaml b/.github/workflows/test-reusable-workflows_one-test.yaml index 1b7b4d6d..4e2595f6 100644 --- a/.github/workflows/test-reusable-workflows_one-test.yaml +++ b/.github/workflows/test-reusable-workflows_one-test.yaml @@ -91,8 +91,8 @@ jobs: build_git-tag_and_create_github-release: # name: Build git tag and GitHub release if it needs - if: github.event_name == 'push' needs: [codecov_finish, coveralls_finish, codacy_finish] +# if: github.event_name == 'push' env: # The environment variables for integration test. PYTHON_PACKAGE_NAME: test_gh_workflow @@ -100,7 +100,7 @@ jobs: uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml with: project_type: python-package - activate_git_event: push +# activate_git_event: push debug_mode: true From e1c70994834ed7ad936c507200ec18848010e520 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 10:40:26 +0800 Subject: [PATCH 217/241] [Breaking Change + Test] (config) Test for reusable workflow feature. --- .../build_git-tag_and_create_github-release.yaml | 12 ++++++------ .../workflows/test-reusable-workflows_one-test.yaml | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_git-tag_and_create_github-release.yaml b/.github/workflows/build_git-tag_and_create_github-release.yaml index 74b0b5e0..b9af26dd 100644 --- a/.github/workflows/build_git-tag_and_create_github-release.yaml +++ b/.github/workflows/build_git-tag_and_create_github-release.yaml @@ -23,11 +23,11 @@ on: description: "Different project type would get the software version info in different way." required: true type: string # Option: python, github-action_reusable-workflow - activate_git_event: - description: "Which git event should activate the workflow." - type: string - required: false - default: push +# activate_git_event: +# description: "Which git event should activate the workflow." +# type: string +# required: false +# default: push debug_mode: description: "It would run the tasks as log message, doesn't essentially run feature if this option is true." type: boolean @@ -46,7 +46,7 @@ on: jobs: build_git-tag_and_create_github-release: # name: Build git tag and GitHub release if it needs - if: github.event_name == ${{ inputs.activate_git_event }} + if: github.event_name == 'push' runs-on: ubuntu-latest outputs: matrix_python: ${{ steps.release_checking.outputs.release_version }} diff --git a/.github/workflows/test-reusable-workflows_one-test.yaml b/.github/workflows/test-reusable-workflows_one-test.yaml index 4e2595f6..379853de 100644 --- a/.github/workflows/test-reusable-workflows_one-test.yaml +++ b/.github/workflows/test-reusable-workflows_one-test.yaml @@ -93,15 +93,15 @@ jobs: # name: Build git tag and GitHub release if it needs needs: [codecov_finish, coveralls_finish, codacy_finish] # if: github.event_name == 'push' + # The environment variables for integration test. env: - # The environment variables for integration test. PYTHON_PACKAGE_NAME: test_gh_workflow SOFTWARE_VERSION_STYLE: general-3 uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml with: project_type: python-package -# activate_git_event: push debug_mode: true +# activate_git_event: push pre-building_check: From f295242f5e335438fa428d0e3bade645aa0d73c9 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 10:41:27 +0800 Subject: [PATCH 218/241] [Breaking Change + Test] (config) Test for reusable workflow feature. --- .github/workflows/test-reusable-workflows_one-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-reusable-workflows_one-test.yaml b/.github/workflows/test-reusable-workflows_one-test.yaml index 379853de..6d35fd8b 100644 --- a/.github/workflows/test-reusable-workflows_one-test.yaml +++ b/.github/workflows/test-reusable-workflows_one-test.yaml @@ -94,10 +94,10 @@ jobs: needs: [codecov_finish, coveralls_finish, codacy_finish] # if: github.event_name == 'push' # The environment variables for integration test. + uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml env: PYTHON_PACKAGE_NAME: test_gh_workflow SOFTWARE_VERSION_STYLE: general-3 - uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml with: project_type: python-package debug_mode: true From 7971e8c3a5c4dfb7fdc7dbadd05bf6c63d665079 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 11:12:02 +0800 Subject: [PATCH 219/241] [Bug Fix + Breaking Change + Test] (config) Fix the set-value issue of output and paramize the shell script arguments. --- ...uild_git-tag_and_create_github-release.yaml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_git-tag_and_create_github-release.yaml b/.github/workflows/build_git-tag_and_create_github-release.yaml index b9af26dd..5076b40d 100644 --- a/.github/workflows/build_git-tag_and_create_github-release.yaml +++ b/.github/workflows/build_git-tag_and_create_github-release.yaml @@ -33,6 +33,14 @@ on: type: boolean required: false default: false + project_name: + description: "The project name." + type: string + required: true + software_version_format: + description: "The format of software version." + type: string + required: true outputs: python_release_version: @@ -49,8 +57,8 @@ jobs: if: github.event_name == 'push' runs-on: ubuntu-latest outputs: - matrix_python: ${{ steps.release_checking.outputs.release_version }} - matrix_github_action_reusable_workflow: ${{ steps.release_checking.outputs.release_version }} + matrix_python: ${{ steps.release_checking.outputs.python_release }} + matrix_github_action_reusable_workflow: ${{ steps.release_checking.outputs.github_action_reusable_workflow_release }} steps: - name: Checkout uses: actions/checkout@v2 @@ -63,13 +71,13 @@ jobs: if: ${{ inputs.project_type == 'python-package' }} id: python_release run: | - release=$(bash ./scripts/ci/build_git-tag_or_create_github-release.sh ${{ inputs.project_type }} ${{ inputs.debug_mode }} $PYTHON_PACKAGE_NAME $SOFTWARE_VERSION_STYLE) + release=$(bash ./scripts/ci/build_git-tag_or_create_github-release.sh ${{ inputs.project_type }} ${{ inputs.debug_mode }} ${{ inputs.project_name }} ${{ inputs.software_version_format }}) echo "release: $release" release_version=$(echo "$release" | grep -E "\[Python\] \[Final Running Result\] ((Official\-Release)|(Pre\-Release))" | grep -E -o "((Official\-Release)|(Pre\-Release))") echo "release_version: $release_version" - echo "::set-output name=release_version::$(echo $release_version)" + echo "::set-output name=python_release::$(echo $release_version)" # This flow for the project type is GitHub Action reusable workflow - name: Build git tag and create GitHub release @@ -82,5 +90,5 @@ jobs: release_version=$(echo "$release" | grep -E "\[GitHub Action - Reusable workflow\] \[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") echo "release_version: $release_version" - echo "::set-output name=release_version::$(echo $release_version)" + echo "::set-output name=github_action_reusable_workflow_release::$(echo $release_version)" From 088a0d5e7614ecee3e4f7d27cd5c24321d01b3a7 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 11:12:18 +0800 Subject: [PATCH 220/241] [Breaking Change + Test] (config) Test for reusable workflow feature. --- .github/workflows/test-reusable-workflows_one-test.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-reusable-workflows_one-test.yaml b/.github/workflows/test-reusable-workflows_one-test.yaml index 6d35fd8b..183260c6 100644 --- a/.github/workflows/test-reusable-workflows_one-test.yaml +++ b/.github/workflows/test-reusable-workflows_one-test.yaml @@ -95,12 +95,11 @@ jobs: # if: github.event_name == 'push' # The environment variables for integration test. uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml - env: - PYTHON_PACKAGE_NAME: test_gh_workflow - SOFTWARE_VERSION_STYLE: general-3 with: project_type: python-package debug_mode: true + project_name: test_gh_workflow + software_version_format: general-3 # activate_git_event: push From e77d7e4483e5f2e6c75a0bb03dfd1c1b47280ffa Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 11:14:45 +0800 Subject: [PATCH 221/241] [Bug Fix + Test] (config) Fix the issue about 'needs'. --- .github/workflows/test-reusable-workflows_one-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-reusable-workflows_one-test.yaml b/.github/workflows/test-reusable-workflows_one-test.yaml index 183260c6..4c457ed8 100644 --- a/.github/workflows/test-reusable-workflows_one-test.yaml +++ b/.github/workflows/test-reusable-workflows_one-test.yaml @@ -91,7 +91,7 @@ jobs: build_git-tag_and_create_github-release: # name: Build git tag and GitHub release if it needs - needs: [codecov_finish, coveralls_finish, codacy_finish] + needs: [coveralls_finish, codacy_finish] # if: github.event_name == 'push' # The environment variables for integration test. uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml From 55d10b1f97408a04a660121ce9e343218d90fd8f Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 11:15:00 +0800 Subject: [PATCH 222/241] [Bug Fix + Test] (config) Fix the issue about input parameters. --- .../workflows/build_git-tag_and_create_github-release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_git-tag_and_create_github-release.yaml b/.github/workflows/build_git-tag_and_create_github-release.yaml index 5076b40d..9ebfd5ed 100644 --- a/.github/workflows/build_git-tag_and_create_github-release.yaml +++ b/.github/workflows/build_git-tag_and_create_github-release.yaml @@ -36,11 +36,11 @@ on: project_name: description: "The project name." type: string - required: true + required: false software_version_format: description: "The format of software version." type: string - required: true + required: false outputs: python_release_version: From 382c97ef82024bb862143a156c2c7057b763325f Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 11:19:47 +0800 Subject: [PATCH 223/241] [Bug Fix + Test] (config) Fix the issue about reusable workflow output. --- .../build_git-tag_and_create_github-release.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_git-tag_and_create_github-release.yaml b/.github/workflows/build_git-tag_and_create_github-release.yaml index 9ebfd5ed..b5734888 100644 --- a/.github/workflows/build_git-tag_and_create_github-release.yaml +++ b/.github/workflows/build_git-tag_and_create_github-release.yaml @@ -57,8 +57,8 @@ jobs: if: github.event_name == 'push' runs-on: ubuntu-latest outputs: - matrix_python: ${{ steps.release_checking.outputs.python_release }} - matrix_github_action_reusable_workflow: ${{ steps.release_checking.outputs.github_action_reusable_workflow_release }} + matrix_python: ${{ steps.python_release.outputs.release_type }} + matrix_github_action_reusable_workflow: ${{ steps.github_action_reusable_workflow_release.outputs.release_version }} steps: - name: Checkout uses: actions/checkout@v2 @@ -77,7 +77,7 @@ jobs: release_version=$(echo "$release" | grep -E "\[Python\] \[Final Running Result\] ((Official\-Release)|(Pre\-Release))" | grep -E -o "((Official\-Release)|(Pre\-Release))") echo "release_version: $release_version" - echo "::set-output name=python_release::$(echo $release_version)" + echo "::set-output name=release_type::$(echo $release_version)" # This flow for the project type is GitHub Action reusable workflow - name: Build git tag and create GitHub release @@ -90,5 +90,5 @@ jobs: release_version=$(echo "$release" | grep -E "\[GitHub Action - Reusable workflow\] \[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") echo "release_version: $release_version" - echo "::set-output name=github_action_reusable_workflow_release::$(echo $release_version)" + echo "::set-output name=release_version::$(echo $release_version)" From 70bfc4a1ef33a58e51d4b479ad013507c100f1a5 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 13:24:35 +0800 Subject: [PATCH 224/241] [Docs] (config) Add description of input parameters and output of reusable workflow. --- .../build_git-tag_and_create_github-release.yaml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_git-tag_and_create_github-release.yaml b/.github/workflows/build_git-tag_and_create_github-release.yaml index b5734888..79cf24e0 100644 --- a/.github/workflows/build_git-tag_and_create_github-release.yaml +++ b/.github/workflows/build_git-tag_and_create_github-release.yaml @@ -6,12 +6,18 @@ # Workflow input parameters: # * General arguments: # * project_type: Different project type would get the software version info in different way. -# * activate_git_event: Which git event should activate the workflow. # * debug_mode: It would run the tasks as log message, doesn't essentially run feature if this option is true. +# * project_name: The project name. +# * software_version_format: The format of software version. # # Workflow running output: # Yes, it has running result output. The output is the release version. # +# * Workflow output: +# It would output the version which would be build as git tag and create GitHub release version title. +# * python_release_version: Python project release version info. +# * github-action_reusable_workflow_release_version: GitHub Action reusable workflow project release version info. +# ############################################################################################## name: Build git tag and create GitHub release with software version @@ -67,7 +73,7 @@ jobs: run: curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Workflow-Template-Python/develop/scripts/ci/build_git-tag_or_create_github-release.sh --output ./scripts/ci/build_git-tag_or_create_github-release.sh # This flow for the project type is Python project - - name: Build git tag and create GitHub release + - name: Build git tag and create GitHub release for Python project if: ${{ inputs.project_type == 'python-package' }} id: python_release run: | @@ -80,7 +86,7 @@ jobs: echo "::set-output name=release_type::$(echo $release_version)" # This flow for the project type is GitHub Action reusable workflow - - name: Build git tag and create GitHub release + - name: Build git tag and create GitHub release for GitHub Action reusable workflow project if: ${{ inputs.project_type == 'github-action-reusable-workflow' }} id: github_action_reusable_workflow_release run: | From e3ac475df717800cca7dd71f5b02611a6ab7f84b Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 13:52:30 +0800 Subject: [PATCH 225/241] [Breaking Change] (config) Rename the workflow and remove some unused settings. --- .../workflows/test-reusable-workflows.yaml | 20 +------------------ .../test-reusable-workflows_one-test.yaml | 4 +--- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test-reusable-workflows.yaml index 1ef6bfcd..178f7725 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test-reusable-workflows.yaml @@ -1,4 +1,4 @@ -name: Github-Action reusable workflows test (multi-tests) +name: Python project CI Test (multi-tests) on: push: branches: @@ -134,7 +134,6 @@ jobs: build_git-tag_and_create_github-release: # name: Build git tag and GitHub release if it needs -# if: github.event_name == 'push' needs: [codecov_finish, coveralls_finish, codacy_finish] uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml with: @@ -142,23 +141,6 @@ jobs: # activate_git_event: push debug_mode: true -# runs-on: ubuntu-latest -# outputs: -# release_type: ${{ steps.release_checking.outputs.run_result }} -# steps: -# - uses: actions/checkout@v2 -# -# - name: Build git tag and create GitHub release -# id: release_checking -# run: | -# release=$(bash ./scripts/ci/build_git-tag_or_create_github-release.sh 'github-action-reusable-workflow' 'true') -# echo "release: $release" -# -# release_version=$(echo "$release" | grep -E "\[GitHub Action - Reusable workflow\] \[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") -# echo "release_version: $release_version" -# -# echo "::set-output name=run_result::$(echo $release_version)" - deploy_as_new_branch: # name: Create new git branch by the tagged commit diff --git a/.github/workflows/test-reusable-workflows_one-test.yaml b/.github/workflows/test-reusable-workflows_one-test.yaml index 4c457ed8..6c2aa10c 100644 --- a/.github/workflows/test-reusable-workflows_one-test.yaml +++ b/.github/workflows/test-reusable-workflows_one-test.yaml @@ -1,4 +1,4 @@ -name: Github-Action reusable workflows test (one-test) +name: Python project CI Test (one-test) on: push: branches: @@ -92,8 +92,6 @@ jobs: build_git-tag_and_create_github-release: # name: Build git tag and GitHub release if it needs needs: [coveralls_finish, codacy_finish] -# if: github.event_name == 'push' - # The environment variables for integration test. uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml with: project_type: python-package From 36375576ee09ba7d3dfe06a4e7bee4370453cdbb Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 13:57:27 +0800 Subject: [PATCH 226/241] [Breaking Change] (config) Rename the reusable workflow CI testing file name. --- ...-workflows.yaml => test_python_project_ci_multi-tests.yaml} | 3 --- ...lows_one-test.yaml => test_python_project_ci_one-test.yaml} | 0 2 files changed, 3 deletions(-) rename .github/workflows/{test-reusable-workflows.yaml => test_python_project_ci_multi-tests.yaml} (95%) rename .github/workflows/{test-reusable-workflows_one-test.yaml => test_python_project_ci_one-test.yaml} (100%) diff --git a/.github/workflows/test-reusable-workflows.yaml b/.github/workflows/test_python_project_ci_multi-tests.yaml similarity index 95% rename from .github/workflows/test-reusable-workflows.yaml rename to .github/workflows/test_python_project_ci_multi-tests.yaml index 178f7725..a680ab08 100644 --- a/.github/workflows/test-reusable-workflows.yaml +++ b/.github/workflows/test_python_project_ci_multi-tests.yaml @@ -144,9 +144,6 @@ jobs: deploy_as_new_branch: # name: Create new git branch by the tagged commit -# if: ${{ github.event_name == 'push' && -# needs.build_git-tag_and_create_github-release.outputs.release_type != 'Initial' && -# needs.build_git-tag_and_create_github-release.outputs.release_type != 'Pre' }} needs: build_git-tag_and_create_github-release if: ${{ github.event_name == 'push' && needs.build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version != 'Initial' && diff --git a/.github/workflows/test-reusable-workflows_one-test.yaml b/.github/workflows/test_python_project_ci_one-test.yaml similarity index 100% rename from .github/workflows/test-reusable-workflows_one-test.yaml rename to .github/workflows/test_python_project_ci_one-test.yaml From 73046a986077619b077ec129e2e86a17ff5e2732 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 14:54:57 +0800 Subject: [PATCH 227/241] [Breaking Change] (config) Add checking process in job 'fake_build_pkg_and_push_to_pypi'. --- .../test_python_project_ci_multi-tests.yaml | 42 ++++++++++------ .../test_python_project_ci_one-test.yaml | 49 +++++++++++++------ 2 files changed, 59 insertions(+), 32 deletions(-) diff --git a/.github/workflows/test_python_project_ci_multi-tests.yaml b/.github/workflows/test_python_project_ci_multi-tests.yaml index a680ab08..3633520d 100644 --- a/.github/workflows/test_python_project_ci_multi-tests.yaml +++ b/.github/workflows/test_python_project_ci_multi-tests.yaml @@ -1,4 +1,5 @@ name: Python project CI Test (multi-tests) + on: push: branches: @@ -12,12 +13,14 @@ on: - ".gitignore" - "LICENSE" - "README.md" + pull_request: branches: - "develop" - "release" - "release-**" - "release/**" + - "master" paths-ignore: - ".gitcommitrules" - ".gitignore" @@ -25,7 +28,6 @@ on: - "README.md" jobs: - prep-testbed_unit-test: # name: Prepare all unit test items uses: ./.github/workflows/prepare_test_items.yaml @@ -123,7 +125,7 @@ jobs: # pre-building_check: ## name: Check about it could work finely by installing the Python package with setup.py file # needs: [codecov_finish, codacy_finish] -# uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/upload_code_report_to_codacy.yaml +# uses: ./.github/workflows/pre-building_test_setup_package.yaml # with: # python_package_name: smoothcrawler # test_import_package_code_1: import smoothcrawler as mr @@ -134,27 +136,35 @@ jobs: build_git-tag_and_create_github-release: # name: Build git tag and GitHub release if it needs - needs: [codecov_finish, coveralls_finish, codacy_finish] + needs: [coveralls_finish, codacy_finish] uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml with: - project_type: github-action-reusable-workflow -# activate_git_event: push + project_type: python-package + project_name: test_gh_workflow + software_version_format: general-3 debug_mode: true - deploy_as_new_branch: -# name: Create new git branch by the tagged commit + fake_build_pkg_and_push_to_pypi: +# name: Check about it could work finely by installing the Python package with setup.py file needs: build_git-tag_and_create_github-release - if: ${{ github.event_name == 'push' && - needs.build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version != 'Initial' && - needs.build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version != 'Pre' }} + if: github.event_name == 'push' runs-on: ubuntu-latest env: -# RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.release_type }} - RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version }} + RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.python_release_version }} steps: - - uses: actions/checkout@v2 - - - name: Create new git branch by the tagged commit - run: bash ./scripts/ci/deployment_new_version_workflow.sh 'true' + - name: Check it whether get the output of previous one job which has version info or not + run: | + release_version=$(echo $RELEASE_TYPE) + if [ "$release_version" != "" ]; then + echo "It gets data which is release version info!" + exit 0 + else + echo "It doesn't get any data which is release version info." + exit 1 + fi + + - name: For testing about getting the software version info + run: | + echo "Release version: $RELEASE_TYPE" diff --git a/.github/workflows/test_python_project_ci_one-test.yaml b/.github/workflows/test_python_project_ci_one-test.yaml index 6c2aa10c..5c5817dc 100644 --- a/.github/workflows/test_python_project_ci_one-test.yaml +++ b/.github/workflows/test_python_project_ci_one-test.yaml @@ -1,4 +1,5 @@ name: Python project CI Test (one-test) + on: push: branches: @@ -18,6 +19,7 @@ on: - "release" - "release-**" - "release/**" + - "master" paths-ignore: - ".gitcommitrules" - ".gitignore" @@ -25,7 +27,6 @@ on: - "README.md" jobs: - prep-testbed_unit-test: # name: Prepare all unit test items uses: ./.github/workflows/prepare_test_items.yaml @@ -89,50 +90,66 @@ jobs: upload-to-codacy: true +# pre-building_check: +## name: Check about it could work finely by installing the Python package with setup.py file +# if: github.event_name == 'push' && (github.ref_name == 'release' || github.ref_name == 'master') +# needs: [codecov_finish, codacy_finish] +# uses: ./.github/workflows/pre-building_test_setup_package.yaml +# with: +# python_package_name: smoothcrawler +# test_import_package_code_1: import smoothcrawler as mr +# test_import_package_code_2: from smoothcrawler.crawler import SimpleCrawler +# test_import_package_code_3: from smoothcrawler.components.data import BaseHTTPResponseParser, BaseDataHandler +# test_python_script: ./scripts/test_crawler.py + + build_git-tag_and_create_github-release: # name: Build git tag and GitHub release if it needs needs: [coveralls_finish, codacy_finish] uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml with: project_type: python-package - debug_mode: true project_name: test_gh_workflow software_version_format: general-3 -# activate_git_event: push + debug_mode: true - pre-building_check: + fake_build_pkg_and_push_to_pypi: # name: Check about it could work finely by installing the Python package with setup.py file needs: build_git-tag_and_create_github-release if: github.event_name == 'push' runs-on: ubuntu-latest + env: + RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.python_release_version }} steps: + - name: Check it whether get the output of previous one job which has version info or not + run: | + release_version=$(echo $RELEASE_TYPE) + if [ "$release_version" != "" ]; then + echo "It gets data which is release version info!" + exit 0 + else + echo "It doesn't get any data which is release version info." + exit 1 + fi + - name: For testing about getting the software version info run: | - echo "Release version: ${{ needs.build_git-tag_and_create_github-release.outputs.python_release_version }}" - -# if: github.event_name == 'push' && (github.ref_name == 'release' || github.ref_name == 'master') -# uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/upload_code_report_to_codacy.yaml -# with: -# python_package_name: smoothcrawler -# test_import_package_code_1: import smoothcrawler as mr -# test_import_package_code_2: from smoothcrawler.crawler import SimpleCrawler -# test_import_package_code_3: from smoothcrawler.components.data import BaseHTTPResponseParser, BaseDataHandler -# test_python_script: ./scripts/test_crawler.py + echo "Release version: $RELEASE_TYPE" # compile_and_build_python_pkg: ## name: Compile the Python source code and build it as Python package files # if: github.event_name == 'push' && github.ref_name == 'master' # needs: pre-building_check -# uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/build_package.yaml +# uses: ./.github/workflows/build_package.yaml # push_python_pkg_to_pypi: ## name: Upload the Python package files which has been compiled to PyPi # if: github.event_name == 'push' && github.ref_name == 'master' # needs: compile_and_build_python_pkg -# uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/push_pkg_to_pypi.yaml +# uses: ./.github/workflows/push_pkg_to_pypi.yaml # secrets: # pypi_user: ${{ secrets.PYPI_USERNAME }} # pypi_token: ${{ secrets.PYPI_PASSWORD }} From 52cecccd9a2af07906620beca3c85a1d7d7a61ba Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 14:55:31 +0800 Subject: [PATCH 228/241] [New Feature] (config) Add new CI testing for GitHub Action reusable workflow projcet. --- .../workflows/test_gh_reusable_workflow.yaml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/test_gh_reusable_workflow.yaml diff --git a/.github/workflows/test_gh_reusable_workflow.yaml b/.github/workflows/test_gh_reusable_workflow.yaml new file mode 100644 index 00000000..1358fe72 --- /dev/null +++ b/.github/workflows/test_gh_reusable_workflow.yaml @@ -0,0 +1,64 @@ +name: GitHub Action reusable workflow project CI Test + +on: + push: + branches: + - "develop" + - "release" + - "release-**" + - "release/**" + - "master" + paths-ignore: + - ".gitcommitrules" + - ".gitignore" + - "LICENSE" + - "README.md" + + pull_request: + branches: + - "develop" + - "release" + - "release-**" + - "release/**" + - "master" + paths-ignore: + - ".gitcommitrules" + - ".gitignore" + - "LICENSE" + - "README.md" + +jobs: + test_build_git-tag_and_create_github-release: +# name: Build git tag and GitHub release if it needs + uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml + with: + project_type: github-action-reusable-workflow + debug_mode: true + + + test_deploy_as_new_branch: +# name: Create new git branch by the tagged commit + needs: build_git-tag_and_create_github-release + if: ${{ github.event_name == 'push' && + needs.build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version != 'Initial' && + needs.build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version != 'Pre' }} + runs-on: ubuntu-latest + env: + RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version }} + steps: + - uses: actions/checkout@v2 + + - name: Check it whether get the output of previous one job which has version info or not + run: | + release_version=$(echo $RELEASE_TYPE) + if [ "$release_version" != "" ]; then + echo "It gets data which is release version info!" + exit 0 + else + echo "It doesn't get any data which is release version info." + exit 1 + fi + + - name: Create new git branch by the tagged commit + run: bash ./scripts/ci/deployment_new_version_workflow.sh 'true' + From 973ecca58da15952c3c1c0d7778393c1ed9695ee Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 14:56:32 +0800 Subject: [PATCH 229/241] [Bug Fix + Test] (config) Fix the issue about 'job..needs'. --- .github/workflows/test_gh_reusable_workflow.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_gh_reusable_workflow.yaml b/.github/workflows/test_gh_reusable_workflow.yaml index 1358fe72..956dc54f 100644 --- a/.github/workflows/test_gh_reusable_workflow.yaml +++ b/.github/workflows/test_gh_reusable_workflow.yaml @@ -38,7 +38,7 @@ jobs: test_deploy_as_new_branch: # name: Create new git branch by the tagged commit - needs: build_git-tag_and_create_github-release + needs: test_build_git-tag_and_create_github-release if: ${{ github.event_name == 'push' && needs.build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version != 'Initial' && needs.build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version != 'Pre' }} From 272c0ed5353f7077a35dfc1c78368c6b582e9ce2 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Wed, 31 Aug 2022 15:02:12 +0800 Subject: [PATCH 230/241] [Bug Fix + Test] (config) Fix the issue about 'job..needs'. --- .github/workflows/test_gh_reusable_workflow.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_gh_reusable_workflow.yaml b/.github/workflows/test_gh_reusable_workflow.yaml index 956dc54f..8dfc818c 100644 --- a/.github/workflows/test_gh_reusable_workflow.yaml +++ b/.github/workflows/test_gh_reusable_workflow.yaml @@ -40,11 +40,11 @@ jobs: # name: Create new git branch by the tagged commit needs: test_build_git-tag_and_create_github-release if: ${{ github.event_name == 'push' && - needs.build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version != 'Initial' && - needs.build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version != 'Pre' }} + needs.test_build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version != 'Initial' && + needs.test_build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version != 'Pre' }} runs-on: ubuntu-latest env: - RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version }} + RELEASE_TYPE: ${{ needs.test_build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version }} steps: - uses: actions/checkout@v2 From 47941da880a5409c5cfa90a441ca3b85a66f73e5 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 1 Sep 2022 08:31:35 +0800 Subject: [PATCH 231/241] [Breaking Change] (config) Modify the log message to display. --- .../build_git-tag_and_create_github-release.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_git-tag_and_create_github-release.yaml b/.github/workflows/build_git-tag_and_create_github-release.yaml index 79cf24e0..8d2c629d 100644 --- a/.github/workflows/build_git-tag_and_create_github-release.yaml +++ b/.github/workflows/build_git-tag_and_create_github-release.yaml @@ -78,12 +78,12 @@ jobs: id: python_release run: | release=$(bash ./scripts/ci/build_git-tag_or_create_github-release.sh ${{ inputs.project_type }} ${{ inputs.debug_mode }} ${{ inputs.project_name }} ${{ inputs.software_version_format }}) - echo "release: $release" + echo "📄 Release log: $release" - release_version=$(echo "$release" | grep -E "\[Python\] \[Final Running Result\] ((Official\-Release)|(Pre\-Release))" | grep -E -o "((Official\-Release)|(Pre\-Release))") - echo "release_version: $release_version" + release_type=$(echo "$release" | grep -E "\[Python\] \[Final Running Result\] ((Official\-Release)|(Pre\-Release))" | grep -E -o "((Official\-Release)|(Pre\-Release))") + echo "🐍 Release Type: $release_type" - echo "::set-output name=release_type::$(echo $release_version)" + echo "::set-output name=release_type::$(echo $release_type)" # This flow for the project type is GitHub Action reusable workflow - name: Build git tag and create GitHub release for GitHub Action reusable workflow project @@ -91,10 +91,10 @@ jobs: id: github_action_reusable_workflow_release run: | release=$(bash ./scripts/ci/build_git-tag_or_create_github-release.sh ${{ inputs.project_type }} ${{ inputs.debug_mode }}) - echo "release: $release" + echo "📄 Release log: $release" release_version=$(echo "$release" | grep -E "\[GitHub Action - Reusable workflow\] \[Final Running Result\] Official-Release and version: ([0-9]{1,})" | grep -E -o "([0-9]{1,})") - echo "release_version: $release_version" + echo "🤖 Release Version: $release_version" echo "::set-output name=release_version::$(echo $release_version)" From 72e64253425562734f7b72d4be6a5c1870e1c504 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 1 Sep 2022 09:07:02 +0800 Subject: [PATCH 232/241] [Breaking Change] (config) Adjust the log message. --- scripts/ci/deployment_new_version_workflow.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/ci/deployment_new_version_workflow.sh b/scripts/ci/deployment_new_version_workflow.sh index 39a33752..5d91f92e 100644 --- a/scripts/ci/deployment_new_version_workflow.sh +++ b/scripts/ci/deployment_new_version_workflow.sh @@ -4,21 +4,21 @@ debug_mode=$1 final_release_type=$RELEASE_TYPE if [ "$final_release_type" == "Pre" ]; then - echo "It detects Pre-Release flag." + echo "💤 It detects Pre-Release flag. So it does NOT do anything in deployment process." else - echo "It detects Official-Release flag." + echo "📬 It detects Official-Release flag." if [ "$debug_mode" == true ]; then echo " 🔍👀[DEBUG MODE] Create new git branch for the new version $final_release_type." else - echo "Add git remote reference." git remote add github-action_workflow-template https://github.com/Chisanan232/GitHub-Action-Template-Python.git - echo "Check all git remote reference." + echo "🔗📄 Add git remote reference." git remote -v - echo "Create a new git branch as version." + echo "🔍 Check all git remote reference." git checkout -b "v$final_release_type" - echo "Push the source code as a branch with one specific version to the GitHub." + echo "⛓ Create a new git branch as version." git push -u github-action_workflow-template "v$final_release_type" + echo "🍻🎉 Push the source code as a branch with one specific version to the GitHub." fi fi -echo "Done!" +echo "🎊🥂 Done!" From 3af7431a247f0243c2ae9744a0e0d773898f5905 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 1 Sep 2022 09:07:17 +0800 Subject: [PATCH 233/241] [New Feature] (script) Add a shell script about checking whether it can get the output or not. --- scripts/ci/check_getting_output.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 scripts/ci/check_getting_output.sh diff --git a/scripts/ci/check_getting_output.sh b/scripts/ci/check_getting_output.sh new file mode 100644 index 00000000..cd5ff6b8 --- /dev/null +++ b/scripts/ci/check_getting_output.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +#set -ex + +release_version=$(echo $RELEASE_TYPE) +if [ "$release_version" != "" ]; then + echo "📬🎉🍻 It gets data which is release version info!" + exit 0 +else + echo "📭🙈 It doesn't get any data which is release version info." + exit 1 +fi From 5cf64811c682b05a0ce0ef54b2a6d581c309b815 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 1 Sep 2022 09:35:48 +0800 Subject: [PATCH 234/241] [Breaking Change] (config) Adjust the log message. --- .../build_git-tag_or_create_github-release.sh | 94 +++++++++---------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/scripts/ci/build_git-tag_or_create_github-release.sh b/scripts/ci/build_git-tag_or_create_github-release.sh index 48d6fd50..783c871d 100644 --- a/scripts/ci/build_git-tag_or_create_github-release.sh +++ b/scripts/ci/build_git-tag_or_create_github-release.sh @@ -5,12 +5,12 @@ # Check whether it has 'release-notes.md' or 'release-title.md' in the target directory '.github'. has_auto_release_flag=$(ls .github | grep -E "release-auto-flag.txt") if [ "$has_auto_release_flag" == "" ]; then - echo "It should have *release-auto-flag.txt* in '.github' directory of your project in HitHub." + echo "⚠️ It should have *release-auto-flag.txt* in '.github' directory of your project in HitHub." exit 0 else auto_release_flag=$(cat .github/release-auto-flag.txt) if [ "$auto_release_flag" == false ]; then - echo "Auto-release flag is 'false' so it won't build git tag or create GitHub release." + echo "💤 Auto-release flag is 'false' so it won't build git tag or create GitHub release." exit 0 fi fi @@ -18,11 +18,11 @@ fi has_release_notes=$(ls .github | grep -E "release-notes.md") has_release_title=$(ls .github | grep -E "release-title.md") if [ "$has_release_notes" == "" ]; then - echo "It should have *release-notes.md* in '.github' directory of your project in HitHub." + echo "❌ It should have *release-notes.md* in '.github' directory of your project in HitHub." exit 1 fi if [ "$has_release_title" == "" ]; then - echo "It should have *release-title.md* in '.github' directory of your project in HitHub." + echo "❌ It should have *release-title.md* in '.github' directory of your project in HitHub." exit 1 fi @@ -31,6 +31,11 @@ fi Input_Arg_Release_Type=$1 Input_Arg_Debug_Mode=$2 +if [ "$Input_Arg_Release_Type" == "" ]; then + echo "❌ The argument 'Input_Arg_Release_Type' (first argument) cannot be empty." + exit 1 +fi + if [ "$Input_Arg_Release_Type" == 'python-package' ]; then # # # # The name of Python package Input_Arg_Python_Pkg_Name=$3 @@ -42,18 +47,13 @@ elif [ "$Input_Arg_Release_Type" == 'github-action-reusable-workflow' ]; then Input_Arg_Software_Version_Format="" # Input_Arg_Debug_Mode=$2 else - echo "Currently, it only has 2 release type: 'python-package' or 'github-action-reusable-workflow'." + echo "❌ Currently, it only has 2 release type: 'python-package' or 'github-action-reusable-workflow'." exit 1 fi if [ "$Input_Arg_Debug_Mode" == "" ]; then Input_Arg_Debug_Mode=true fi -if [ "$Input_Arg_Release_Type" == "" ]; then - echo "The argument 'Input_Arg_Release_Type' (first argument) cannot be empty." - exit 1 -fi - # # # # From the PEP440: Software version style rule # # # @@ -77,7 +77,7 @@ declare Python_Version_Reg if [ "$Input_Arg_Release_Type" == 'python-package' ]; then if [ "$Input_Arg_Python_Pkg_Name" == "" ]; then - echo "The argument 'Input_Arg_Python_Pkg_Name' (second argument) cannot be empty if option 'Input_Arg_Release_Type' (first argument) is 'python-package'." + echo "❌ The argument 'Input_Arg_Python_Pkg_Name' (second argument) cannot be empty if option 'Input_Arg_Release_Type' (first argument) is 'python-package'." exit 1 fi @@ -122,7 +122,7 @@ fi # This is the global value to provide after-handle to use Current_Branch=$(git branch --list | cat | grep -E '\* ([a-zA-Z0-9]{1,16})' | grep -E -o '([a-zA-Z0-9]{1,16})') -echo "Current git branch: $Current_Branch" +echo "🔎 🌳 Current git branch: $Current_Branch" declare Tag_Version # This is the return value of function 'get_latest_version_by_git_tag' @@ -131,14 +131,14 @@ get_latest_version_by_git_tag() { get_version_type=$1 if [ "$get_version_type" == "git" ]; then - echo "" + echo "🔎 🌳 🏷 Get the version info from git tag." Tag_Version=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]*" | grep -E -o '[0-9]\.[0-9]\.[0-9]*') elif [ "$get_version_type" == "github" ]; then - echo "" + echo "🔎 🐙 🐈 🏷 Get the version info from GitHub release." github_release=$(curl -s https://api.github.com/repos/Chisanan232/GitHub-Action_Workflow-Template-Python/releases/latest | jq -r '.tag_name') Tag_Version=$(echo "$github_release" | grep -E -o '[0-9]\.[0-9]\.[0-9]*') else - echo "" + echo "❌ Currently, it only has 2 valid options could use: 'git' or 'github'." exit 1 fi } @@ -149,14 +149,14 @@ declare New_Release_Tag # This is the return value of function 'generate_new_ generate_new_version_as_tag() { project_type=$1 if [ "$project_type" == "python" ]; then - echo "" + echo "🔎 🐍 📦 Get the new version info from Python package." New_Release_Version=$(cat ./"$Input_Arg_Python_Pkg_Name"/__pkg_info__.py | grep -E "$Python_Version_Reg" | grep -E -o "$Software_Version_Reg") elif [ "$project_type" == "github-action_reusable-workflow" ]; then - echo "" + echo "🔎 🐙 🐈 🏷 Get the current version info from GitHub release." # Generate the new version from previous tag get_latest_version_by_git_tag 'github' current_ver=$(echo "$Tag_Version" | head -n1 | cut -d "." -f1) - echo "current_ver: $current_ver" + echo "🔎 📃 Current Version: $current_ver" # current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1) if [ "$current_ver" == "" ]; then @@ -178,24 +178,23 @@ build_git_tag_or_github_release() { generate_new_version_as_tag "$project_type" if [ "$Input_Arg_Debug_Mode" == true ]; then - echo " 🔍👀[DEBUG MODE] Build git tag $New_Release_Tag in git branch '$Current_Branch'." + echo " 🔍👀 [DEBUG MODE] Build git tag $New_Release_Tag in git branch '$Current_Branch'." else git tag -a "$New_Release_Tag" -m "$New_Release_Tag" git push -u origin --tags fi + echo "🎉 🍻 🌳 🏷 Build git tag which named '$New_Release_Tag' with current branch '$Current_Branch' successfully!" - echo "Build git tag which named '$New_Release_Tag' with current branch '$Current_Branch' successfully!" if [ "$Current_Branch" == "master" ]; then release_title=$(cat .github/release-title.md) if [ "$Input_Arg_Debug_Mode" == true ]; then - echo " 🔍👀[DEBUG MODE] Create GitHub release with tag '$New_Release_Tag' and title '$release_title' in git branch '$Current_Branch'." + echo " 🔍👀 [DEBUG MODE] Create GitHub release with tag '$New_Release_Tag' and title '$release_title' in git branch '$Current_Branch'." else gh release create "$New_Release_Tag" --title "$release_title" --notes-file .github/release-notes.md fi - - echo "Create GitHub release with title '$release_title' successfully!" fi + echo "🎉 🍻 🐙 🐈 🏷 Create GitHub release with title '$release_title' successfully!" } @@ -203,28 +202,29 @@ build_git_tag_or_github_release() { if [ "$Input_Arg_Release_Type" == 'python-package' ]; then # # # # For Python package release - echo 'do python package release' + echo "🏃‍♂ ️🐍 𝌚 Run python package releasing process" git_tag=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]*" | grep -o '[0-9]\.[0-9]\.[0-9]*') github_release=$(curl -s https://api.github.com/repos/Chisanan232/GitHub-Action_Workflow-Template-Python/releases/latest | jq -r '.tag_name') # shellcheck disable=SC2002 - pkg_version=$(cat ./"$Input_Arg_Python_Pkg_Name"/__pkg_info__.py | grep -E "$Python_Version_Reg" | grep -E -o "$Software_Version_Reg") + generate_new_version_as_tag "python" +# pkg_version=$(cat ./"$Input_Arg_Python_Pkg_Name"/__pkg_info__.py | grep -E "$Python_Version_Reg" | grep -E -o "$Software_Version_Reg") build_git_tag=false create_github_release=false # 1. Compare the Python source code version and git tag, GitHub release version. - if [ "$pkg_version" == "$git_tag" ]; then - echo "Version of git tag info are the same. So it verifies it has built and pushed before." + if [ "$New_Release_Version" == "$git_tag" ]; then + echo "✅ Version of git tag info are the same. So it verifies it has built and pushed before." else - echo "Version of git tag info are different. So it verifies it doesn't build and push before." + echo "⚠️ Version of git tag info are different. So it verifies it doesn't build and push before." build_git_tag=true fi - if [ "$Current_Branch" == "master" ] && [ "$pkg_version" == "$github_release" ]; then - echo "Version of GitHub release info are the same. So it verifies it has built and pushed before." + if [ "$Current_Branch" == "master" ] && [ "$New_Release_Version" == "$github_release" ]; then + echo "✅ Version of GitHub release info are the same. So it verifies it has built and pushed before." else - echo "Version of GitHub release info are different. So it verifies it doesn't build and push before." + echo "⚠️ Version of GitHub release info are different. So it verifies it doesn't build and push before." create_github_release=true fi @@ -239,19 +239,19 @@ if [ "$Input_Arg_Release_Type" == 'python-package' ]; then if [ "$build_git_tag" == true ] || [ "$create_github_release" == true ]; then - echo "pkg_version: $pkg_version" + echo "🔎 🐍 📦 Python package new release version: $New_Release_Version" # is_pre_release_version=$(echo $pkg_version | sed -n 's/.*\([a-zA-Z][0-9]*\)/\1/p') - is_pre_release_version=$(echo $pkg_version | grep -E -o '([\.-]*([a-zA-Z]{1,})+([0-9]{0,})*){1,}') - echo "is_pre_release_version: $is_pre_release_version" + is_pre_release_version=$(echo $New_Release_Version | grep -E -o '([\.-]*([a-zA-Z]{1,})+([0-9]{0,})*){1,}') + echo "🔎 🤰 📦 is pre-release version: $is_pre_release_version" if [ "$is_pre_release_version" == "" ]; then - echo "The version is not a pre-release." + echo "🎓 🐍 📦 The version is a official-release." # do different things with different ranches # git event: push # all branch -> Build tag # master branch -> Build tag and create release - echo "build tag and create GitHub release, also push code to PyPi" + echo "👷🏽‍♂️ 📌 Build tag and create GitHub release, also push code to PyPi" build_git_tag_or_github_release "python" - echo "Done! This is Official-Release so please push source code to PyPi." + echo "✅ 🎊 🥂 Done! This is Official-Release so please push source code to PyPi." echo "[Python] [Final Running Result] Official-Release" else echo "The version is a pre-release." @@ -259,9 +259,9 @@ if [ "$Input_Arg_Release_Type" == 'python-package' ]; then # git event: push # all branch -> Build tag # master branch -> Build tag and create release - echo "build tag and create GitHub release only" + echo "👷🏽‍♂ ️📌 Build tag and create GitHub release only" build_git_tag_or_github_release "python" - echo "Done! This is Pre-Release so please don't push this to PyPi." + echo "✅ 🎊 🥂 Done! This is Pre-Release so please don't push this to PyPi." echo "[Python] [Final Running Result] Pre-Release" fi @@ -269,7 +269,7 @@ if [ "$Input_Arg_Release_Type" == 'python-package' ]; then elif [ "$Input_Arg_Release_Type" == 'github-action-reusable-workflow' ]; then - echo 'do github-action-reusable-workflow release' + echo "🏃‍♂ 🐙 🐈 𝌚 Run github-action-reusable-workflow releasing process" # # # # For GitHub Action reusable workflow template release # 1. Compare whether the release-notes.md has different or not. # Note 1: Diff a specific file with currently latest tag and previous one commit @@ -280,28 +280,28 @@ elif [ "$Input_Arg_Release_Type" == 'github-action-reusable-workflow' ]; then # Note 4: We should git fetch to provide git diff feature working # https://github.com/actions/checkout/issues/160 - echo "Run git fetch to sync upstream with latest project in GitHub" + echo "🌳 ⛓ 🌳 Run git fetch to sync upstream with latest project in GitHub" git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* - echo "Verify all the git branch info again after git fetch." + echo "🔎 🌳 🌳 Verify all the git branch info again after git fetch." git branch -a | cat - echo "Verify the git remote info again after git fetch." + echo "🔎 🔗 🌳 Verify the git remote info again after git fetch." git remote -v - echo "Check the different between current git branch and master branch." + echo "🔬 📄 🌳 ⛓ 🌳 Check the different of '.github/release-notes.md' between current git branch and master branch ..." release_notes_has_diff=$(git diff origin/master "$Current_Branch" -- .github/release-notes.md | cat) - echo "release_notes_has_diff: $release_notes_has_diff" + echo "🔎 🔬 📄 different of '.github/release-notes.md': $release_notes_has_diff" if [ "$release_notes_has_diff" != "" ]; then # 1. Yes, it has different. -> Build git tag, GitHub release and version branch build_git_tag_or_github_release "github-action_reusable-workflow" - echo "Done! This is Official-Release of GitHub Action reusable workflow, please create a version branch of it." + echo "✅ 🎊 🥂 Done! This is Official-Release of GitHub Action reusable workflow, please create a version branch of it." echo "[GitHub Action - Reusable workflow] [Final Running Result] Official-Release and version: $New_Release_Version" else # 1. No, do nothing. # Return nothing output - echo "Release note file doesn't change. Don't do anything." + echo "💤 Release note file doesn't change. Don't do anything." echo "[GitHub Action - Reusable workflow] [Final Running Result] Pre-Release" fi From 5b662732b5d1f1b0f162d0b3804f35bb2f0d9dcb Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 1 Sep 2022 09:37:52 +0800 Subject: [PATCH 235/241] [Refactor + Breaking Change] (config) Refactor the getting test items shell script path and modify the use shell script checks the getting output. --- .../workflows/test_gh_reusable_workflow.yaml | 10 +-------- .../test_python_project_ci_multi-tests.yaml | 14 +++---------- .../test_python_project_ci_one-test.yaml | 21 ++++++++++--------- .../{ => test}/get-integration-test-paths.sh | 0 scripts/ci/{ => test}/get-unit-test-paths.sh | 0 5 files changed, 15 insertions(+), 30 deletions(-) rename scripts/ci/{ => test}/get-integration-test-paths.sh (100%) rename scripts/ci/{ => test}/get-unit-test-paths.sh (100%) diff --git a/.github/workflows/test_gh_reusable_workflow.yaml b/.github/workflows/test_gh_reusable_workflow.yaml index 8dfc818c..af75f426 100644 --- a/.github/workflows/test_gh_reusable_workflow.yaml +++ b/.github/workflows/test_gh_reusable_workflow.yaml @@ -49,15 +49,7 @@ jobs: - uses: actions/checkout@v2 - name: Check it whether get the output of previous one job which has version info or not - run: | - release_version=$(echo $RELEASE_TYPE) - if [ "$release_version" != "" ]; then - echo "It gets data which is release version info!" - exit 0 - else - echo "It doesn't get any data which is release version info." - exit 1 - fi + run: bash scripts/ci/check_getting_output.sh - name: Create new git branch by the tagged commit run: bash ./scripts/ci/deployment_new_version_workflow.sh 'true' diff --git a/.github/workflows/test_python_project_ci_multi-tests.yaml b/.github/workflows/test_python_project_ci_multi-tests.yaml index 3633520d..82e7b78d 100644 --- a/.github/workflows/test_python_project_ci_multi-tests.yaml +++ b/.github/workflows/test_python_project_ci_multi-tests.yaml @@ -32,7 +32,7 @@ jobs: # name: Prepare all unit test items uses: ./.github/workflows/prepare_test_items.yaml with: - shell_path: scripts/ci/get-unit-test-paths.sh + shell_path: scripts/ci/test/get-unit-test-paths.sh shell_arg: unix @@ -40,7 +40,7 @@ jobs: # name: Prepare all integration test items uses: ./.github/workflows/prepare_test_items.yaml with: - shell_path: scripts/ci/get-integration-test-paths.sh + shell_path: scripts/ci/test/get-integration-test-paths.sh shell_arg: unix @@ -154,15 +154,7 @@ jobs: RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.python_release_version }} steps: - name: Check it whether get the output of previous one job which has version info or not - run: | - release_version=$(echo $RELEASE_TYPE) - if [ "$release_version" != "" ]; then - echo "It gets data which is release version info!" - exit 0 - else - echo "It doesn't get any data which is release version info." - exit 1 - fi + run: bash scripts/ci/check_getting_output.sh - name: For testing about getting the software version info run: | diff --git a/.github/workflows/test_python_project_ci_one-test.yaml b/.github/workflows/test_python_project_ci_one-test.yaml index 5c5817dc..adefe4e8 100644 --- a/.github/workflows/test_python_project_ci_one-test.yaml +++ b/.github/workflows/test_python_project_ci_one-test.yaml @@ -31,7 +31,7 @@ jobs: # name: Prepare all unit test items uses: ./.github/workflows/prepare_test_items.yaml with: - shell_path: scripts/ci/get-unit-test-paths.sh + shell_path: scripts/ci/test/get-unit-test-paths.sh shell_arg: unix @@ -123,15 +123,16 @@ jobs: RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.python_release_version }} steps: - name: Check it whether get the output of previous one job which has version info or not - run: | - release_version=$(echo $RELEASE_TYPE) - if [ "$release_version" != "" ]; then - echo "It gets data which is release version info!" - exit 0 - else - echo "It doesn't get any data which is release version info." - exit 1 - fi + run: bash scripts/ci/check_getting_output.sh +# run: | +# release_version=$(echo $RELEASE_TYPE) +# if [ "$release_version" != "" ]; then +# echo "📬🎉🍻 It gets data which is release version info!" +# exit 0 +# else +# echo "📭🙈 It doesn't get any data which is release version info." +# exit 1 +# fi - name: For testing about getting the software version info run: | diff --git a/scripts/ci/get-integration-test-paths.sh b/scripts/ci/test/get-integration-test-paths.sh similarity index 100% rename from scripts/ci/get-integration-test-paths.sh rename to scripts/ci/test/get-integration-test-paths.sh diff --git a/scripts/ci/get-unit-test-paths.sh b/scripts/ci/test/get-unit-test-paths.sh similarity index 100% rename from scripts/ci/get-unit-test-paths.sh rename to scripts/ci/test/get-unit-test-paths.sh From bf44beec426933634731b66cc529f00feb6b2722 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 1 Sep 2022 09:53:41 +0800 Subject: [PATCH 236/241] [Docs + New Feature] (docs) Update the information of README. --- README.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ea1784e3..8c731491 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ # GitHub Action - Workflow template for Python library -[![Github-Action reusable workflows test (one-test)](https://github.com/Chisanan232/GitHub-Action-Template-Python/actions/workflows/test-reusable-workflows_one-test.yaml/badge.svg)](https://github.com/Chisanan232/GitHub-Action-Template-Python/actions/workflows/test-reusable-workflows_one-test.yaml) -[![Github-Action reusable workflows test (multi-tests)](https://github.com/Chisanan232/GitHub-Action-Template-Python/actions/workflows/test-reusable-workflows.yaml/badge.svg)](https://github.com/Chisanan232/GitHub-Action-Template-Python/actions/workflows/test-reusable-workflows.yaml) [![Release](https://img.shields.io/github/release/Chisanan232/GitHub-Action-Template-Python.svg?label=Release&logo=github)](https://github.com/Chisanan232/GitHub-Action-Template-Python/releases) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?logo=apache)](https://opensource.org/licenses/Apache-2.0) +[![Python project CI Test (one-test)](https://github.com/Chisanan232/GitHub-Action_Workflow-Template-Python/actions/workflows/test_python_project_ci_one-test.yaml/badge.svg)](https://github.com/Chisanan232/GitHub-Action_Workflow-Template-Python/actions/workflows/test_python_project_ci_one-test.yaml) +[![Python project CI Test (multi-tests)](https://github.com/Chisanan232/GitHub-Action_Workflow-Template-Python/actions/workflows/test_python_project_ci_multi-tests.yaml/badge.svg)](https://github.com/Chisanan232/GitHub-Action_Workflow-Template-Python/actions/workflows/test_python_project_ci_multi-tests.yaml) +[![GitHub Action reusable workflow project CI Test](https://github.com/Chisanan232/GitHub-Action_Workflow-Template-Python/actions/workflows/test_gh_reusable_workflow.yaml/badge.svg)](https://github.com/Chisanan232/GitHub-Action_Workflow-Template-Python/actions/workflows/test_gh_reusable_workflow.yaml) This is a GitHub Action workflow template for **_Python library_** project. @@ -29,6 +30,7 @@ The usage of each workflow template. * [_run_test_items_via_pytest.yaml_](#run_test_items_via_pytestyaml) * [_organize_and_generate_test_cov_reports.yaml_](#organize_and_generate_test_cov_reportsyaml) * [_upload_test_cov_report.yaml_](#upload_test_cov_reportyaml) +* [_build_git-tag_and_create_github-release.yaml_](#build_git-tag_and_create_github-releaseyaml) ### _prepare_test_items.yaml_ @@ -248,3 +250,59 @@ Nothing. [![Codacy Badge](https://app.codacy.com/project/badge/Grade/e8bfcd5830ba4232b45aca7c2d3e6310)](https://www.codacy.com/gh/Chisanan232/GitHub-Action-Template-Python/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Chisanan232/GitHub-Action-Template-Python&utm_campaign=Badge_Grade) [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/e8bfcd5830ba4232b45aca7c2d3e6310)](https://www.codacy.com/gh/Chisanan232/GitHub-Action-Template-Python/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Chisanan232/GitHub-Action-Template-Python&utm_campaign=Badge_Coverage) + +
+ +### _build_git-tag_and_create_github-release.yaml_ + +* Description: Build a git tag on a specific commit in every git branch. And create GitHub release if current git branch is 'master'. +* Options: + +| option name | data type | optional or required | function content | +|-------------------------|-----------|-------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| project_type | string | Required | Different project type would get the software version info in different way. Currently, it only has 2 options: _python-package_ or _github-action-reusable-workflow_ | +| debug_mode | boolean | Optional, Default value is _false_ | It would run the tasks as log message, doesn't essentially run feature if this option is true. | +| project_name | string | Optional, Default value is _empty string_ | The project name. | +| software_version_format | string | Optional, Default value is _empty string_ | The format of software version. | + +* Output: + +Yes, it has running result output. It would output the version which could provide after-process to verify what thing it should do, e.g., release or not. + +| Workflow output | description | +|-------------------------------------------------|------------------------------------------------------------------------------------------------------| +| python_release_version | Python project release version info. It only has 2 types value: _Official-Release_ or _Pre-Release_. | +| github-action_reusable_workflow_release_version | Python project release version info. | + +* How to use it? + + * **_Python package_** usage case: + + ```yaml + build_git-tag_and_create_github-release: + # name: Build git tag and GitHub release if it needs for Python package project + needs: [coveralls_finish, codacy_finish] + uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml + with: + project_type: python-package + project_name: test_gh_workflow + software_version_format: general-3 + debug_mode: true + ``` + + * **_GitHub Action reusable workflow_** usage case: + + ```yaml + build_git-tag_and_create_github-release: + # name: Build git tag and GitHub release if it needs for GitHub Action reusable workflow project + needs: [coveralls_finish, codacy_finish] + uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml + with: + project_type: github-action-reusable-workflow + debug_mode: true + ``` + +The badge it generates: + +[![Release](https://img.shields.io/github/release/Chisanan232/GitHub-Action-Template-Python.svg?label=Release&logo=github)](https://github.com/Chisanan232/GitHub-Action-Template-Python/releases) + From 87d9352117e713db7e566cbce2c4a780ceec04c6 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 1 Sep 2022 09:57:59 +0800 Subject: [PATCH 237/241] [Bug Fix] (config) Fix the issue about forget to git clone project. --- .github/workflows/test_python_project_ci_multi-tests.yaml | 3 +++ .github/workflows/test_python_project_ci_one-test.yaml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/test_python_project_ci_multi-tests.yaml b/.github/workflows/test_python_project_ci_multi-tests.yaml index 82e7b78d..ec33747d 100644 --- a/.github/workflows/test_python_project_ci_multi-tests.yaml +++ b/.github/workflows/test_python_project_ci_multi-tests.yaml @@ -153,6 +153,9 @@ jobs: env: RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.python_release_version }} steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Check it whether get the output of previous one job which has version info or not run: bash scripts/ci/check_getting_output.sh diff --git a/.github/workflows/test_python_project_ci_one-test.yaml b/.github/workflows/test_python_project_ci_one-test.yaml index adefe4e8..f02d62a2 100644 --- a/.github/workflows/test_python_project_ci_one-test.yaml +++ b/.github/workflows/test_python_project_ci_one-test.yaml @@ -122,6 +122,9 @@ jobs: env: RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.python_release_version }} steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Check it whether get the output of previous one job which has version info or not run: bash scripts/ci/check_getting_output.sh # run: | From 79a361466a8d200ba2c4254292929813bf9d696e Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 1 Sep 2022 14:29:36 +0800 Subject: [PATCH 238/241] [Docs] (docs) Add a newline. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8c731491..2df6bf5f 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ The usage of each workflow template. * [_upload_test_cov_report.yaml_](#upload_test_cov_reportyaml) * [_build_git-tag_and_create_github-release.yaml_](#build_git-tag_and_create_github-releaseyaml) +
+ ### _prepare_test_items.yaml_ From f4c0cff593e0a52dfd85386a76a0770ae476e49b Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 1 Sep 2022 14:37:25 +0800 Subject: [PATCH 239/241] [New Feature] (config) Add new CI/CD configuration for deployment. --- .github/workflows/ci-cd.yaml | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/ci-cd.yaml diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml new file mode 100644 index 00000000..d5ace6e3 --- /dev/null +++ b/.github/workflows/ci-cd.yaml @@ -0,0 +1,52 @@ +name: GitHub Action reusable workflow build + +on: + push: + branches: + - "develop" + - "release" + - "master" + paths-ignore: + - ".gitcommitrules" + - ".gitignore" + - "LICENSE" + - "README.md" + + pull_request: + branches: + - "develop" + - "release" + paths-ignore: + - ".gitcommitrules" + - ".gitignore" + - "LICENSE" + - "README.md" + +jobs: + test_build_git-tag_and_create_github-release: +# name: Build git tag and GitHub release if it needs + uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml + with: + project_type: github-action-reusable-workflow + debug_mode: false + + + test_deploy_as_new_branch: +# name: Create new git branch by the tagged commit + needs: test_build_git-tag_and_create_github-release + if: ${{ github.ref_name == 'master' && + github.event_name == 'push' && + needs.test_build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version != 'Pre' }} + runs-on: ubuntu-latest + env: + RELEASE_TYPE: ${{ needs.test_build_git-tag_and_create_github-release.outputs.github-action_reusable_workflow_release_version }} + DEBUG_MODE: false + steps: + - uses: actions/checkout@v2 + + - name: Check it whether get the output of previous one job which has version info or not + run: bash scripts/ci/check_getting_output.sh + + - name: Create new git branch by the tagged commit + run: bash ./scripts/ci/deployment_new_version_workflow.sh $DEBUG_MODE + From 8a9bd69c0170deaeebd6c2df55cf191090236fd8 Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 1 Sep 2022 21:42:39 +0800 Subject: [PATCH 240/241] [Breaking Change] (config) Add command lines to configure user info and remove unused setting. --- scripts/ci/build_git-tag_or_create_github-release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ci/build_git-tag_or_create_github-release.sh b/scripts/ci/build_git-tag_or_create_github-release.sh index 783c871d..a85d6bfa 100644 --- a/scripts/ci/build_git-tag_or_create_github-release.sh +++ b/scripts/ci/build_git-tag_or_create_github-release.sh @@ -181,6 +181,8 @@ build_git_tag_or_github_release() { echo " 🔍👀 [DEBUG MODE] Build git tag $New_Release_Tag in git branch '$Current_Branch'." else git tag -a "$New_Release_Tag" -m "$New_Release_Tag" + git config --global user.email "chi10211201@cycu.org.tw" + git config --global user.name "Chisanan232" git push -u origin --tags fi echo "🎉 🍻 🌳 🏷 Build git tag which named '$New_Release_Tag' with current branch '$Current_Branch' successfully!" @@ -208,7 +210,6 @@ if [ "$Input_Arg_Release_Type" == 'python-package' ]; then github_release=$(curl -s https://api.github.com/repos/Chisanan232/GitHub-Action_Workflow-Template-Python/releases/latest | jq -r '.tag_name') # shellcheck disable=SC2002 generate_new_version_as_tag "python" -# pkg_version=$(cat ./"$Input_Arg_Python_Pkg_Name"/__pkg_info__.py | grep -E "$Python_Version_Reg" | grep -E -o "$Software_Version_Reg") build_git_tag=false create_github_release=false @@ -240,7 +241,6 @@ if [ "$Input_Arg_Release_Type" == 'python-package' ]; then if [ "$build_git_tag" == true ] || [ "$create_github_release" == true ]; then echo "🔎 🐍 📦 Python package new release version: $New_Release_Version" -# is_pre_release_version=$(echo $pkg_version | sed -n 's/.*\([a-zA-Z][0-9]*\)/\1/p') is_pre_release_version=$(echo $New_Release_Version | grep -E -o '([\.-]*([a-zA-Z]{1,})+([0-9]{0,})*){1,}') echo "🔎 🤰 📦 is pre-release version: $is_pre_release_version" if [ "$is_pre_release_version" == "" ]; then From 1ac1b52a18607282caea918355dd9310c3fa4e3d Mon Sep 17 00:00:00 2001 From: Chisanan232 Date: Thu, 1 Sep 2022 21:48:49 +0800 Subject: [PATCH 241/241] [Breaking Change] (config) Add command lines to configure user info. --- scripts/ci/build_git-tag_or_create_github-release.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/ci/build_git-tag_or_create_github-release.sh b/scripts/ci/build_git-tag_or_create_github-release.sh index a85d6bfa..5ea2a92e 100644 --- a/scripts/ci/build_git-tag_or_create_github-release.sh +++ b/scripts/ci/build_git-tag_or_create_github-release.sh @@ -124,6 +124,12 @@ fi Current_Branch=$(git branch --list | cat | grep -E '\* ([a-zA-Z0-9]{1,16})' | grep -E -o '([a-zA-Z0-9]{1,16})') echo "🔎 🌳 Current git branch: $Current_Branch" +git config --global user.name "Chisanan232" +git config --global user.email "chi10211201@cycu.org.tw" +git_global_username=$(git config --global user.name) +git_global_user_email=$(git config --global user.email) +echo "🔎 🌳 Current git name: $git_global_username" +echo "🔎 🌳 Current git email: $git_global_user_email" declare Tag_Version # This is the return value of function 'get_latest_version_by_git_tag' get_latest_version_by_git_tag() { @@ -181,8 +187,6 @@ build_git_tag_or_github_release() { echo " 🔍👀 [DEBUG MODE] Build git tag $New_Release_Tag in git branch '$Current_Branch'." else git tag -a "$New_Release_Tag" -m "$New_Release_Tag" - git config --global user.email "chi10211201@cycu.org.tw" - git config --global user.name "Chisanan232" git push -u origin --tags fi echo "🎉 🍻 🌳 🏷 Build git tag which named '$New_Release_Tag' with current branch '$Current_Branch' successfully!"