Skip to content

Commit 9b422d3

Browse files
authored
Merge pull request #37 from Chisanan232/release
🎉🎊🍾 [New Feature] (config) Official release v4.0.0 GitHub Action reusable workflows.
2 parents dbb2a5c + 6f2e125 commit 9b422d3

16 files changed

+416
-192
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
branch = True
33
parallel = True
44
source=./test_gh_workflow
5+
relative_files = True
56

67
omit =
78
*/__init__.py

.github/release-notes.md

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,40 @@
1-
[//]: # (### 🎉🎊🍾 New feature)
2-
3-
[//]: # (<hr>)
1+
### 🎉🎊🍾 New feature
2+
<hr>
43

5-
[//]: # ()
6-
[//]: # (1. Add new options about set up and run a sample HTTP server for testing if it needs in some testing scenario &#40;_run_test_items_via_pytest.yaml_&#41;.)
4+
1. Add new reusable workflows.
5+
* _pre-building_test.yaml_: Running pre-testing by simple way with running _setup.py_ script.
6+
* _push_pkg_to_pypi.yaml_: Compile Python source code and push the Python package to PyPI.
77

8-
[//]: # ()
98
### 🛠⚙️🔩 **Breaking Change**
109
<hr>
1110

12-
1. Clear the under testing environments or settings to reduce resource.
13-
14-
1-1. Deprecate and remove some runtime OS versions.
15-
16-
* Deprecated settings: _ubuntu-18.04_, _ubuntu-20.04_, _ubuntu-22.04_, _macos-10.15_, _macos-11_, _macos-12_
17-
* New settings: _ubuntu-latest_, _macos-latest_
11+
1. Modify the workflows detail about testing coverage report processing.
12+
* 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_.
13+
* It only processes uploading testing reports in workflow _upload_test_cov_report.yaml_.
1814

19-
1-2. Add more Python version for testing
20-
21-
* New version: _Python 3.11_
15+
### 🛠🐛💣 **Bug Fix**
16+
<hr>
2217

23-
[//]: # (### ⚒⚒💣 **Bug Fix** )
18+
1. Fix issue of setup processing would fail with Python version 3.6 in runtime OS Ubuntu 22.04.
19+
* Modify to test code with Python 3.6 version in Ubuntu 20.04.
2420

21+
[//]: # (### 🔬🧪🧬 **Refactor**)
2522
[//]: # (<hr>)
2623

2724
[//]: # ()
28-
[//]: # (1. Fix the issue about uploading test coverage report cannot work at all.)
25+
[//]: # (1. Upgrade the GitHub Action syntax usage about set-output commands.)
2926

30-
### 🔬🧪🧬 **Refactor**
31-
<hr>
27+
[//]: # ()
28+
[//]: # ( * Change to use environment variable _GITHUB_OUTPUT_.)
3229

33-
1. Upgrade the GitHub Action syntax usage about set-output commands.
30+
[//]: # ( * Refer: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/)
3431

35-
* Change to use environment variable _GITHUB_OUTPUT_.
36-
* Refer: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
32+
[//]: # ()
33+
[//]: # (2. Upgrade the actions which depends on Node.JS version 12 to newer version.)
34+
35+
[//]: # ()
36+
[//]: # ( * Upgrade _actions/checkout_ to version 3.)
3737

38-
2. Upgrade the actions which depends on Node.JS version 12 to newer version.
38+
[//]: # ( * Upgrade _actions/setup-python_ to version 4.)
3939

40-
* Upgrade _actions/checkout_ to version 3.
41-
* Upgrade _actions/setup-python_ to version 4.
42-
* Refer: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/
40+
[//]: # ( * Refer: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/)

.github/release-title.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v3.0.0 - Modify under testing OS & Python versions and upgrade dependencies actions 🍻
1+
v4.0.0 🍻🍾 - Add new reusable workflows and fix setup issue with the latest version Ubuntu OS.

.github/workflows/build_git-tag_and_create_github-release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
uses: actions/checkout@v3
7676

7777
- name: Download shell script for checking input parameters
78-
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
78+
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
7979

8080
# This flow for the project type is Python project
8181
- name: Build git tag and create GitHub release for Python project

.github/workflows/organize_and_generate_test_cov_reports.yaml

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ on:
2222
inputs:
2323
test_type:
2424
description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'."
25-
required: true
2625
type: string
26+
required: true
2727

2828

2929
jobs:
@@ -49,33 +49,22 @@ jobs:
4949
python3 -m pip install --upgrade pip
5050
pip3 install -U pip
5151
pip3 install coverage
52-
pip3 install codecov
53-
pip3 install coveralls
54-
55-
- name: Combine all testing code coverage result files with one specific test type
56-
if: ${{ inputs.test_type == 'unit-test' || inputs.test_type == 'integration-test' }}
57-
run: coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.${{ inputs.test_type }}.*
5852
59-
- name: Combine all testing code coverage result files with all test types
60-
if: ${{ inputs.test_type == 'all-test' }}
61-
run: coverage combine --data-file=.coverage.${{ inputs.test_type }} .coverage.*
62-
63-
- name: Report testing coverage of project code
64-
run: coverage report -m --data-file=.coverage.${{ inputs.test_type }}
65-
66-
- name: General testing coverage report as XML format with ${{ inputs.test_type }}
67-
run: coverage xml --data-file=.coverage.${{ inputs.test_type }} -o coverage_${{ inputs.test_type }}.xml
53+
- name: Combine all testing coverage data files with test type and runtime OS, and convert to XML format file finally
54+
run: |
55+
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
56+
bash ./scripts/ci/combine_coverage_reports.sh ${{ inputs.test_type }}
6857
6958
- name: Upload testing coverage report (.coverage)
7059
uses: actions/upload-artifact@v3
7160
with:
72-
name: test_coverage_report
73-
path: .coverage.${{ inputs.test_type }}
61+
name: test_coverage_data_file
62+
path: .coverage
7463
if-no-files-found: error
7564

7665
- name: Upload testing coverage report (.xml)
7766
uses: actions/upload-artifact@v3
7867
with:
7968
name: test_coverage_xml_report
80-
path: coverage_${{ inputs.test_type }}.xml
69+
path: coverage**xml
8170
if-no-files-found: error
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
###################################################################################################################
2+
#
3+
# Workflow Description:
4+
# Test Python package by simple way, i.e., import modules, after running setup.py script to install package.
5+
#
6+
# Workflow input parameters:
7+
# * General arguments:
8+
# * python_package_name: The Python package name.
9+
# * test_import_package_code_1: Test for importing the Python package.
10+
# * test_import_package_code_2: Test for importing the Python package.
11+
# * test_import_package_code_3: Run a Python script for testing the Python package.
12+
# * test_python_script: Test for importing the Python package.
13+
#
14+
# Workflow running output:
15+
# No and do nothing.
16+
#
17+
###################################################################################################################
18+
19+
name: Running pre-testing before building with running setup.py script
20+
21+
on:
22+
workflow_call:
23+
inputs:
24+
python_package_name:
25+
description: "The Python package name."
26+
required: true
27+
type: string
28+
test_import_package_code_1:
29+
description: "Test for importing the Python package."
30+
required: true
31+
type: string
32+
test_import_package_code_2:
33+
description: "Test for importing the Python package."
34+
required: false
35+
type: string
36+
test_import_package_code_3:
37+
description: "Test for importing the Python package."
38+
required: false
39+
type: string
40+
test_python_script:
41+
description: "Run a Python script for testing the Python package."
42+
required: false
43+
type: string
44+
45+
46+
jobs:
47+
pre-building_check:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v3
52+
53+
- name: Setup Python 3.10 in Ubuntu OS
54+
uses: actions/setup-python@v4
55+
with:
56+
python-version: '3.10'
57+
58+
- name: Install Python dependencies
59+
run: |
60+
python3 -m pip install --upgrade pip
61+
pip3 install -U pip
62+
pip3 install -U setuptools
63+
pip3 install wheel
64+
pip install -U -r ./requirements/requirements-test.txt
65+
66+
- name: Install Python package by setup.py
67+
run: python3 setup.py install --user || exit 1
68+
69+
- name: Show the Python package information
70+
run: pip3 show ${{ inputs.python_package_name }}
71+
72+
- name: Test to run script with package '${{ inputs.python_package_name }}' in command lines
73+
run: |
74+
${{ inputs.test_import_package_code_1 }}
75+
${{ inputs.test_import_package_code_2 }}
76+
${{ inputs.test_import_package_code_3 }}
77+
shell: python
78+
79+
- name: Test to run script with package '${{ inputs.python_package_name }}' with Python file
80+
run: python3 ${{ inputs.test_python_script }}
81+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#########################################################################################################################
2+
#
3+
# Workflow Description:
4+
# Push the Python package to PyPI. (Official release the Python package)
5+
#
6+
# Workflow input parameters:
7+
# * General arguments:
8+
# * release-type: The type of release processing. It has 2 type options: 'Official-Release' or 'Pre-Release'.
9+
# It won't push the package to PyPI if it's 'Pre-Release'.
10+
# * push-to-PyPI: Push Python package to official PyPI or test PyPI. It has 2 type options: 'official' or 'test'.
11+
#
12+
# * Secret arguments:
13+
# * PyPI_user: The username of PyPI.
14+
# * PyPI_token: The password token of PyPI.
15+
#
16+
# Workflow running output:
17+
# No and do nothing.
18+
#
19+
#########################################################################################################################
20+
21+
name: Push the Python package to PyPI
22+
23+
on:
24+
workflow_call:
25+
inputs:
26+
release-type:
27+
description: "The type of release processing. It has 2 type options: 'Official-Release' or 'Pre-Release'. It won't
28+
push the package to PyPI if it's 'Pre-Release'."
29+
type: string
30+
required: true
31+
push-to-PyPI:
32+
description: "Push Python package to official PyPI or test PyPI. It has 2 type options: 'official' or 'test'."
33+
type: string
34+
required: false
35+
default: 'test'
36+
37+
secrets:
38+
PyPI_user:
39+
description: "The username of PyPI."
40+
required: true
41+
PyPI_token:
42+
description: "The password token of PyPI."
43+
required: true
44+
45+
46+
jobs:
47+
push_to_PyPI:
48+
if: ${{ inputs.release-type == 'Official-Release' }}
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v3
53+
54+
- name: Setup Python 3.10 in Ubuntu OS
55+
uses: actions/setup-python@v4
56+
with:
57+
python-version: '3.10'
58+
59+
- name: Install Python dependencies
60+
run: |
61+
python3 -m pip install --upgrade pip
62+
pip3 install -U pip
63+
pip3 install -U setuptools
64+
pip3 install wheel
65+
pip3 install twine
66+
67+
- name: Compile and package the code as Python package formatter
68+
run: python3 setup.py sdist bdist_wheel
69+
70+
- name: Push Python package to test PyPI
71+
if: ${{ inputs.push-to-PyPI == 'test' }}
72+
run: python3 -m twine upload --repository testpypi ./dist/*
73+
env:
74+
TWINE_USERNAME: ${{ secrets.PyPI_user }}
75+
TWINE_PASSWORD: ${{ secrets.PyPI_token }}
76+
77+
- name: Push Python package to official PyPI
78+
if: ${{ inputs.push-to-PyPI == 'official' }}
79+
run: python3 -m twine upload ./dist/*
80+
env:
81+
TWINE_USERNAME: ${{ secrets.PyPI_user }}
82+
TWINE_PASSWORD: ${{ secrets.PyPI_token }}

.github/workflows/run_test_items_via_pytest.yaml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,32 +76,23 @@ jobs:
7676
strategy:
7777
matrix:
7878
python-version: [3.6,3.7,3.8,3.9,'3.10','3.11']
79-
os: [ubuntu-latest,macos-latest]
79+
os: [ubuntu-20.04,ubuntu-latest,macos-latest]
8080
exclude:
81-
- os: ubuntu-18.04
81+
- os: ubuntu-latest
8282
python-version: 3.6
83-
- os: ubuntu-18.04
84-
python-version: 3.9
85-
- os: ubuntu-18.04
86-
python-version: '3.10'
8783
- os: ubuntu-20.04
88-
python-version: 3.8
84+
python-version: 3.7
8985
- os: ubuntu-20.04
90-
python-version: 3.9
91-
- os: ubuntu-22.04
92-
python-version: 3.6
93-
- os: macos-10.15
94-
python-version: 3.6
95-
- os: macos-10.15
9686
python-version: 3.8
97-
- os: macos-11
98-
python-version: 3.6
99-
- os: macos-11
87+
- os: ubuntu-20.04
10088
python-version: 3.9
101-
- os: macos-12
102-
python-version: 3.6
89+
- os: ubuntu-20.04
90+
python-version: '3.10'
91+
- os: ubuntu-20.04
92+
python-version: 3.11
10393
test-path: ${{fromJson(inputs.all_test_items_paths)}}
10494

95+
10596
steps:
10697
- uses: actions/checkout@v3
10798

0 commit comments

Comments
 (0)