From 780201fbbfdbcb2d1ea014c1c943c89ed3e724fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Sat, 26 Nov 2022 07:48:22 +0800 Subject: [PATCH 01/60] [Breaking Change] (config) Modify the strategy-matrix settings. --- .../workflows/run_test_items_via_pytest.yaml | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/.github/workflows/run_test_items_via_pytest.yaml b/.github/workflows/run_test_items_via_pytest.yaml index 7ef7b8dd..1dc79daa 100644 --- a/.github/workflows/run_test_items_via_pytest.yaml +++ b/.github/workflows/run_test_items_via_pytest.yaml @@ -76,32 +76,23 @@ jobs: strategy: matrix: python-version: [3.6,3.7,3.8,3.9,'3.10','3.11'] - os: [ubuntu-latest,macos-latest] + os: [ubuntu-20.04,ubuntu-latest,macos-latest] exclude: - - os: ubuntu-18.04 + - os: ubuntu-latest 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 + python-version: 3.7 - 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 + - os: ubuntu-20.04 python-version: 3.9 - - os: macos-12 - python-version: 3.6 + - os: ubuntu-20.04 + python-version: '3.10' + - os: ubuntu-20.04 + python-version: 3.11 test-path: ${{fromJson(inputs.all_test_items_paths)}} + steps: - uses: actions/checkout@v3 From 4bd2c7f1064045abbfa71efd5133d4add9f7f129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Sat, 26 Nov 2022 07:50:22 +0800 Subject: [PATCH 02/60] [Breaking Change] (config) Remove debug mode for testing. --- .github/workflows/test_python_project_ci_one-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_python_project_ci_one-test.yaml b/.github/workflows/test_python_project_ci_one-test.yaml index b1bdd082..398dc2aa 100644 --- a/.github/workflows/test_python_project_ci_one-test.yaml +++ b/.github/workflows/test_python_project_ci_one-test.yaml @@ -42,7 +42,7 @@ jobs: with: test_type: unit-test all_test_items_paths: ${{needs.prep-testbed_unit-test.outputs.all_test_items}} - debug_mode: true +# debug_mode: true unit-test_codecov: From cc28790e9df85e2caf077d87a5c345304830b100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Sat, 26 Nov 2022 09:19:17 +0800 Subject: [PATCH 03/60] [Debug] (config) Print log message about file tree. --- .../workflows/organize_and_generate_test_cov_reports.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index 1466f773..4999a1ef 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -58,7 +58,10 @@ 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: | + pwd + ls -la + 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 }} From 839fc83ec546f2e5727a1c9e01cc605f77deb952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Sat, 26 Nov 2022 09:32:27 +0800 Subject: [PATCH 04/60] [Debug] (config) Print log message about file tree. --- .../organize_and_generate_test_cov_reports.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index 4999a1ef..b3f6914c 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -54,14 +54,14 @@ jobs: - 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: | pwd ls -la - coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.* + 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 }} From 4dd3b8cb402da3ef2f2dbf2c5f32feaef6d621f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Sat, 26 Nov 2022 09:38:28 +0800 Subject: [PATCH 05/60] [Debug] (config) Print log message about file tree. --- .../workflows/organize_and_generate_test_cov_reports.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index b3f6914c..39ffdb05 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -64,7 +64,11 @@ jobs: 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 }} + run: | + pwd + ls -la + ls -la ./test_gh_workflow + 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 From a0ebf9b1fc41e6bfafe45457a830c815861e6bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Sat, 26 Nov 2022 09:45:18 +0800 Subject: [PATCH 06/60] [Test] (config) Modify coverage setting to use relative path. --- .coveragerc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.coveragerc b/.coveragerc index b6ca4893..33055ce4 100644 --- a/.coveragerc +++ b/.coveragerc @@ -5,3 +5,6 @@ source=./test_gh_workflow omit = */__init__.py + +[path] +source=./test_gh_workflow From c6105c578337a4100febf82b20cb52436adb5c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Sat, 26 Nov 2022 14:31:02 +0800 Subject: [PATCH 07/60] [Test] (config) Modify the running commands. --- .../organize_and_generate_test_cov_reports.yaml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index 39ffdb05..52ced74c 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -55,20 +55,15 @@ jobs: - 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: | - pwd - ls -la coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.${{ inputs.test_type }}.* + coverage report -m --data-file=.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: | - pwd - ls -la - ls -la ./test_gh_workflow - coverage report -m --data-file=.coverage.${{ inputs.test_type }} + 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 From d1e19a8379d290b1f403683cb8bd38ed6b0314ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Sat, 26 Nov 2022 14:43:37 +0800 Subject: [PATCH 08/60] [Test] (config) Back to original setting. --- .github/workflows/organize_and_generate_test_cov_reports.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index 52ced74c..1466f773 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -54,9 +54,7 @@ jobs: - 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 }}.* - coverage report -m --data-file=.coverage.${{ inputs.test_type }} + 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' }} From 1f64e8aea9f47d8c4598a645d784074af6d30866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Sun, 27 Nov 2022 09:42:18 +0800 Subject: [PATCH 09/60] [Test] (config) Comment out the running command 'coverage report'. --- .github/workflows/organize_and_generate_test_cov_reports.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index 1466f773..2dfa447a 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -60,8 +60,8 @@ jobs: 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: 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 From 10d5b845f12b6ef643af9df90112f62fd69a6db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 10:20:59 +0800 Subject: [PATCH 10/60] [New Feature] (script) Add new shell script for combining testing coverage reports. --- scripts/ci/combine_coverage_reports.sh | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 scripts/ci/combine_coverage_reports.sh diff --git a/scripts/ci/combine_coverage_reports.sh b/scripts/ci/combine_coverage_reports.sh new file mode 100644 index 00000000..4bdeafee --- /dev/null +++ b/scripts/ci/combine_coverage_reports.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +#set -ex + +test_type=$1 +os=$2 + +IFS=',' read -ra allosarray <<< "$os" + +# shellcheck disable=SC2145 +echo "This is all OS array: ${allosarray[@]}" + +if [ "$test_type" == "unit-test" ] || [ "$test_type" == "integration-test" ]; +then + for oneos in "${allosarray[@]}" ; + do + coverage combine --data-file=.coverage."$test_type"."$oneos" .coverage."$test_type"."$oneos"* + done + echo "✅ It's" && exit 0 +elif [ "$test_type" == "all-test" ]; +then + for oneos in "${allosarray[@]}" ; + do + coverage combine --data-file=.coverage."$test_type"."$oneos" .coverage.*."$oneos"* + done + echo "✅ It's" && exit 0 +else + echo "❌ It's" && exit 1 +fi From ce28f45d502c40ae4b72cecdd0eddae4e31e5fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 10:28:55 +0800 Subject: [PATCH 11/60] [New Feature] (script) Add new processing of converting final testing coverage data file to XML format. --- scripts/ci/combine_coverage_reports.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/ci/combine_coverage_reports.sh b/scripts/ci/combine_coverage_reports.sh index 4bdeafee..285bfb7c 100644 --- a/scripts/ci/combine_coverage_reports.sh +++ b/scripts/ci/combine_coverage_reports.sh @@ -14,14 +14,18 @@ if [ "$test_type" == "unit-test" ] || [ "$test_type" == "integration-test" ]; then for oneos in "${allosarray[@]}" ; do - coverage combine --data-file=.coverage."$test_type"."$oneos" .coverage."$test_type"."$oneos"* + coveragedatafile=".coverage.$test_type.$oneos" + coverage combine --data-file="$coveragedatafile" .coverage."$test_type"."$oneos"* + coverage xml --data-file="$coveragedatafile" -o coverage_"$test_type"_"$oneos".xml done echo "✅ It's" && exit 0 elif [ "$test_type" == "all-test" ]; then for oneos in "${allosarray[@]}" ; do - coverage combine --data-file=.coverage."$test_type"."$oneos" .coverage.*."$oneos"* + coveragedatafile=".coverage.$test_type.$oneos" + coverage combine --data-file="$coveragedatafile" .coverage.*."$oneos"* + coverage xml --data-file="$coveragedatafile" -o coverage_"$test_type"_"$oneos".xml done echo "✅ It's" && exit 0 else From c7545049b57249d0c3a6590a83753e9af59cf955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 10:31:52 +0800 Subject: [PATCH 12/60] [Breaking Change] (script) Add log messages. --- scripts/ci/combine_coverage_reports.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/ci/combine_coverage_reports.sh b/scripts/ci/combine_coverage_reports.sh index 285bfb7c..a0642f2a 100644 --- a/scripts/ci/combine_coverage_reports.sh +++ b/scripts/ci/combine_coverage_reports.sh @@ -6,7 +6,7 @@ test_type=$1 os=$2 IFS=',' read -ra allosarray <<< "$os" - +g # shellcheck disable=SC2145 echo "This is all OS array: ${allosarray[@]}" @@ -18,7 +18,7 @@ then coverage combine --data-file="$coveragedatafile" .coverage."$test_type"."$oneos"* coverage xml --data-file="$coveragedatafile" -o coverage_"$test_type"_"$oneos".xml done - echo "✅ It's" && exit 0 + echo "✅ All processing done." && exit 0 elif [ "$test_type" == "all-test" ]; then for oneos in "${allosarray[@]}" ; @@ -27,7 +27,7 @@ then coverage combine --data-file="$coveragedatafile" .coverage.*."$oneos"* coverage xml --data-file="$coveragedatafile" -o coverage_"$test_type"_"$oneos".xml done - echo "✅ It's" && exit 0 + echo "✅ All processing done." && exit 0 else - echo "❌ It's" && exit 1 + echo "❌ It doesn't support $test_type currently. Please change to use options 'unit-test', 'integration-test' or 'all-test'." && exit 1 fi From 5c195666423a57765dd9dcb30d482e3be43d583c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 10:34:25 +0800 Subject: [PATCH 13/60] [Breaking Change] (config) Add new option 'test_os' of reusable workflow and modify to run processing by shell script. --- ...rganize_and_generate_test_cov_reports.yaml | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index 2dfa447a..da07eb5d 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -4,6 +4,7 @@ # Organize all the testing coverage reports. (it would save reports by 'actions/upload-artifact@v3'). # # Workflow input parameters: +# * test_os: The OS runtime environment in. If it has multiple values, please separate it by comma ','. In generally, it only has 2 options: 'macos' and 'ubuntu'. # * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'. # # Workflow running output: @@ -22,8 +23,13 @@ on: inputs: test_type: description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'." + type: string required: true + test_os: + description: "The OS runtime environment in. If it has multiple values, please separate it by comma ','. In generally, + it only has 2 options: 'macos' and 'ubuntu'." type: string + required: true jobs: @@ -52,19 +58,8 @@ jobs: 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: Combine all testing coverage data files with test type and runtime OS, and convert to XML format file finally + run: bash ./scripts/ci/combine_coverage_reports.sh ${{ inputs.test_type }} ${{ inputs.test_os }} - name: Upload testing coverage report (.coverage) uses: actions/upload-artifact@v3 From 34413e77231e8ad1451d76b86d3a12c823b49a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 10:39:37 +0800 Subject: [PATCH 14/60] [Bug Fix] (script) Remove incorrect shell. --- scripts/ci/combine_coverage_reports.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/combine_coverage_reports.sh b/scripts/ci/combine_coverage_reports.sh index a0642f2a..e17811cc 100644 --- a/scripts/ci/combine_coverage_reports.sh +++ b/scripts/ci/combine_coverage_reports.sh @@ -6,7 +6,7 @@ test_type=$1 os=$2 IFS=',' read -ra allosarray <<< "$os" -g + # shellcheck disable=SC2145 echo "This is all OS array: ${allosarray[@]}" From 0554716ab16f9518dc31976505f015b0a37f3a4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 11:40:54 +0800 Subject: [PATCH 15/60] [New Feature] (script) Combine all test coverage data files and convert to XML format file finally. --- scripts/ci/combine_coverage_reports.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/ci/combine_coverage_reports.sh b/scripts/ci/combine_coverage_reports.sh index e17811cc..019d47e4 100644 --- a/scripts/ci/combine_coverage_reports.sh +++ b/scripts/ci/combine_coverage_reports.sh @@ -4,6 +4,7 @@ test_type=$1 os=$2 +calculate_all_finally=$3 IFS=',' read -ra allosarray <<< "$os" @@ -18,7 +19,6 @@ then coverage combine --data-file="$coveragedatafile" .coverage."$test_type"."$oneos"* coverage xml --data-file="$coveragedatafile" -o coverage_"$test_type"_"$oneos".xml done - echo "✅ All processing done." && exit 0 elif [ "$test_type" == "all-test" ]; then for oneos in "${allosarray[@]}" ; @@ -27,7 +27,14 @@ then coverage combine --data-file="$coveragedatafile" .coverage.*."$oneos"* coverage xml --data-file="$coveragedatafile" -o coverage_"$test_type"_"$oneos".xml done - echo "✅ All processing done." && exit 0 else echo "❌ It doesn't support $test_type currently. Please change to use options 'unit-test', 'integration-test' or 'all-test'." && exit 1 fi + +if [ "$calculate_all_finally" == "false" ]; then + echo "✅ All processing done." && exit 0 +else + coverage combine .coverage.* + coverage xml + echo "✅ All processing done." && exit 0 +fi From 0cb658ebe3512cc25c798161c5ce9ff9da844637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 11:42:04 +0800 Subject: [PATCH 16/60] [Breaking Change] (config) 3 changes: 1. Add argument of shell script. 2. Rename uploading name. 3. Modify the path. --- .../workflows/organize_and_generate_test_cov_reports.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index da07eb5d..a13a8b4d 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -59,18 +59,18 @@ jobs: pip3 install coveralls - name: Combine all testing coverage data files with test type and runtime OS, and convert to XML format file finally - run: bash ./scripts/ci/combine_coverage_reports.sh ${{ inputs.test_type }} ${{ inputs.test_os }} + run: bash ./scripts/ci/combine_coverage_reports.sh ${{ inputs.test_type }} ${{ inputs.test_os }} true - name: Upload testing coverage report (.coverage) uses: actions/upload-artifact@v3 with: - name: test_coverage_report - path: .coverage.${{ inputs.test_type }} + name: test_coverage_data_file + path: .coverage 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 + path: coverage**xml if-no-files-found: error From bb25d3657fb0af4875cab548a06d757578813a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 11:43:06 +0800 Subject: [PATCH 17/60] [Breaking Change] (config) Add new option 'test_os' of reusable workflow caller. --- .github/workflows/test_python_project_ci_one-test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test_python_project_ci_one-test.yaml b/.github/workflows/test_python_project_ci_one-test.yaml index 398dc2aa..c0af6fe1 100644 --- a/.github/workflows/test_python_project_ci_one-test.yaml +++ b/.github/workflows/test_python_project_ci_one-test.yaml @@ -51,6 +51,7 @@ jobs: uses: ./.github/workflows/organize_and_generate_test_cov_reports.yaml with: test_type: unit-test + test_os: ubuntu,macos # codecov_finish: From 8e00f232e8f59c62a1308ec0e8dc0949fec00bb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 11:44:00 +0800 Subject: [PATCH 18/60] [Breaking Change] (config) 2 changes: 1. Rename download name. 2. Comment out deprecated prcoess. --- .github/workflows/upload_test_cov_report.yaml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index ed6f8b8b..890c884e 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -37,6 +37,11 @@ on: description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'." required: true type: string + test_os: + description: "The OS runtime environment in. If it has multiple values, please separate it by comma ','. In generally, it + only has 2 options: 'macos' and 'ubuntu'." + 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 @@ -100,7 +105,7 @@ jobs: - name: Download code coverage result files which has be handled by different test type process uses: actions/download-artifact@v3 with: - name: test_coverage_report + name: test_coverage_data_file path: ${{ inputs.download_path }} # TODO: It's possible be better that open input parameter 'file_path' or 'download name' outside. @@ -153,11 +158,11 @@ jobs: if: ${{ inputs.upload-to-coveralls == true }} run: | pip3 install coveralls - pip3 install coverage +# pip3 install coverage - - name: Combine all testing code coverage result files with all test types - if: ${{ inputs.upload-to-coveralls == true }} - run: coverage combine .coverage.* +# - name: Combine all testing code coverage result files with all test types +# if: ${{ inputs.upload-to-coveralls == true }} +# run: coverage combine .coverage.* - name: Upload coverage report to Coveralls https://coveralls.io if: ${{ inputs.upload-to-coveralls == true }} From 657bb389b2a512ce5481566a1339fc52dcce6de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 12:21:41 +0800 Subject: [PATCH 19/60] [Breaking Change] (config) Adjust settings of test coverage report. --- .../workflows/test_python_project_ci_one-test.yaml | 2 ++ .github/workflows/upload_test_cov_report.yaml | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test_python_project_ci_one-test.yaml b/.github/workflows/test_python_project_ci_one-test.yaml index c0af6fe1..bf41bef6 100644 --- a/.github/workflows/test_python_project_ci_one-test.yaml +++ b/.github/workflows/test_python_project_ci_one-test.yaml @@ -77,6 +77,7 @@ jobs: coveralls_token: ${{ secrets.COVERALLS_TOKEN }} with: test_type: unit-test + test_os: ubuntu upload-to-coveralls: true @@ -88,6 +89,7 @@ jobs: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} with: test_type: unit-test + test_os: ubuntu upload-to-codacy: true diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 890c884e..a3390a4a 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -136,10 +136,11 @@ jobs: run: | codecov \ -t ${{ secrets.codecov_token }} \ - --file coverage_${{ inputs.test_type }}.xml \ + --file coverage_${{ inputs.test_type }}_${{ inputs.test_os }}.xml \ --flags ${{ inputs.codecov_flags }} \ --env OS,PYTHON \ --name ${{ inputs.codecov_name }} \ + --required --verbose - name: Upload coverage report to Codecov https://codecov.io (For all test types) @@ -147,11 +148,11 @@ jobs: run: | codecov \ -t ${{ secrets.codecov_token }} \ - --file coverage_unit-test.xml \ - --file coverage_integration-test.xml \ + --file coverage.xml \ --flags ${{ inputs.codecov_flags }} \ --env OS,PYTHON \ --name ${{ inputs.codecov_name }} \ + --required --verbose - name: Install Python dependencies about tool of Coveralls @@ -175,7 +176,7 @@ jobs: uses: codacy/codacy-coverage-reporter-action@v1 with: project-token: ${{ secrets.codacy_token }} - coverage-reports: coverage_${{ inputs.test_type }}.xml + coverage-reports: coverage_${{ inputs.test_type }}_${{ inputs.test_os }}.xml # coverage-reports: cobertura.xml - name: Upload testing report to Codacy https://app.codacy.com/ (For all test types) @@ -183,5 +184,5 @@ 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.xml # coverage-reports: cobertura.xml From 932160922ea90e9f128948fc58de8232ab73b7c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 13:08:39 +0800 Subject: [PATCH 20/60] [Test] (config) Test the uploading feature of Codecov. --- .../test_python_project_ci_one-test.yaml | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test_python_project_ci_one-test.yaml b/.github/workflows/test_python_project_ci_one-test.yaml index bf41bef6..6d91ed0d 100644 --- a/.github/workflows/test_python_project_ci_one-test.yaml +++ b/.github/workflows/test_python_project_ci_one-test.yaml @@ -54,18 +54,19 @@ jobs: test_os: ubuntu,macos -# 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 + test_os: ubuntu + 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 f7584258a9717ef9b81278dd51b6ffde6ae27c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 13:15:09 +0800 Subject: [PATCH 21/60] [Bug Fix] (config) Fix command line issue. --- .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 a3390a4a..ee83b912 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -140,7 +140,7 @@ jobs: --flags ${{ inputs.codecov_flags }} \ --env OS,PYTHON \ --name ${{ inputs.codecov_name }} \ - --required + --required \ --verbose - name: Upload coverage report to Codecov https://codecov.io (For all test types) @@ -152,7 +152,7 @@ jobs: --flags ${{ inputs.codecov_flags }} \ --env OS,PYTHON \ --name ${{ inputs.codecov_name }} \ - --required + --required \ --verbose - name: Install Python dependencies about tool of Coveralls From 6303b5244ef3fcae03e9e3e66f1b228f50afe255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 13:24:07 +0800 Subject: [PATCH 22/60] [Test] (config) Test the uploading feature of Codecov. --- .../test_python_project_ci_one-test.yaml | 2 +- .github/workflows/upload_test_cov_report.yaml | 60 +++++++++++++------ 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test_python_project_ci_one-test.yaml b/.github/workflows/test_python_project_ci_one-test.yaml index 6d91ed0d..da5f01b3 100644 --- a/.github/workflows/test_python_project_ci_one-test.yaml +++ b/.github/workflows/test_python_project_ci_one-test.yaml @@ -109,7 +109,7 @@ jobs: build_git-tag_and_create_github-release: # name: Build git tag and GitHub release if it needs - needs: [coveralls_finish, codacy_finish] + needs: [coveralls_finish, codecov_finish, codacy_finish] uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml with: project_type: python-package diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index ee83b912..a44faa8a 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -131,29 +131,53 @@ jobs: if: ${{ inputs.upload-to-codecov == true }} run: pip3 install codecov +# - 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 }}_${{ inputs.test_os }}.xml \ +# --flags ${{ inputs.codecov_flags }} \ +# --env OS,PYTHON \ +# --name ${{ inputs.codecov_name }} \ +# --required \ +# --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.xml \ +# --flags ${{ inputs.codecov_flags }} \ +# --env OS,PYTHON \ +# --name ${{ inputs.codecov_name }} \ +# --required \ +# --verbose + - 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 }}_${{ inputs.test_os }}.xml \ - --flags ${{ inputs.codecov_flags }} \ - --env OS,PYTHON \ - --name ${{ inputs.codecov_name }} \ - --required \ - --verbose + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.codecov_token }} # not required for public repos + files: coverage_${{ inputs.test_type }}_${{ inputs.test_os }}.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 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.xml \ - --flags ${{ inputs.codecov_flags }} \ - --env OS,PYTHON \ - --name ${{ inputs.codecov_name }} \ - --required \ - --verbose + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.codecov_token }} # not required for public repos + files: coverage.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: Install Python dependencies about tool of Coveralls if: ${{ inputs.upload-to-coveralls == true }} From 9395847b28e8866463f472c8c99df66e16979a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 13:42:14 +0800 Subject: [PATCH 23/60] [Test] (config) Remove some options to test the uploading feature of Codecov. --- .github/workflows/upload_test_cov_report.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index a44faa8a..8167aa8d 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -161,11 +161,11 @@ jobs: with: token: ${{ secrets.codecov_token }} # not required for public repos files: coverage_${{ inputs.test_type }}_${{ inputs.test_os }}.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) +# flags: ${{ inputs.codecov_flags }} # optional +# env_vars: OS,PYTHON +# name: ${{ inputs.codecov_name }} # optional - name: Upload coverage report to Codecov https://codecov.io (For all test types) if: ${{ inputs.upload-to-codecov == true && inputs.test_type == 'all-test' }} From ac11cc0af8cbbee35d57183872fd3c72ff4deea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 13:50:32 +0800 Subject: [PATCH 24/60] [Test] (code) Add testing code for testing of codecov. --- test_gh_workflow/sample.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test_gh_workflow/sample.py b/test_gh_workflow/sample.py index 682c3790..12e53c3d 100644 --- a/test_gh_workflow/sample.py +++ b/test_gh_workflow/sample.py @@ -1,3 +1,4 @@ def hello_python() -> str: + print("This is testing log message.") return "Hello Python" From 8e6e1728bd2d0657b18524aaabc323ccde5160a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 20:02:59 +0800 Subject: [PATCH 25/60] [Breaking Change] (config) Modify the dependency 'coverage' version between 6.2-6.4.4. --- requirements/requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/requirements-test.txt b/requirements/requirements-test.txt index 4cb4d2aa..16dfa031 100644 --- a/requirements/requirements-test.txt +++ b/requirements/requirements-test.txt @@ -6,7 +6,7 @@ pytest-html >= 3.1.1 pytest-rerunfailures >= 10.2 ## For calculating code coverage ## -coverage >= 6.2 # In Python 3.6, its latest version supported is 6.2. But it supports 6.4 version in Python 3.10. +coverage >= 6.2, <= 6.4.4 # 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 From 75a0fc0f2d7488c0c306c362d2d2cb9dd0f08050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 20:08:06 +0800 Subject: [PATCH 26/60] [Breaking Change] (config) Modify the pip installation version of dependencies and remove unused command lines. --- .github/workflows/organize_and_generate_test_cov_reports.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index a13a8b4d..a0edc839 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -54,9 +54,7 @@ jobs: run: | python3 -m pip install --upgrade pip pip3 install -U pip - pip3 install coverage - pip3 install codecov - pip3 install coveralls + pip3 install 'coverage >= 6.2, <= 6.4.4' - name: Combine all testing coverage data files with test type and runtime OS, and convert to XML format file finally run: bash ./scripts/ci/combine_coverage_reports.sh ${{ inputs.test_type }} ${{ inputs.test_os }} true From 8b11ace432c628743510c35bd4db1e1ee1a7266b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 21:40:09 +0800 Subject: [PATCH 27/60] [Test] (code) Add testing code for testing of codecov. --- .github/workflows/upload_test_cov_report.yaml | 85 +++++++++---------- 1 file changed, 39 insertions(+), 46 deletions(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 8167aa8d..a95a0585 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -101,14 +101,12 @@ jobs: echo "Check the parameters of uploading report to Codacy ..." bash ./scripts/ci/check-input-params.sh ${{ inputs.upload-to-codacy }} ${{ secrets.codacy_token }} - # TODO: It's possible be better that open input parameter 'file_path' or 'download name' outside. - name: Download code coverage result files which has be handled by different test type process uses: actions/download-artifact@v3 with: name: test_coverage_data_file path: ${{ inputs.download_path }} - # TODO: It's possible be better that open input parameter 'file_path' or 'download name' outside. - name: Download code coverage result files which has be handled by different test type process uses: actions/download-artifact@v3 with: @@ -131,63 +129,58 @@ jobs: if: ${{ inputs.upload-to-codecov == true }} run: pip3 install codecov + - 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 }}_${{ inputs.test_os }}.xml \ + --flags ${{ inputs.codecov_flags }} \ + --env OS,PYTHON \ + --name ${{ inputs.codecov_name }} \ + --required \ + --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.xml \ + --flags ${{ inputs.codecov_flags }} \ + --env OS,PYTHON \ + --name ${{ inputs.codecov_name }} \ + --required \ + --verbose + # - 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 }}_${{ inputs.test_os }}.xml \ -# --flags ${{ inputs.codecov_flags }} \ -# --env OS,PYTHON \ -# --name ${{ inputs.codecov_name }} \ -# --required \ -# --verbose +# uses: codecov/codecov-action@v3 +# with: +# token: ${{ secrets.codecov_token }} # not required for public repos +# files: coverage_${{ inputs.test_type }}_${{ inputs.test_os }}.xml # optional +# fail_ci_if_error: true # optional (default = false) +# verbose: true # optional (default = false) +## flags: ${{ inputs.codecov_flags }} # optional +## env_vars: OS,PYTHON +## name: ${{ inputs.codecov_name }} # optional # # - 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.xml \ -# --flags ${{ inputs.codecov_flags }} \ -# --env OS,PYTHON \ -# --name ${{ inputs.codecov_name }} \ -# --required \ -# --verbose - - - 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') }} - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.codecov_token }} # not required for public repos - files: coverage_${{ inputs.test_type }}_${{ inputs.test_os }}.xml # 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.xml # optional # flags: ${{ inputs.codecov_flags }} # optional # env_vars: OS,PYTHON # name: ${{ inputs.codecov_name }} # optional - - - name: Upload coverage report to Codecov https://codecov.io (For all test types) - if: ${{ inputs.upload-to-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 - 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) +# 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 -# pip3 install coverage - -# - name: Combine all testing code coverage result files with all test types -# if: ${{ inputs.upload-to-coveralls == true }} -# run: coverage combine .coverage.* - name: Upload coverage report to Coveralls https://coveralls.io if: ${{ inputs.upload-to-coveralls == true }} From 0ef428e2b33aa9426444e1f52e2a965eba2f80cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 21:54:13 +0800 Subject: [PATCH 28/60] [Test] (code) Remove unused config. --- .github/workflows/upload_test_cov_report.yaml | 27 +------------------ 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index a95a0585..46018b1f 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -153,34 +153,9 @@ jobs: --required \ --verbose -# - 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') }} -# uses: codecov/codecov-action@v3 -# with: -# token: ${{ secrets.codecov_token }} # not required for public repos -# files: coverage_${{ inputs.test_type }}_${{ inputs.test_os }}.xml # optional -# fail_ci_if_error: true # optional (default = false) -# verbose: true # optional (default = false) -## flags: ${{ inputs.codecov_flags }} # optional -## env_vars: OS,PYTHON -## name: ${{ inputs.codecov_name }} # optional -# -# - name: Upload coverage report to Codecov https://codecov.io (For all test types) -# if: ${{ inputs.upload-to-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 -# 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: Install Python dependencies about tool of Coveralls if: ${{ inputs.upload-to-coveralls == true }} - run: | - pip3 install coveralls + run: pip3 install coveralls - name: Upload coverage report to Coveralls https://coveralls.io if: ${{ inputs.upload-to-coveralls == true }} From 8ba298907c46764ef217fdd5d159dc085389b9c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 22:12:17 +0800 Subject: [PATCH 29/60] [Test] (code) Remove the new setting of dependency 'coverage' setting. --- .github/workflows/organize_and_generate_test_cov_reports.yaml | 2 +- requirements/requirements-test.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index a0edc839..62bd9bf1 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -54,7 +54,7 @@ jobs: run: | python3 -m pip install --upgrade pip pip3 install -U pip - pip3 install 'coverage >= 6.2, <= 6.4.4' + pip3 install coverage - name: Combine all testing coverage data files with test type and runtime OS, and convert to XML format file finally run: bash ./scripts/ci/combine_coverage_reports.sh ${{ inputs.test_type }} ${{ inputs.test_os }} true diff --git a/requirements/requirements-test.txt b/requirements/requirements-test.txt index 16dfa031..4cb4d2aa 100644 --- a/requirements/requirements-test.txt +++ b/requirements/requirements-test.txt @@ -6,7 +6,7 @@ pytest-html >= 3.1.1 pytest-rerunfailures >= 10.2 ## For calculating code coverage ## -coverage >= 6.2, <= 6.4.4 # In Python 3.6, its latest version supported is 6.2. But it supports 6.4 version in Python 3.10. +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 From bc3b3f10e9fa92e9751a7b83e1943d547ee6e6b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Mon, 28 Nov 2022 22:12:31 +0800 Subject: [PATCH 30/60] [Test] (code) Remove log message. --- test_gh_workflow/sample.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test_gh_workflow/sample.py b/test_gh_workflow/sample.py index 12e53c3d..682c3790 100644 --- a/test_gh_workflow/sample.py +++ b/test_gh_workflow/sample.py @@ -1,4 +1,3 @@ def hello_python() -> str: - print("This is testing log message.") return "Hello Python" From 37686675a73e392211bd7f9b1599d8917df6ccd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Tue, 29 Nov 2022 07:15:06 +0800 Subject: [PATCH 31/60] [Test] (script) Remove argument 'os' about runtime OS. --- scripts/ci/combine_coverage_reports.sh | 49 ++++++++++++++------------ 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/scripts/ci/combine_coverage_reports.sh b/scripts/ci/combine_coverage_reports.sh index 019d47e4..0406de4a 100644 --- a/scripts/ci/combine_coverage_reports.sh +++ b/scripts/ci/combine_coverage_reports.sh @@ -3,38 +3,41 @@ #set -ex test_type=$1 -os=$2 -calculate_all_finally=$3 +#os=$2 +#calculate_all_finally=$2 -IFS=',' read -ra allosarray <<< "$os" +#IFS=',' read -ra allosarray <<< "$os" # shellcheck disable=SC2145 -echo "This is all OS array: ${allosarray[@]}" +#echo "This is all OS array: ${allosarray[@]}" + +coveragedatafile=".coverage.$test_type" if [ "$test_type" == "unit-test" ] || [ "$test_type" == "integration-test" ]; then - for oneos in "${allosarray[@]}" ; - do - coveragedatafile=".coverage.$test_type.$oneos" - coverage combine --data-file="$coveragedatafile" .coverage."$test_type"."$oneos"* - coverage xml --data-file="$coveragedatafile" -o coverage_"$test_type"_"$oneos".xml - done +# for oneos in "${allosarray[@]}" ; +# do + coverage combine --data-file="$coveragedatafile" .coverage."$test_type".* +# done elif [ "$test_type" == "all-test" ]; then - for oneos in "${allosarray[@]}" ; - do - coveragedatafile=".coverage.$test_type.$oneos" - coverage combine --data-file="$coveragedatafile" .coverage.*."$oneos"* - coverage xml --data-file="$coveragedatafile" -o coverage_"$test_type"_"$oneos".xml - done +# for oneos in "${allosarray[@]}" ; +# do + coverage combine --data-file="$coveragedatafile" .coverage.* +# done else echo "❌ It doesn't support $test_type currently. Please change to use options 'unit-test', 'integration-test' or 'all-test'." && exit 1 fi -if [ "$calculate_all_finally" == "false" ]; then - echo "✅ All processing done." && exit 0 -else - coverage combine .coverage.* - coverage xml - echo "✅ All processing done." && exit 0 -fi +coverage report -m --data-file="$coveragedatafile" +coverage xml --data-file="$coveragedatafile" -o coverage_"$test_type".xml +cp coveragedatafile .coverage +echo "✅ All processing done." && exit 0 + +#if [ "$calculate_all_finally" == "false" ]; then +# echo "✅ All processing done." && exit 0 +#else +# coverage combine .coverage.* +# coverage xml +# echo "✅ All processing done." && exit 0 +#fi From 865976cace19bf2ceeb8782cef573059bfb80af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Tue, 29 Nov 2022 07:15:25 +0800 Subject: [PATCH 32/60] [Test] (config) Remove argument 'test_os' about runtime OS. --- .../workflows/organize_and_generate_test_cov_reports.yaml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index 62bd9bf1..d2923ea7 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -4,7 +4,6 @@ # Organize all the testing coverage reports. (it would save reports by 'actions/upload-artifact@v3'). # # Workflow input parameters: -# * test_os: The OS runtime environment in. If it has multiple values, please separate it by comma ','. In generally, it only has 2 options: 'macos' and 'ubuntu'. # * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'. # # Workflow running output: @@ -25,11 +24,6 @@ on: description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'." type: string required: true - test_os: - description: "The OS runtime environment in. If it has multiple values, please separate it by comma ','. In generally, - it only has 2 options: 'macos' and 'ubuntu'." - type: string - required: true jobs: @@ -57,7 +51,7 @@ jobs: pip3 install coverage - name: Combine all testing coverage data files with test type and runtime OS, and convert to XML format file finally - run: bash ./scripts/ci/combine_coverage_reports.sh ${{ inputs.test_type }} ${{ inputs.test_os }} true + run: bash ./scripts/ci/combine_coverage_reports.sh ${{ inputs.test_type }} - name: Upload testing coverage report (.coverage) uses: actions/upload-artifact@v3 From cd0b476f7ac98192d90cbcc743d3b452a5d03b1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Tue, 29 Nov 2022 07:20:13 +0800 Subject: [PATCH 33/60] [Breaking Change + Test] (config) Clean the config. --- .github/workflows/upload_test_cov_report.yaml | 37 +++---------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 46018b1f..92ee62b5 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -37,11 +37,6 @@ on: description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'." required: true type: string - test_os: - description: "The OS runtime environment in. If it has multiple values, please separate it by comma ','. In generally, it - only has 2 options: 'macos' and 'ubuntu'." - 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 @@ -129,24 +124,12 @@ jobs: if: ${{ inputs.upload-to-codecov == true }} run: pip3 install codecov - - 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 }}_${{ inputs.test_os }}.xml \ - --flags ${{ inputs.codecov_flags }} \ - --env OS,PYTHON \ - --name ${{ inputs.codecov_name }} \ - --required \ - --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' }} + - name: Upload coverage report to Codecov https://codecov.io + if: ${{ inputs.upload-to-codecov == true }} run: | codecov \ -t ${{ secrets.codecov_token }} \ - --file coverage.xml \ + --file coverage_${{ inputs.test_type }}.xml \ --flags ${{ inputs.codecov_flags }} \ --env OS,PYTHON \ --name ${{ inputs.codecov_name }} \ @@ -163,18 +146,10 @@ jobs: GITHUB_TOKEN: ${{ secrets.coveralls_token }} run: coveralls --verbose - - 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: ${{ secrets.codacy_token }} - coverage-reports: coverage_${{ inputs.test_type }}_${{ inputs.test_os }}.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' }} + - 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: coverage_${{ inputs.test_type }}.xml # coverage-reports: cobertura.xml From 4ae3c4250b104e9a88edf7b8a0bd88811f19df11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Tue, 29 Nov 2022 07:20:48 +0800 Subject: [PATCH 34/60] [Test] (config) Remove argument 'test_os' about runtime OS of all reusable workflows. --- .github/workflows/test_python_project_ci_one-test.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test_python_project_ci_one-test.yaml b/.github/workflows/test_python_project_ci_one-test.yaml index da5f01b3..5c074569 100644 --- a/.github/workflows/test_python_project_ci_one-test.yaml +++ b/.github/workflows/test_python_project_ci_one-test.yaml @@ -51,7 +51,6 @@ jobs: uses: ./.github/workflows/organize_and_generate_test_cov_reports.yaml with: test_type: unit-test - test_os: ubuntu,macos codecov_finish: @@ -63,7 +62,6 @@ jobs: codecov_token: ${{ secrets.CODECOV_TOKEN }} with: test_type: unit-test - test_os: ubuntu 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 @@ -78,7 +76,6 @@ jobs: coveralls_token: ${{ secrets.COVERALLS_TOKEN }} with: test_type: unit-test - test_os: ubuntu upload-to-coveralls: true @@ -90,7 +87,6 @@ jobs: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} with: test_type: unit-test - test_os: ubuntu upload-to-codacy: true From 51d1f13892f17b41cd376b19271da9255d0d6099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Tue, 29 Nov 2022 07:25:19 +0800 Subject: [PATCH 35/60] [Bug Fix] (script) Fix to use variable in command running. --- scripts/ci/combine_coverage_reports.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/combine_coverage_reports.sh b/scripts/ci/combine_coverage_reports.sh index 0406de4a..371d3032 100644 --- a/scripts/ci/combine_coverage_reports.sh +++ b/scripts/ci/combine_coverage_reports.sh @@ -31,7 +31,7 @@ fi coverage report -m --data-file="$coveragedatafile" coverage xml --data-file="$coveragedatafile" -o coverage_"$test_type".xml -cp coveragedatafile .coverage +cp "$coveragedatafile" .coverage echo "✅ All processing done." && exit 0 #if [ "$calculate_all_finally" == "false" ]; then From 732b03f1e0e83de96f7887020a2dec851ae057cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Tue, 29 Nov 2022 07:39:15 +0800 Subject: [PATCH 36/60] [Breaking Change + Test] (config) Add new option 'relative_files' to be True. --- .coveragerc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.coveragerc b/.coveragerc index 33055ce4..2e9ca09a 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,9 +2,7 @@ branch = True parallel = True source=./test_gh_workflow +relative_files = True omit = */__init__.py - -[path] -source=./test_gh_workflow From 1be07a181d2a14d0cc46cc7e675b42e896420580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Tue, 29 Nov 2022 09:01:05 +0800 Subject: [PATCH 37/60] [Breaking Change + Test] (config) Modify the workflow with latest design of reusable workflows. --- .../test_python_project_ci_multi-tests.yaml | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test_python_project_ci_multi-tests.yaml b/.github/workflows/test_python_project_ci_multi-tests.yaml index 78d158ee..a072934a 100644 --- a/.github/workflows/test_python_project_ci_multi-tests.yaml +++ b/.github/workflows/test_python_project_ci_multi-tests.yaml @@ -69,26 +69,18 @@ jobs: debug_mode: true - unit-test_codecov: + all-test_codecov: # name: Organize and generate the testing report and upload it to Codecov - needs: run_unit-test + needs: [run_unit-test, run_integration-test] uses: ./.github/workflows/organize_and_generate_test_cov_reports.yaml with: - test_type: unit-test - - - 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 + test_type: all-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, integration-test_codecov] + needs: [all-test_codecov] uses: ./.github/workflows/upload_test_cov_report.yaml secrets: codecov_token: ${{ secrets.CODECOV_TOKEN }} @@ -102,7 +94,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: [all-test_codecov] uses: ./.github/workflows/upload_test_cov_report.yaml secrets: coveralls_token: ${{ secrets.COVERALLS_TOKEN }} @@ -113,7 +105,7 @@ jobs: 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_test_cov_report.yaml secrets: codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} @@ -136,7 +128,7 @@ jobs: build_git-tag_and_create_github-release: # name: Build git tag and GitHub release if it needs - needs: [coveralls_finish, codacy_finish] + needs: [codecov_finish, coveralls_finish, codacy_finish] uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml with: project_type: python-package From db5c96d76800340f5aab3a36210440e53b64696e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Tue, 29 Nov 2022 09:21:35 +0800 Subject: [PATCH 38/60] [Breaking Change] (script) Remove all unused shell. --- scripts/ci/combine_coverage_reports.sh | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/scripts/ci/combine_coverage_reports.sh b/scripts/ci/combine_coverage_reports.sh index 371d3032..9a7895bf 100644 --- a/scripts/ci/combine_coverage_reports.sh +++ b/scripts/ci/combine_coverage_reports.sh @@ -1,30 +1,17 @@ #!/usr/bin/env bash -#set -ex +set -ex test_type=$1 -#os=$2 -#calculate_all_finally=$2 - -#IFS=',' read -ra allosarray <<< "$os" - -# shellcheck disable=SC2145 -#echo "This is all OS array: ${allosarray[@]}" coveragedatafile=".coverage.$test_type" if [ "$test_type" == "unit-test" ] || [ "$test_type" == "integration-test" ]; then -# for oneos in "${allosarray[@]}" ; -# do coverage combine --data-file="$coveragedatafile" .coverage."$test_type".* -# done elif [ "$test_type" == "all-test" ]; then -# for oneos in "${allosarray[@]}" ; -# do coverage combine --data-file="$coveragedatafile" .coverage.* -# done else echo "❌ It doesn't support $test_type currently. Please change to use options 'unit-test', 'integration-test' or 'all-test'." && exit 1 fi @@ -33,11 +20,3 @@ coverage report -m --data-file="$coveragedatafile" coverage xml --data-file="$coveragedatafile" -o coverage_"$test_type".xml cp "$coveragedatafile" .coverage echo "✅ All processing done." && exit 0 - -#if [ "$calculate_all_finally" == "false" ]; then -# echo "✅ All processing done." && exit 0 -#else -# coverage combine .coverage.* -# coverage xml -# echo "✅ All processing done." && exit 0 -#fi From 549b31f66ce1226d904634af64d1f2216ad5408d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Tue, 29 Nov 2022 09:26:02 +0800 Subject: [PATCH 39/60] [Breaking Change] (config) Add processing about downloading needed shell script. --- .github/workflows/organize_and_generate_test_cov_reports.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index d2923ea7..264f7b9a 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -51,7 +51,9 @@ jobs: pip3 install coverage - name: Combine all testing coverage data files with test type and runtime OS, and convert to XML format file finally - run: bash ./scripts/ci/combine_coverage_reports.sh ${{ inputs.test_type }} + run: | + curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Workflow-Template-Python/develop/scripts/ci/combine_coverage_reports.sh --output ./scripts/ci/combine_coverage_reports.sh + bash ./scripts/ci/combine_coverage_reports.sh ${{ inputs.test_type }} - name: Upload testing coverage report (.coverage) uses: actions/upload-artifact@v3 From a296b8865bfb2fc992cded5830dd50df847ca26e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Tue, 29 Nov 2022 10:06:58 +0800 Subject: [PATCH 40/60] [Breaking Change] (config) Add option 'if-no-files-found' of action 'download-artifact'. --- .github/workflows/organize_and_generate_test_cov_reports.yaml | 1 + .github/workflows/upload_test_cov_report.yaml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index 264f7b9a..b959589c 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -38,6 +38,7 @@ jobs: with: name: coverage path: ./ + if-no-files-found: error - name: Setup Python 3.10 in Ubuntu OS uses: actions/setup-python@v4 diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 92ee62b5..552c2c97 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -101,12 +101,14 @@ jobs: with: name: test_coverage_data_file path: ${{ inputs.download_path }} + if-no-files-found: error - 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 }} + if-no-files-found: error - name: Install Python 3.10 if: ${{ inputs.upload-to-codecov == true || inputs.upload-to-coveralls == true }} From ff6f9a00fb73df6424b8bb957f3440a864ea8add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Wed, 30 Nov 2022 09:30:49 +0800 Subject: [PATCH 41/60] [Test] (code) Add setup.py for testing. --- setup.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 setup.py diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..0e166029 --- /dev/null +++ b/setup.py @@ -0,0 +1,46 @@ +import setuptools +import os + + +here = os.path.abspath(os.path.dirname(__file__)) + + +about = {} +with open(os.path.join(here, "test_gh_workflow", "__pkg_info__.py"), "r", encoding="utf-8") as f: + exec(f.read(), about) + + +with open("README.md", "r") as fh: + readme = fh.read() + + +setuptools.setup( + name="Test GitHub Action workflow", + version=about["__version__"], + author="Bryant Liu", + license="Apache License 2.0", + description="This is a testing package of GitHub Action reusable workflow", + long_description=readme, + long_description_content_type="text/markdown", + packages=setuptools.find_packages(exclude=("test",)), + package_dir={"test_gh_workflow": "test_gh_workflow"}, + zip_safe=False, + classifiers=[ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries :: Python Modules", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + ], + python_requires='>=3.6', + project_urls={ + "Source": "https://github.com/Chisanan232/GitHub-Action_Reusable_Workflows-Python", + }, +) From 512633887c92145d05cb3e66ec3ad375f0f9191d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Wed, 30 Nov 2022 09:31:18 +0800 Subject: [PATCH 42/60] [Test] (script) Add Python script for testing. --- scripts/ci/test/test_pgk_install.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 scripts/ci/test/test_pgk_install.py diff --git a/scripts/ci/test/test_pgk_install.py b/scripts/ci/test/test_pgk_install.py new file mode 100644 index 00000000..3c2a4ca1 --- /dev/null +++ b/scripts/ci/test/test_pgk_install.py @@ -0,0 +1,3 @@ +from test_gh_workflow import sample + +sample.hello_python() From 5b326cfa024f7b23ffcc117ab7cd64aac17bb5c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Wed, 30 Nov 2022 09:32:05 +0800 Subject: [PATCH 43/60] [New Feature] (config) Add new GitHub Action reusable workflow about pre-test before building package. --- .github/workflows/pre-building_test.yaml | 78 ++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/pre-building_test.yaml diff --git a/.github/workflows/pre-building_test.yaml b/.github/workflows/pre-building_test.yaml new file mode 100644 index 00000000..86dc3054 --- /dev/null +++ b/.github/workflows/pre-building_test.yaml @@ -0,0 +1,78 @@ +############################################################################################## +# +# Workflow Description: +# Build the Python source code to be Python package. +# +# Workflow input parameters: +# * General arguments: +# * upload_artifact_name: The option 'name' of reusable action 'actions/upload-artifact@v3'. +# * upload_artifact_path: The option 'path' of reusable action 'actions/upload-artifact@v3'. +# +# Workflow running output: +# No and do nothing. +# +############################################################################################## + +name: Build and compile the code to be Python package + +on: + workflow_call: + inputs: + python_package_name: + description: "The Python package name." + required: true + type: string + test_import_package_code_1: + description: "Test for importing the Python package." + required: true + type: string + test_import_package_code_2: + description: "Test for importing the Python package." + required: false + type: string + test_import_package_code_3: + description: "Test for importing the Python package." + required: false + type: string + test_python_script: + description: "Run a Python script for testing the Python package." + required: false + type: string + + +jobs: + pre-building_check: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Python 3.10 in Ubuntu OS + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install Python dependencies + run: | + python3 -m pip install --upgrade pip + pip3 install -U pip + pip3 install -U setuptools + pip3 install wheel + pip install -U -r ./requirements/requirements-test.txt + + - name: Install SmoothCrawler with by setup.py + run: python3 setup.py install --user || exit 1 + + - name: Show the Python package information + run: pip3 show ${{ inputs.python_package_name }} + + - name: Test to run script with package '${{ inputs.python_package_name }}' in command lines + run: | + ${{ inputs.test_import_package_code_1 }} + ${{ inputs.test_import_package_code_2 }} + ${{ inputs.test_import_package_code_3 }} + shell: python + + - name: Test to run script with package '${{ inputs.python_package_name }}' with Python file + run: python3 ${{ inputs.test_python_script }} + From 8089354af6e4969266d52226ff15c4c0fb054efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Wed, 30 Nov 2022 09:32:38 +0800 Subject: [PATCH 44/60] [New Feature] (config) Import new reusable workflow setting. --- .../test_python_project_ci_multi-tests.yaml | 23 ++++++++++--------- .../test_python_project_ci_one-test.yaml | 23 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test_python_project_ci_multi-tests.yaml b/.github/workflows/test_python_project_ci_multi-tests.yaml index a072934a..d3712acc 100644 --- a/.github/workflows/test_python_project_ci_multi-tests.yaml +++ b/.github/workflows/test_python_project_ci_multi-tests.yaml @@ -114,21 +114,22 @@ 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: ./.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 + pre-building_test: +# 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, coveralls_finish, codacy_finish] + uses: ./.github/workflows/pre-building_test.yaml + with: + python_package_name: Test-GitHub-Action-workflow + test_import_package_code_1: import test_gh_workflow + test_import_package_code_2: from test_gh_workflow import sample + test_import_package_code_3: sample.hello_python() + test_python_script: ./scripts/ci/test/test_pgk_install.py 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: pre-building_test uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml with: project_type: python-package diff --git a/.github/workflows/test_python_project_ci_one-test.yaml b/.github/workflows/test_python_project_ci_one-test.yaml index 5c074569..0aa29973 100644 --- a/.github/workflows/test_python_project_ci_one-test.yaml +++ b/.github/workflows/test_python_project_ci_one-test.yaml @@ -90,22 +90,21 @@ 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 + pre-building_test: +# name: Check about it could work finely by installing the Python package with setup.py file + needs: [codecov_finish, coveralls_finish, codacy_finish] + uses: ./.github/workflows/pre-building_test.yaml + with: + python_package_name: Test-GitHub-Action-workflow + test_import_package_code_1: import test_gh_workflow + test_import_package_code_2: from test_gh_workflow import sample + test_import_package_code_3: sample.hello_python() + test_python_script: ./scripts/ci/test/test_pgk_install.py build_git-tag_and_create_github-release: # name: Build git tag and GitHub release if it needs - needs: [coveralls_finish, codecov_finish, codacy_finish] + needs: pre-building_test uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml with: project_type: python-package From 5bee5e6e87ac05f20208d20c153dd54ffdea6c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Wed, 30 Nov 2022 09:40:09 +0800 Subject: [PATCH 45/60] [Bug Fix] (config) Remove invalid argument of action. --- .github/workflows/organize_and_generate_test_cov_reports.yaml | 1 - .github/workflows/upload_test_cov_report.yaml | 2 -- 2 files changed, 3 deletions(-) diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index b959589c..264f7b9a 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -38,7 +38,6 @@ jobs: with: name: coverage path: ./ - if-no-files-found: error - name: Setup Python 3.10 in Ubuntu OS uses: actions/setup-python@v4 diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 552c2c97..92ee62b5 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -101,14 +101,12 @@ jobs: with: name: test_coverage_data_file path: ${{ inputs.download_path }} - if-no-files-found: error - 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 }} - if-no-files-found: error - name: Install Python 3.10 if: ${{ inputs.upload-to-codecov == true || inputs.upload-to-coveralls == true }} From 5bd43f6d8bc48f70a8cccb95b39435ed29326eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Wed, 30 Nov 2022 09:42:05 +0800 Subject: [PATCH 46/60] [Breaking Change] (config) Add usage description and modify step name. --- .github/workflows/pre-building_test.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pre-building_test.yaml b/.github/workflows/pre-building_test.yaml index 86dc3054..16958708 100644 --- a/.github/workflows/pre-building_test.yaml +++ b/.github/workflows/pre-building_test.yaml @@ -5,8 +5,11 @@ # # Workflow input parameters: # * General arguments: -# * upload_artifact_name: The option 'name' of reusable action 'actions/upload-artifact@v3'. -# * upload_artifact_path: The option 'path' of reusable action 'actions/upload-artifact@v3'. +# * python_package_name: The Python package name. +# * test_import_package_code_1: Test for importing the Python package. +# * test_import_package_code_2: Test for importing the Python package. +# * test_import_package_code_3: Run a Python script for testing the Python package. +# * test_python_script: Test for importing the Python package. # # Workflow running output: # No and do nothing. @@ -60,7 +63,7 @@ jobs: pip3 install wheel pip install -U -r ./requirements/requirements-test.txt - - name: Install SmoothCrawler with by setup.py + - name: Install Python package by setup.py run: python3 setup.py install --user || exit 1 - name: Show the Python package information From cddd995e76115194424dbdfabc7ad8f493ef72fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Wed, 30 Nov 2022 09:56:36 +0800 Subject: [PATCH 47/60] [Docs] (docs) Add section of new reusable workflow 'pre-building_test.yaml'. --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index 2df6bf5f..e6c86089 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ The usage of each workflow template. * [_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) +* [_pre-building_test.yaml_](#pre-building_testyaml)
@@ -255,6 +256,38 @@ Nothing.
+### _pre-building_test.yaml_ + +* Description: Test package by simple way after running setup.py script to install Python package +* Options: + +| option name | data type | optional or required | function content | +|----------------------------|-----------|-------------------------------------------|-----------------------------------------------------| +| python_package_name | string | Required | The Python package name. | +| test_import_package_code_1 | string | Optional, Default value is _empty string_ | Test for importing the Python package. | +| test_import_package_code_2 | string | Optional, Default value is _empty string_ | Test for importing the Python package. | +| test_import_package_code_3 | string | Optional, Default value is _empty string_ | Test for importing the Python package. | +| test_python_script | string | Optional, Default value is _empty string_ | Run a Python script for testing the Python package. | + +* Output: + +No, nothing at all. + +* How to use it? + +```yaml + pre-building_test: +# name: Check about it could work finely by installing the Python package with setup.py file + uses: ./.github/workflows/pre-building_test.yaml + with: + python_package_name: Test-GitHub-Action-workflow + test_import_package_code_1: from test_gh_workflow import sample + test_import_package_code_2: sample.hello_python() + test_python_script: ./scripts/ci/test/test_pgk_install.py +``` + +
+ ### _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'. From 185439ee0ad44abbfd0062484af435a653cfe614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Wed, 30 Nov 2022 09:58:10 +0800 Subject: [PATCH 48/60] [Docs] (docs) Modify the order of reusable workflows agenda. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e6c86089..48bad357 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ 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) * [_pre-building_test.yaml_](#pre-building_testyaml) +* [_build_git-tag_and_create_github-release.yaml_](#build_git-tag_and_create_github-releaseyaml)
From 2a1c513f5fd20a5f063c365b25320de3892a0580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Wed, 30 Nov 2022 10:25:09 +0800 Subject: [PATCH 49/60] [Breaking Change] (config) Modify the workflow description. --- .github/workflows/pre-building_test.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pre-building_test.yaml b/.github/workflows/pre-building_test.yaml index 16958708..65642d96 100644 --- a/.github/workflows/pre-building_test.yaml +++ b/.github/workflows/pre-building_test.yaml @@ -1,7 +1,7 @@ -############################################################################################## +################################################################################################################### # # Workflow Description: -# Build the Python source code to be Python package. +# Test Python package by simple way, i.e., import modules, after running setup.py script to install package. # # Workflow input parameters: # * General arguments: @@ -14,9 +14,9 @@ # Workflow running output: # No and do nothing. # -############################################################################################## +################################################################################################################### -name: Build and compile the code to be Python package +name: Running pre-testing before building with running setup.py script on: workflow_call: From 1c0f31b7a413e4c02f8e08c996512ecc517784a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Wed, 30 Nov 2022 20:32:47 +0800 Subject: [PATCH 50/60] [Breaking Change] (config) Modify the GitHub repository name. --- .github/workflows/build_git-tag_and_create_github-release.yaml | 2 +- .github/workflows/organize_and_generate_test_cov_reports.yaml | 2 +- .github/workflows/upload_test_cov_report.yaml | 2 +- 3 files changed, 3 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 f0e69f9b..625e52a9 100644 --- a/.github/workflows/build_git-tag_and_create_github-release.yaml +++ b/.github/workflows/build_git-tag_and_create_github-release.yaml @@ -75,7 +75,7 @@ jobs: uses: actions/checkout@v3 - 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 + run: curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Reusable_Workflows-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 for Python project diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index 264f7b9a..2637422b 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -52,7 +52,7 @@ jobs: - name: Combine all testing coverage data files with test type and runtime OS, and convert to XML format file finally run: | - curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Workflow-Template-Python/develop/scripts/ci/combine_coverage_reports.sh --output ./scripts/ci/combine_coverage_reports.sh + curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Reusable_Workflows-Python/develop/scripts/ci/combine_coverage_reports.sh --output ./scripts/ci/combine_coverage_reports.sh bash ./scripts/ci/combine_coverage_reports.sh ${{ inputs.test_type }} - name: Upload testing coverage report (.coverage) diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 92ee62b5..45e2ba16 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -83,7 +83,7 @@ jobs: uses: actions/checkout@v3 - 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 + run: curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Reusable_Workflows-Python/develop/scripts/ci/check-input-params.sh --output ./scripts/ci/check-input-params.sh - name: Check the workflow input parameter run: | From 4bb7446377f94cd6370932f3af4128bab3afe17a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Wed, 30 Nov 2022 20:45:48 +0800 Subject: [PATCH 51/60] [New Feature] (config) Add new GitHub Action reusable workflow about pushing Python package to PyPI. --- .github/workflows/push_pkg_to_pypi.yaml | 84 +++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .github/workflows/push_pkg_to_pypi.yaml diff --git a/.github/workflows/push_pkg_to_pypi.yaml b/.github/workflows/push_pkg_to_pypi.yaml new file mode 100644 index 00000000..248e74a1 --- /dev/null +++ b/.github/workflows/push_pkg_to_pypi.yaml @@ -0,0 +1,84 @@ +######################################################################################################################### +# +# Workflow Description: +# Push the Python package to PyPI. (Official release the Python package) +# +# Workflow input parameters: +# * General arguments: +# * release-type: The type of release processing. It has 2 type options: 'Official-Release' or 'Pre-Release'. +# It won't push the package to PyPI if it's 'Pre-Release'. +# * push-to-PyPI: Push Python package to official PyPI or test PyPI. It has 2 type options: 'official' or 'test'. +# +# * Secret arguments: +# * PyPI_user: The username of PyPI. +# * PyPI_token: The password token of PyPI. +# +# Workflow running output: +# No and do nothing. +# +######################################################################################################################### + +name: Push the Python package to PyPI + +on: + workflow_call: + inputs: + release-type: + description: "The type of release processing. It has 2 type options: 'Official-Release' or 'Pre-Release'. It won't + push the package to PyPI if it's 'Pre-Release'." + type: string + required: true + push-to-PyPI: + description: "Push Python package to official PyPI or test PyPI. It has 2 type options: 'official' or 'test'." + type: string + required: false + default: 'test' + + secrets: + PyPI_user: + description: "The username of PyPI." + required: true + PyPI_token: + description: "The password token of PyPI." + required: true + + +jobs: + push_to_PyPI: + if: ${{ inputs.release-type == 'Official-Release' }} + runs-on: ubuntu-latest + steps: + - name: Download shell script for checking input parameters + run: | + curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Reusable_Workflows-Python/develop/scripts/ci/check_getting_output.sh --output ./scripts/ci/check_getting_output.sh + bash ./scripts/ci/check_getting_output.sh + + - name: Setup Python 3.10 in Ubuntu OS + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install Python dependencies + run: | + python3 -m pip install --upgrade pip + pip3 install -U pip + pip3 install -U setuptools + pip3 install wheel + pip3 install twine + + - name: Compile and package the code as Python package formatter + run: python3 setup.py sdist bdist_wheel + + - name: Push Python package to test PyPI + if: ${{ inputs.push-to-PyPI == 'test' }} + run: python3 -m twine upload --repository testpypi ./dist/* + env: + TWINE_USERNAME: ${{ secrets.PyPI_user }} + TWINE_PASSWORD: ${{ secrets.PyPI_token }} + + - name: Push Python package to official PyPI + if: ${{ inputs.push-to-PyPI == 'official' }} + run: python3 -m twine upload ./dist/* + env: + TWINE_USERNAME: ${{ secrets.PyPI_user }} + TWINE_PASSWORD: ${{ secrets.PyPI_token }} From bf17a1db41baaba56350e70221ba15f6491999a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Wed, 30 Nov 2022 20:47:18 +0800 Subject: [PATCH 52/60] [Breaking Change] (config) Modify to use new reusable workflow. --- .../test_python_project_ci_one-test.yaml | 52 ++++--------------- 1 file changed, 10 insertions(+), 42 deletions(-) diff --git a/.github/workflows/test_python_project_ci_one-test.yaml b/.github/workflows/test_python_project_ci_one-test.yaml index 0aa29973..94b20d92 100644 --- a/.github/workflows/test_python_project_ci_one-test.yaml +++ b/.github/workflows/test_python_project_ci_one-test.yaml @@ -113,47 +113,15 @@ jobs: debug_mode: true - fake_build_pkg_and_push_to_pypi: -# name: Check about it could work finely by installing the Python package with setup.py file + 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 == 'release' 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: Checkout - uses: actions/checkout@v3 - - - 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: | -# 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" - - -# 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: ./.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: ./.github/workflows/push_pkg_to_pypi.yaml -# secrets: -# pypi_user: ${{ secrets.PYPI_USERNAME }} -# pypi_token: ${{ secrets.PYPI_PASSWORD }} + uses: ./.github/workflows/push_pkg_to_pypi.yaml + with: + release-type: ${{ needs.build_git-tag_and_create_github-release.outputs.python_release_version }} + push-to-PyPI: test + secrets: + pypi_user: ${{ secrets.PYPI_USERNAME }} + pypi_token: ${{ secrets.PYPI_PASSWORD }} From c19fb913accf1bc33f67bcd0bf368d8b08dbe752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Wed, 30 Nov 2022 22:01:49 +0800 Subject: [PATCH 53/60] [Docs] (docs) Add section of new reusable workflow 'push_pkg_to_pypi.yaml'. --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/README.md b/README.md index 48bad357..a6e3ee60 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ The usage of each workflow template. * [_upload_test_cov_report.yaml_](#upload_test_cov_reportyaml) * [_pre-building_test.yaml_](#pre-building_testyaml) * [_build_git-tag_and_create_github-release.yaml_](#build_git-tag_and_create_github-releaseyaml) +* [_push_pkg_to_pypi.yaml_](#push_pkg_to_pypiyaml)
@@ -341,3 +342,44 @@ 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) +
+ +### _push_pkg_to_pypi.yaml_ + +* Description: Compile source code and push the Python package to PyPI. (Official release the Python package) +* Options: + +It has 2 different types option could use: + +_General option_: + +| option name | data type | optional or required | function content | +|--------------|-----------|-------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------| +| release-type | string | Required | The type of release processing. It has 2 type options: 'Official-Release' or 'Pre-Release'. It won't push the package to PyPI if it's 'Pre-Release'. | +| push-to-PyPI | string | Optional, Default value is _empty string_ | Push Python package to official PyPI or test PyPI. It has 2 type options: 'official' or 'test'. | + +_Secret option_: + +| option name | option is optional or required | function content | +|-------------|--------------------------------|-----------------------------| +| PyPI_user | Required | The username of PyPI. | +| PyPI_token | Required | The password token of PyPI. | + +* Output: + +No, nothing at all. + +* How to use it? + +```yaml + push_python_pkg_to_pypi: +# name: Upload the Python package files which has been compiled to PyPi + uses: ./.github/workflows/push_pkg_to_pypi.yaml + with: + release-type: 'Official-Release' + push-to-PyPI: test + secrets: + pypi_user: ${{ secrets.PYPI_USERNAME }} + pypi_token: ${{ secrets.PYPI_PASSWORD }} +``` + From c3fe3ba85643bc138e3fb572fc7c5444bd315cfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Wed, 30 Nov 2022 22:10:30 +0800 Subject: [PATCH 54/60] [Test] (code) Modify the version for testing. --- test_gh_workflow/__pkg_info__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_gh_workflow/__pkg_info__.py b/test_gh_workflow/__pkg_info__.py index 02ca93b3..d3ec452c 100644 --- a/test_gh_workflow/__pkg_info__.py +++ b/test_gh_workflow/__pkg_info__.py @@ -1 +1 @@ -__version__ = "0.2.0-alpha1.post1" +__version__ = "0.2.0" From 2d8a80290e618813506171a887b171b7b3e4c447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Thu, 1 Dec 2022 11:49:20 +0800 Subject: [PATCH 55/60] [Bug Fix] (config) Add step 'actions/checkout'. --- .github/workflows/push_pkg_to_pypi.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/push_pkg_to_pypi.yaml b/.github/workflows/push_pkg_to_pypi.yaml index 248e74a1..328ca56a 100644 --- a/.github/workflows/push_pkg_to_pypi.yaml +++ b/.github/workflows/push_pkg_to_pypi.yaml @@ -48,6 +48,9 @@ jobs: if: ${{ inputs.release-type == 'Official-Release' }} runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Download shell script for checking input parameters run: | curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Reusable_Workflows-Python/develop/scripts/ci/check_getting_output.sh --output ./scripts/ci/check_getting_output.sh From 08034546ae1635b265d1f451629e3fea081c1656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Thu, 1 Dec 2022 12:09:59 +0800 Subject: [PATCH 56/60] [Bug Fix] (config) Remove step about running shell to check release type. --- .github/workflows/push_pkg_to_pypi.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/push_pkg_to_pypi.yaml b/.github/workflows/push_pkg_to_pypi.yaml index 328ca56a..f993b8ae 100644 --- a/.github/workflows/push_pkg_to_pypi.yaml +++ b/.github/workflows/push_pkg_to_pypi.yaml @@ -51,11 +51,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Download shell script for checking input parameters - run: | - curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Reusable_Workflows-Python/develop/scripts/ci/check_getting_output.sh --output ./scripts/ci/check_getting_output.sh - bash ./scripts/ci/check_getting_output.sh - - name: Setup Python 3.10 in Ubuntu OS uses: actions/setup-python@v4 with: From 4c4620f128cd749b34925a046bc578a257046271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Thu, 1 Dec 2022 19:05:56 +0800 Subject: [PATCH 57/60] [Breaking Change] (code) Modify the package version back to pre-release format. --- test_gh_workflow/__pkg_info__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_gh_workflow/__pkg_info__.py b/test_gh_workflow/__pkg_info__.py index d3ec452c..02ca93b3 100644 --- a/test_gh_workflow/__pkg_info__.py +++ b/test_gh_workflow/__pkg_info__.py @@ -1 +1 @@ -__version__ = "0.2.0" +__version__ = "0.2.0-alpha1.post1" From 2e1c65d5262a08ca38920f91aa32742d0b260ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Thu, 1 Dec 2022 19:07:39 +0800 Subject: [PATCH 58/60] [Breaking Change] (config) Add more files or directories to ignore by git. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 7a71fa75..1eb06cce 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,11 @@ __pycache__ .coverage .coverage.* +*.egg-info/ .pypirc .pytest_cache/ .python-version +build/ code_source/ coverage.xml +dist/ From 89782a9b94a28d067e34e5d15dd6d129f3bdb2b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Thu, 1 Dec 2022 19:10:25 +0800 Subject: [PATCH 59/60] [Breaking Change] (docs) Add v4.0.0 GitHub release title. --- .github/release-title.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/release-title.md b/.github/release-title.md index 2e8aed9c..fa306999 100644 --- a/.github/release-title.md +++ b/.github/release-title.md @@ -1 +1 @@ -v3.0.0 - Modify under testing OS & Python versions and upgrade dependencies actions 🍻 \ No newline at end of file +v4.0.0 🍻🍾 - Add new reusable workflows and fix setup issue with the latest version Ubuntu OS. \ No newline at end of file From fd6284a2fea0a7f1ebec1f4d9dd35ef101060f63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CChisanan232=E2=80=9D?= Date: Thu, 1 Dec 2022 19:10:38 +0800 Subject: [PATCH 60/60] [Breaking Change] (docs) Add v4.0.0 GitHub release content. --- .github/release-notes.md | 50 +++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/.github/release-notes.md b/.github/release-notes.md index 682939a7..75714821 100644 --- a/.github/release-notes.md +++ b/.github/release-notes.md @@ -1,42 +1,40 @@ -[//]: # (### 🎉🎊🍾 New feature) - -[//]: # (
) +### 🎉🎊🍾 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_).) +1. Add new reusable workflows. + * _pre-building_test.yaml_: Running pre-testing by simple way with running _setup.py_ script. + * _push_pkg_to_pypi.yaml_: Compile Python source code and push the Python package to PyPI. -[//]: # () ### 🛠⚙️🔩 **Breaking Change**
-1. Clear the under testing environments or settings to reduce resource. - - 1-1. Deprecate and remove some runtime OS versions. - - * Deprecated settings: _ubuntu-18.04_, _ubuntu-20.04_, _ubuntu-22.04_, _macos-10.15_, _macos-11_, _macos-12_ - * New settings: _ubuntu-latest_, _macos-latest_ +1. Modify the workflows detail about testing coverage report processing. + * All report types, e.g., .coverage format data file or XML format report, would be handled and generated in workflow _organize_and_generate_test_cov_reports.yaml_. + * It only processes uploading testing reports in workflow _upload_test_cov_report.yaml_. - 1-2. Add more Python version for testing - - * New version: _Python 3.11_ +### 🛠🐛💣 **Bug Fix** +
-[//]: # (### ⚒⚒💣 **Bug Fix** ) +1. Fix issue of setup processing would fail with Python version 3.6 in runtime OS Ubuntu 22.04. + * Modify to test code with Python 3.6 version in Ubuntu 20.04. +[//]: # (### 🔬🧪🧬 **Refactor**) [//]: # (
) [//]: # () -[//]: # (1. Fix the issue about uploading test coverage report cannot work at all.) +[//]: # (1. Upgrade the GitHub Action syntax usage about set-output commands.) -### 🔬🧪🧬 **Refactor** -
+[//]: # () +[//]: # ( * Change to use environment variable _GITHUB_OUTPUT_.) -1. Upgrade the GitHub Action syntax usage about set-output commands. +[//]: # ( * Refer: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/) - * Change to use environment variable _GITHUB_OUTPUT_. - * Refer: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ +[//]: # () +[//]: # (2. Upgrade the actions which depends on Node.JS version 12 to newer version.) + +[//]: # () +[//]: # ( * Upgrade _actions/checkout_ to version 3.) -2. Upgrade the actions which depends on Node.JS version 12 to newer version. +[//]: # ( * Upgrade _actions/setup-python_ to version 4.) - * Upgrade _actions/checkout_ to version 3. - * Upgrade _actions/setup-python_ to version 4. - * Refer: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/ +[//]: # ( * Refer: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/)