Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
64ce074
[New Feature] (script) Add sample shell scripts for testing.
Chisanan232 Aug 20, 2022
84d76b2
[New Feature] (code) Add sample Python library source code.
Chisanan232 Aug 20, 2022
56a9535
[New Feature] (test) Add sample test code of Python library project.
Chisanan232 Aug 20, 2022
9ce19eb
[New Feature] (config) Add sample testing coverage configuration for …
Chisanan232 Aug 20, 2022
8ec68f9
[New Feature] (config) Add sample PyTest configuration.
Chisanan232 Aug 20, 2022
327e815
[New Feature] (config) Add sample configuration for Codecov service.
Chisanan232 Aug 20, 2022
10d7730
[New Feature] (config) Add .gitignore setting for development.
Chisanan232 Aug 20, 2022
e41a5cf
[New Feature] (config) Add configuration of CI tool GitHub Action.
Chisanan232 Aug 20, 2022
5ae160b
[New Feature] (config) Add sample configuration about Python dependen…
Chisanan232 Aug 20, 2022
f716582
[Bug Fix] (config) Fix the issue about incorrect usage at if-condition.
Chisanan232 Aug 20, 2022
4349ea8
[Bug Fix] (config) Fix the issue about incorrect usage at if-condition.
Chisanan232 Aug 20, 2022
4ec69d0
[Bug Fix] (config) Fix the issue about incorrect usage at if-condition.
Chisanan232 Aug 20, 2022
c3c5897
[Bug Fix] (config) Fix the issue about incorrect usage at if-condition.
Chisanan232 Aug 20, 2022
de4f167
[Bug Fix] (config) Fix the issue about incorrect usage at if-condition.
Chisanan232 Aug 20, 2022
35410cd
[Bug Fix] (config) Fix the issue about incorrect usage at if-condition.
Chisanan232 Aug 20, 2022
9c44a07
[Bug Fix] (config) Fix the issue about incorrect usage at if-condition.
Chisanan232 Aug 20, 2022
6682cf5
[Bug Fix] (config) Fix the issue about incorrect usage at if-condition.
Chisanan232 Aug 20, 2022
07fffed
[Bug Fix + Test] (config) Modify the if-condition usage to job level.
Chisanan232 Aug 21, 2022
ab69975
[Bug Fix] (config) Bug the issue about it only call the reusable work…
Chisanan232 Aug 21, 2022
9ede387
[Bug Fix] (config) Fix the issue about call reusable workflows in loc…
Chisanan232 Aug 21, 2022
30e6e2b
[Bug Fix + Test] (config) Modify the uploading file name.
Chisanan232 Aug 21, 2022
921b655
[Bug Fix + Test] (config) Rename the uploading option 'name' and file…
Chisanan232 Aug 21, 2022
e508552
[Bug Fix + Test] (config) Modify the downloading option 'path'.
Chisanan232 Aug 21, 2022
b2b6d42
[Bug Fix + Test] (config) Modify the file path value for combining te…
Chisanan232 Aug 21, 2022
780d03f
[Bug Fix + Test] (config) Modify the file path value for combining te…
Chisanan232 Aug 21, 2022
d815659
[Bug Fix + Test] (config) Modify the file path value for combining te…
Chisanan232 Aug 21, 2022
899b63f
[Bug Fix + Test] (config) Modify the file path value for combining te…
Chisanan232 Aug 21, 2022
ce93130
[Bug Fix + Test] (config) Modify the file path value for combining te…
Chisanan232 Aug 21, 2022
bcd12b6
[Bug Fix + Test] (config) Modify the file path value for combining te…
Chisanan232 Aug 21, 2022
6ac31e2
[Bug Fix + Test] (config) Modify the file path value for combining te…
Chisanan232 Aug 21, 2022
756b48e
[Breaking Change] (config) Remove the steps for testing and troublesh…
Chisanan232 Aug 21, 2022
c50f540
Merge pull request #8 from Chisanan232/develop
Chisanan232 Aug 21, 2022
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
11 changes: 11 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# # This test directory for testing to simulate a Python library project structure.

[run]
parallel = True
relative_files = True
source=./test_gh_workflow

omit =
*/__init__.py

#ignore_errors = True
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ on:
type: string
generate_xml_report_finally:
description: "Something, it only has 1 test type currently. So it could let this option to be 'true' than it would generate XML report finally to let uploading process to use it directly."
required: true
type: boolean
required: false
default: false


jobs:
organize_and_generate_test_report:
organize_test_reports:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -39,7 +40,7 @@ jobs:
uses: actions/download-artifact@v3
with:
name: coverage
path: .coverage.${{ inputs.test_type }}*
path: ./

- name: Setup Python 3.10 in Ubuntu OS
uses: actions/setup-python@v2
Expand All @@ -58,26 +59,53 @@ jobs:
- name: Report testing coverage of project code
run: coverage report -m

- name: Upload testing coverage report
uses: actions/upload-artifact@v3
with:
name: project_testing_coverage_report_${{ inputs.test_type }}
path: .coverage
if-no-files-found: error

generate_final_test_report:
if: ${{ inputs.generate_xml_report_finally == true }}
# if: inputs.generate_xml_report_finally == 'true'
needs: organize_test_reports
runs-on: ubuntu-latest
steps:
- name: Download code coverage result file
uses: actions/download-artifact@v3
with:
name: project_testing_coverage_report_${{ inputs.test_type }}
path: ./

- name: General testing coverage report as XML format
if: ${{ inputs.generate_xml_report_finally }} == 'true'
run: coverage xml

- name: Rename the testing coverage report with test type
if: ${{ inputs.generate_xml_report_finally }} == 'false'
run: mv .coverage .coverage-${{ inputs.test_type }}

- name: Upload testing coverage report
if: ${{ inputs.generate_xml_report_finally }} == 'true'
uses: actions/upload-artifact@v3
with:
name: final_project_testing_coverage_report
path: coverage.xml
if-no-files-found: error

generate_test_type_report:
if: ${{ inputs.generate_xml_report_finally == false }}
# if: inputs.generate_xml_report_finally == 'false'
needs: organize_test_reports
runs-on: ubuntu-latest
steps:
- name: Download code coverage result file
uses: actions/download-artifact@v3
with:
name: project_testing_coverage_report_${{ inputs.test_type }}
path: ./

- name: Rename the testing coverage report with test type
run: mv .coverage .coverage-${{ inputs.test_type }}

- name: Upload testing coverage report
if: ${{ inputs.generate_xml_report_finally }} == 'false'
uses: actions/upload-artifact@v3
with:
name: project_testing_coverage_report
name: new_project_testing_coverage_report_${{ inputs.test_type }}
path: .coverage-${{ inputs.test_type }}
if-no-files-found: error
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ jobs:
- name: Download code coverage result file
uses: actions/download-artifact@v3
with:
name: project_testing_coverage_report
path: .coverage-*
name: new_project_testing_coverage_report_unit-test
path: ./

- name: Download code coverage result file
uses: actions/download-artifact@v3
with:
name: new_project_testing_coverage_report_integration-test
path: ./

- name: Setup Python 3.10 in Ubuntu OS
uses: actions/setup-python@v2
Expand Down
120 changes: 120 additions & 0 deletions .github/workflows/test-reusable-workflows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: github-action reusable workflows test
on:
push:
branches:
- "develop"
- "release"
- "release-**"
- "release/**"
- "master"
paths-ignore:
- ".gitcommitrules"
- ".gitignore"
- "LICENSE"
- "README.md"
pull_request:
branches:
- "develop"
- "release"
- "release-**"
- "release/**"
paths-ignore:
- ".gitcommitrules"
- ".gitignore"
- "LICENSE"
- "README.md"

jobs:

prep-testbed_unit-test:
# name: Prepare all unit test items
uses: ./.github/workflows/prepare_test_items.yaml
with:
shell_path: scripts/ci/get-unit-test-paths.sh
shell_arg: unix


prep-testbed_integration-test:
# name: Prepare all integration test items
uses: ./.github/workflows/prepare_test_items.yaml
with:
shell_path: scripts/ci/get-integration-test-paths.sh
shell_arg: unix


run_unit-test:
# name: Run all unit test items
needs: prep-testbed_unit-test
uses: ./.github/workflows/run_test_items_via_pytest.yaml
with:
test_type: unit-test
all_test_items_paths: ${{needs.prep-testbed_unit-test.outputs.all_test_items}}


run_integration-test:
# name: Run all integration test items. This testing would test the code with other resource or system to ensure the features work finely.
needs: prep-testbed_integration-test
uses: ./.github/workflows/run_test_items_via_pytest.yaml
with:
test_type: integration-test
all_test_items_paths: ${{needs.prep-testbed_integration-test.outputs.all_test_items}}


unit-test_codecov:
# name: Organize and generate the testing report and upload it to Codecov
needs: run_unit-test
uses: ./.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml
with:
test_type: unit-test
generate_xml_report_finally: false


integration-test_codecov:
# name: Organize and generate the testing report and upload it to Codecov
needs: run_integration-test
uses: ./.github/workflows/organize_all_testing_coverage_reports_with_different_os_and_py_version.yaml
with:
test_type: integration-test
generate_xml_report_finally: false


organize_all-test_codecov_and_generate_report:
# name: Organize and generate the testing report and upload it to Codecov
needs: [unit-test_codecov, integration-test_codecov]
uses: ./.github/workflows/organize_all_testing_reports_with_different_test_type.yaml


codecov_finish:
# name: Organize and generate the testing report and upload it to Codecov
if: github.ref_name == 'release' || github.ref_name == 'master'
needs: organize_all-test_codecov_and_generate_report
uses: ./.github/workflows/upload_test_report_to_codecov.yaml
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
with:
download_path: ./
codecov_flags: unit-test, integration-test
codecov_name: smoothcrawler-appintegration_github-actions_test # optional


codacy_finish:
# name: Upload test report to Codacy to analyse and record code quality
needs: [codecov_finish]
uses: ./.github/workflows/upload_code_report_to_codacy.yaml
secrets:
codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }}
with:
download_path: ./


# pre-building_check:
## name: Check about it could work finely by installing the Python package with setup.py file
# needs: [codecov_finish, codacy_finish]
# uses: Chisanan232/GitHub-Action-Template-Python/.github/workflows/upload_code_report_to_codacy.yaml
# with:
# python_package_name: smoothcrawler
# test_import_package_code_1: import smoothcrawler as mr
# test_import_package_code_2: from smoothcrawler.crawler import SimpleCrawler
# test_import_package_code_3: from smoothcrawler.components.data import BaseHTTPResponseParser, BaseDataHandler
# test_python_script: ./scripts/test_crawler.py

11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# # This test directory for testing to simulate a Python library project structure.

.DS_Store
__pycache__
.coverage
.coverage.*
.pypirc
.pytest_cache/
.python-version
code_source/
coverage.xml
4 changes: 4 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# # This test directory for testing to simulate a Python library project structure.

codecov:
token: $CODECOV_TOKEN
14 changes: 14 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# # This test directory for testing to simulate a Python library project structure.

# pytest.ini
[pytest]
minversion = 0.1.0

addopts =
--cov=./test_gh_workflow
--cov-config=./.coveragerc
-r a
-v
--reruns 3

testpaths =
11 changes: 11 additions & 0 deletions requirements/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
###### SmoothCrawler-AppIntegration Development (or Testing) Dependencies Requirements ######
## For running pytest ##
pytest >= 7.0.0
pytest-cov >= 3.0.0
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.
codecov >= 2.1.12
coveralls >= 3.3.1
2 changes: 2 additions & 0 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
###### SmoothCrawler-AppIntegration Dependencies Requirements ######
## Code - Basic ##
34 changes: 34 additions & 0 deletions scripts/ci/get-integration-test-paths.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -ex
runtime_os=$1

declare -a base_tests

getalltests() {
declare -a testpatharray=( $(ls -F "$1" | grep -v '/$' | grep -v '__init__.py' | grep -v 'test_config.py' | grep -v -E '^_[a-z_]{1,64}.py' | grep -v '__pycache__'))

declare -a alltestpaths
for (( i = 0; i < ${#testpatharray[@]}; i++ )) ; do
alltestpaths[$i]=$1${testpatharray[$i]}
done

base_tests=("${alltestpaths[@]}")
}

base_path=test/integration_test/

getalltests $base_path

dest=( "${base_tests[@]}" )


if echo "$runtime_os" | grep -q "windows";
then
printf '%s\n' "${dest[@]}" | jq -R .
elif echo "$runtime_os" | grep -q "unix";
then
printf '%s\n' "${dest[@]}" | jq -R . | jq -cs .
else
printf 'error' | jq -R .
fi
34 changes: 34 additions & 0 deletions scripts/ci/get-unit-test-paths.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -ex
runtime_os=$1

declare -a init_tests

getalltests() {
declare -a testpatharray=( $(ls -F "$1" | grep -v '/$' | grep -v '__init__.py' | grep -v 'test_config.py' | grep -v -E '^_[a-z_]{1,64}.py' | grep -v '__pycache__'))

declare -a alltestpaths
for (( i = 0; i < ${#testpatharray[@]}; i++ )) ; do
alltestpaths[$i]=$1${testpatharray[$i]}
done

init_tests=("${alltestpaths[@]}")
}

init_path=test/unit_test/

getalltests $init_path

dest=( "${init_tests[@]}" )


if echo "$runtime_os" | grep -q "windows";
then
printf "${dest[@]}" | jq -R .
elif echo "$runtime_os" | grep -q "unix";
then
printf '%s\n' "${dest[@]}" | jq -R . | jq -cs .
else
printf 'error' | jq -R .
fi
Loading