Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
2722bbb
✏️ Add the working directory setting at the step about downloading th…
Chisanan232 Apr 4, 2025
e5fd431
➕ Add end-to-end test about working directory feature.
Chisanan232 Apr 4, 2025
7af40eb
✏️ Rename the CI workflow to be more clear its meaning.
Chisanan232 Apr 4, 2025
0f896e5
✏️ Update the Poetry lock file.
Chisanan232 Apr 4, 2025
d1a0164
✏️ Fix the Poetry configuration bug.
Chisanan232 Apr 4, 2025
a270e6d
✏️ Fix the import error for nested project file structure.
Chisanan232 Apr 4, 2025
10c79e0
✏️ Fix the bug about test coverage reports would under working direct…
Chisanan232 Apr 4, 2025
a77ee6a
✏️ Fix broken E2E test.
Chisanan232 Apr 4, 2025
2f4075e
✏️ Fix broken E2E test.
Chisanan232 Apr 4, 2025
a6e63a8
✏️ Adjust the file path to be correct.
Chisanan232 Apr 4, 2025
9bce268
Merge branch 'master' into develop
Chisanan232 Apr 4, 2025
375b7f8
✏️ Adopt working directory feature into reusable workflow about organ…
Chisanan232 Apr 4, 2025
b2d7c2e
✏️ Adopt the setting about working directory into E2E test.
Chisanan232 Apr 4, 2025
4ba8fd2
Merge remote-tracking branch 'remote/master' into develop
Chisanan232 Apr 4, 2025
7ca6956
Merge branch 'develop' of https://github.com/Chisanan232/GitHub-Actio…
Chisanan232 Apr 4, 2025
93e325a
➕ Add new parameter of reusable workflow about working directory in o…
Chisanan232 Apr 4, 2025
3725126
✏️ Apply the working directory setting at organizing test coverage re…
Chisanan232 Apr 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/rw_get_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:

- name: Download shell script for getting path of all test modules
if: ${{ inputs.use_customized_shell != true }}
working-directory: ${{ inputs.test_working_directory }}
run: curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Reusable_Workflows-Python/develop/scripts/ci/get-all-tests.sh --output ${{ inputs.shell_path }}

- id: set-matrix
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/rw_organize_test_cov_reports.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#
# Workflow input parameters:
# * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'.
# * test_working_directory: The working directory for test running.
#
# Workflow running output:
# No, but it would save the testing coverage reports (coverage.xml) to provide after-process to organize and record.
Expand All @@ -24,6 +25,11 @@ on:
description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'."
type: string
required: true
test_working_directory:
description: "The working directory for test running."
required: false
type: string
default: './'


jobs:
Expand All @@ -37,7 +43,7 @@ jobs:
uses: actions/download-artifact@v4
with:
pattern: coverage*
path: ./
path: ${{ inputs.test_working_directory }}
merge-multiple: true

- name: Setup Python 3.10 in Ubuntu OS
Expand All @@ -46,6 +52,7 @@ jobs:
python-version: '3.10'

- name: Install Python tool 'coverage'
working-directory: ${{ inputs.test_working_directory }}
run: |
python3 -m pip install --upgrade pip
pip3 install -U pip
Expand All @@ -54,6 +61,7 @@ jobs:
ls -la

- name: Combine all testing coverage data files with test type and runtime OS, and convert to XML format file finally
working-directory: ${{ inputs.test_working_directory }}
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 }} .coverage.
Expand All @@ -62,14 +70,14 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.test_type }}_coverage_data_file
path: .coverage
path: ${{ inputs.test_working_directory }}.coverage
if-no-files-found: error
include-hidden-files: true

- name: Upload testing coverage report (.xml)
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.test_type }}_coverage_xml_report
path: coverage**xml
path: ${{ inputs.test_working_directory }}coverage**xml
if-no-files-found: error
include-hidden-files: true
3 changes: 2 additions & 1 deletion .github/workflows/rw_poetry_run_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ jobs:

- name: Setup and run HTTP server for testing
if: ${{ inputs.setup_http_server == true }}
working-directory: ${{ inputs.test_working_directory }}
run: gunicorn --bind ${{ inputs.http_server_host }}:${{ inputs.http_server_port }} '${{ inputs.http_server_app_module }}:${{ inputs.http_server_enter_point }}' --daemon

- name: Test to send HTTP request to sample HTTP server
Expand All @@ -169,6 +170,6 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: coverage_${{ inputs.test_type }}_${{ inputs.runtime_os }}_${{ inputs.python_version }}
path: .coverage.${{ inputs.test_type }}.${{ inputs.runtime_os }}-${{ inputs.python_version }}
path: ${{ inputs.test_working_directory }}.coverage.${{ inputs.test_type }}.${{ inputs.runtime_os }}-${{ inputs.python_version }}
if-no-files-found: error
include-hidden-files: true
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
# Workflow input parameters:
# * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'.
# * test_working_directory: The working directory for test running.
# * install_dependency_with_group: Install the dependency by Poetry configuration with dependency group setting. This parameter receive the dependency group naming.
# * all_test_items_paths: The target paths of test items under test.
# * setup_http_server: If it's true, it would set up and run HTTP server for testing.
Expand Down Expand Up @@ -34,6 +35,11 @@ on:
description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'."
required: true
type: string
test_working_directory:
description: "The working directory for test running."
required: false
type: string
default: './'
install_dependency_with_group:
description: "Install the dependency by Poetry configuration with dependency group setting. This parameter receive the dependency group naming."
type: string
Expand Down Expand Up @@ -86,6 +92,7 @@ jobs:
runtime_os: ${{ matrix.os }}
python_version: ${{ matrix.python-version }}
test_type: ${{ inputs.test_type }}
test_working_directory: ${{ inputs.test_working_directory }}
install_dependency_with_group: ${{ inputs.install_dependency_with_group }}
all_test_items_paths: ${{ inputs.all_test_items_paths }}
setup_http_server: ${{ inputs.setup_http_server }}
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/rw_upload_test_cov_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# * General arguments:
# * download_path: The path to download testing coverage reports via 'actions/download-artifact@v3'.
# * test_type: The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'.
# * test_working_directory: The working directory for test running.
# * upload-to-codecov: If it's true, it would upload testing coverage report for Codecov (https://codecov.io).
# * codecov_flags: The flags of the testing coverage report for Codecov. This option would be required if 'upload-to-codecov' is true.
# * codecov_name: The name of the testing coverage report for Codecov. This option would be required if 'upload-to-codecov' is true.
Expand Down Expand Up @@ -37,6 +38,11 @@ on:
description: "The testing type. In generally, it only has 2 options: 'unit-test' and 'integration-test'."
required: true
type: string
test_working_directory:
description: "The working directory for test running."
required: false
type: string
default: './'
upload-to-codecov:
description: "If it's true, it would upload testing coverage report for Codecov (https://codecov.io)."
type: boolean
Expand Down Expand Up @@ -156,6 +162,7 @@ jobs:

- name: Upload coverage report to Coveralls https://coveralls.io
if: ${{ inputs.upload-to-coveralls == true }}
working-directory: ${{ inputs.test_working_directory }}
env:
GITHUB_TOKEN: ${{ secrets.coveralls_token }}
run: coveralls --verbose
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: Nested Python project with Poetry CI Test (multi-tests)

on:
pull_request:
branches:
- "develop**"
- "master"
paths:
# The workflow self.
- ".github/workflows/test_nested_pyproject_ci_multi-tests_by_poetry.yaml"
# The shell script only be used by this workflow.
- "nested_poetry_project/scripts/ci/check_getting_output.sh"
# The sample Python code.
- "nested_poetry_project/.coveragerc"
- "nested_poetry_project/pyproject.toml"
- "nested_poetry_project/poetry.lock"
- "nested_poetry_project/pytest.ini"
- "nested_poetry_project/nested_python_src/**"
- "nested_poetry_project/test/**"
# The shell scripts or actions this workflow would use.
- ".github/workflows/rw_get_tests.yaml"
- ".github/workflows/rw_poetry_run_test.yaml"
- ".github/workflows/rw_poetry_run_test_with_multi_py_versions.yaml"
- ".github/workflows/rw_organize_test_cov_reports.yaml"
- "nested_poetry_project/scripts/ci/combine_coverage_reports.sh"
- ".github/workflows/rw_upload_test_cov_report.yaml"
- "nested_poetry_project/scripts/ci/check-input-params.sh"
- ".github/workflows/rw_sonarqube_scan.yaml"
- ".github/workflows/rw_pre-building_test.yaml"
- ".github/workflows/rw_build_git-tag_and_create_github-release.yaml"
- "nested_poetry_project/scripts/ci/build_git-tag_or_create_github-release.sh"
- "nested_poetry_project/scripts/ci/deployment_new_version_workflow.sh"

jobs:
prep-testbed_unit-test:
# name: Prepare all unit test items
uses: ./.github/workflows/rw_get_tests.yaml
with:
test_working_directory: './nested_poetry_project/'
shell_arg: test/unit_test/


prep-testbed_integration-test:
# name: Prepare all integration test items
uses: ./.github/workflows/rw_get_tests.yaml
with:
shell_path: ./scripts/ci/test/get-integration-test-paths.sh
shell_arg: unix
test_working_directory: './nested_poetry_project/'
use_customized_shell: true


run_unit-test:
# name: Run all unit test items
needs: prep-testbed_unit-test
uses: ./.github/workflows/rw_poetry_run_test.yaml
with:
test_type: unit-test
test_working_directory: './nested_poetry_project/'
install_dependency_with_group: github-action
all_test_items_paths: ${{needs.prep-testbed_unit-test.outputs.all_test_items}}


run_integration-test:
# name: Run all integration test items. This testing would test the code with other resource or system to ensure the features work finely.
needs: prep-testbed_integration-test
uses: ./.github/workflows/rw_poetry_run_test_with_multi_py_versions.yaml
with:
test_type: integration-test
test_working_directory: './nested_poetry_project/'
install_dependency_with_group: github-action
all_test_items_paths: ${{needs.prep-testbed_integration-test.outputs.all_test_items}}
setup_http_server: true
http_server_host: 0.0.0.0
http_server_port: 30303
http_server_app_module: test._http_server.app
http_server_enter_point: app


all-test_codecov:
# name: Organize and generate the testing report and upload it to Codecov
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dependencies') }}
needs: [run_unit-test, run_integration-test]
uses: ./.github/workflows/rw_organize_test_cov_reports.yaml
with:
test_type: all-test
test_working_directory: './nested_poetry_project/'


codecov_finish:
# name: Organize and generate the testing report and upload it to Codecov
# if: github.ref_name == 'release' || github.ref_name == 'master'
needs: [all-test_codecov]
uses: ./.github/workflows/rw_upload_test_cov_report.yaml
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
with:
test_type: all-test
upload-to-codecov: true
codecov_flags: unit,integration # Required if 'upload-to-codecov' is true
codecov_name: gh_workflow_template # Required if 'upload-to-codecov' is true


coveralls_finish:
# name: Organize and generate the testing report and upload it to Coveralls
# if: github.ref_name == 'release' || github.ref_name == 'master'
needs: [all-test_codecov]
uses: ./.github/workflows/rw_upload_test_cov_report.yaml
secrets:
coveralls_token: ${{ secrets.COVERALLS_TOKEN }}
with:
test_type: all-test
test_working_directory: './nested_poetry_project/'
upload-to-coveralls: true


codacy_finish:
# name: Upload test report to Codacy to analyse and record code quality
needs: [all-test_codecov]
uses: ./.github/workflows/rw_upload_test_cov_report.yaml
secrets:
codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }}
with:
test_type: all-test
upload-to-codacy: true


sonarqube_finish:
# name: Trigger SoarQube service to scan and analyse project
needs: [all-test_codecov]
uses: ./.github/workflows/rw_sonarqube_scan.yaml
secrets:
sonar_token: ${{ secrets.SONAR_TOKEN }}
with:
test_type: all-test
# download_path: ${{ inputs.download_path }}
7 changes: 7 additions & 0 deletions nested_poetry_project/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[run]
parallel = True
relative_files = True
include=./test_gh_workflow

omit =
*/__init__.py
Empty file.
1 change: 1 addition & 0 deletions nested_poetry_project/nested_python_src/__pkg_info__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.2.0-alpha1.post1"

Check warning on line 1 in nested_poetry_project/nested_python_src/__pkg_info__.py

View check run for this annotation

Codecov / codecov/patch

nested_poetry_project/nested_python_src/__pkg_info__.py#L1

Added line #L1 was not covered by tests
3 changes: 3 additions & 0 deletions nested_poetry_project/nested_python_src/sample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

def hello_python() -> str:
return "Hello Python"
Loading