diff --git a/.coveragerc b/.coveragerc
index b6ca4893..2e9ca09a 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -2,6 +2,7 @@
branch = True
parallel = True
source=./test_gh_workflow
+relative_files = True
omit =
*/__init__.py
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/)
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
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 1466f773..2637422b 100644
--- a/.github/workflows/organize_and_generate_test_cov_reports.yaml
+++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml
@@ -22,8 +22,8 @@ on:
inputs:
test_type:
description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'."
- required: true
type: string
+ required: true
jobs:
@@ -49,33 +49,22 @@ jobs:
python3 -m pip install --upgrade pip
pip3 install -U pip
pip3 install coverage
- pip3 install codecov
- pip3 install coveralls
-
- - name: Combine all testing code coverage result files with one specific test type
- if: ${{ inputs.test_type == 'unit-test' || inputs.test_type == 'integration-test' }}
- 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: |
+ 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)
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
diff --git a/.github/workflows/pre-building_test.yaml b/.github/workflows/pre-building_test.yaml
new file mode 100644
index 00000000..65642d96
--- /dev/null
+++ b/.github/workflows/pre-building_test.yaml
@@ -0,0 +1,81 @@
+###################################################################################################################
+#
+# Workflow Description:
+# Test Python package by simple way, i.e., import modules, after running setup.py script to install package.
+#
+# Workflow input parameters:
+# * General arguments:
+# * 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.
+#
+###################################################################################################################
+
+name: Running pre-testing before building with running setup.py script
+
+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 Python package 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 }}
+
diff --git a/.github/workflows/push_pkg_to_pypi.yaml b/.github/workflows/push_pkg_to_pypi.yaml
new file mode 100644
index 00000000..f993b8ae
--- /dev/null
+++ b/.github/workflows/push_pkg_to_pypi.yaml
@@ -0,0 +1,82 @@
+#########################################################################################################################
+#
+# 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: 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
+ 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 }}
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
diff --git a/.github/workflows/test_python_project_ci_multi-tests.yaml b/.github/workflows/test_python_project_ci_multi-tests.yaml
index 78d158ee..d3712acc 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 }}
@@ -122,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: [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 b1bdd082..94b20d92 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:
@@ -53,18 +53,18 @@ jobs:
test_type: unit-test
-# codecov_finish:
-## name: Organize and generate the testing report and upload it to Codecov
-## if: github.ref_name == 'release' || github.ref_name == 'master'
-# needs: [unit-test_codecov]
-# uses: ./.github/workflows/upload_test_cov_report.yaml
-# secrets:
-# codecov_token: ${{ secrets.CODECOV_TOKEN }}
-# with:
-# test_type: unit-test
-# upload-to-codecov: true
-# codecov_flags: unit # Required if 'upload-to-codecov' is true
-# codecov_name: gh_workflow_template # Required if 'upload-to-codecov' is true
+ codecov_finish:
+# name: Organize and generate the testing report and upload it to Codecov
+# if: github.ref_name == 'release' || github.ref_name == 'master'
+ needs: [unit-test_codecov]
+ uses: ./.github/workflows/upload_test_cov_report.yaml
+ secrets:
+ codecov_token: ${{ secrets.CODECOV_TOKEN }}
+ with:
+ test_type: unit-test
+ upload-to-codecov: true
+ codecov_flags: unit # Required if 'upload-to-codecov' is true
+ codecov_name: gh_workflow_template # Required if 'upload-to-codecov' is true
coveralls_finish:
@@ -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, codacy_finish]
+ needs: pre-building_test
uses: ./.github/workflows/build_git-tag_and_create_github-release.yaml
with:
project_type: python-package
@@ -114,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 }}
diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml
index ed6f8b8b..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: |
@@ -96,14 +96,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_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.
- name: Download code coverage result files which has be handled by different test type process
uses: actions/download-artifact@v3
with:
@@ -126,8 +124,8 @@ 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') }}
+ - name: Upload coverage report to Codecov https://codecov.io
+ if: ${{ inputs.upload-to-codecov == true }}
run: |
codecov \
-t ${{ secrets.codecov_token }} \
@@ -135,29 +133,12 @@ jobs:
--flags ${{ inputs.codecov_flags }} \
--env OS,PYTHON \
--name ${{ inputs.codecov_name }} \
- --verbose
-
- - name: Upload coverage report to Codecov https://codecov.io (For all test types)
- if: ${{ inputs.upload-to-codecov == true && inputs.test_type == 'all-test' }}
- run: |
- codecov \
- -t ${{ secrets.codecov_token }} \
- --file coverage_unit-test.xml \
- --file coverage_integration-test.xml \
- --flags ${{ inputs.codecov_flags }} \
- --env OS,PYTHON \
- --name ${{ inputs.codecov_name }} \
+ --required \
--verbose
- 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.*
+ run: pip3 install coveralls
- name: Upload coverage report to Coveralls https://coveralls.io
if: ${{ inputs.upload-to-coveralls == true }}
@@ -165,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') }}
+ - 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_${{ inputs.test_type }}.xml
# coverage-reports: cobertura.xml
-
- - name: Upload testing report to Codacy https://app.codacy.com/ (For all test types)
- if: ${{ inputs.upload-to-codacy == true && inputs.test_type == 'all-test' }}
- uses: codacy/codacy-coverage-reporter-action@v1
- with:
- project-token: ${{ secrets.codacy_token }}
- coverage-reports: coverage_unit-test.xml,coverage_integration-test.xml
-# coverage-reports: cobertura.xml
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/
diff --git a/README.md b/README.md
index 2df6bf5f..a6e3ee60 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,9 @@ 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)
+* [_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)
@@ -255,6 +257,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'.
@@ -308,3 +342,44 @@ The badge it generates:
[](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 }}
+```
+
diff --git a/scripts/ci/combine_coverage_reports.sh b/scripts/ci/combine_coverage_reports.sh
new file mode 100644
index 00000000..9a7895bf
--- /dev/null
+++ b/scripts/ci/combine_coverage_reports.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+set -ex
+
+test_type=$1
+
+coveragedatafile=".coverage.$test_type"
+
+if [ "$test_type" == "unit-test" ] || [ "$test_type" == "integration-test" ];
+then
+ coverage combine --data-file="$coveragedatafile" .coverage."$test_type".*
+elif [ "$test_type" == "all-test" ];
+then
+ coverage combine --data-file="$coveragedatafile" .coverage.*
+else
+ echo "โ It doesn't support $test_type currently. Please change to use options 'unit-test', 'integration-test' or 'all-test'." && exit 1
+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
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()
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",
+ },
+)