Skip to content

Commit

Permalink
improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
mahesh-hpe committed Jan 4, 2024
1 parent 0fb4c96 commit 491d908
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
22 changes: 13 additions & 9 deletions .github/parse_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,25 @@
def main(args):
n = len(args)
if n != 2:
print("Pass the log directory")
print("Pass the log directory or txt file path")
return 1
log_path = args[1]
file_content = ''
for x in os.listdir(log_path):
if x.endswith(".txt"):
with open(os.path.join(log_path, x)) as f:
file_content += (f.read())
test_count = file_content.count('RUN')
if log_path.endswith(".txt"):
with open(log_path) as f:
file_content += (f.read())
else:
for x in os.listdir(log_path):
if x.endswith(".txt"):
with open(os.path.join(log_path, x)) as f:
file_content += (f.read())
test_count = file_content.count('RUN') - file_content.count('SKIP:')
pass_count = file_content.count('PASS:')
fail_count = file_content.count('FAIL:')
print(
f"\nTestcases Ran: {test_count}; "
f"Testcases Passed: {pass_count}; "
f"Testcases Failed: {fail_count}; ")
f"\nTestcases Ran: {test_count}; \n"
f"Testcases Passed: {pass_count}; \n"
f"Testcases Failed: {fail_count}; \n")
return 0

if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/cicd-dev-acc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
test-vmaas-instance:
uses: ./.github/workflows/reusable-dev-acc.yml
needs: [test-provider, test-datasouces]
if: "always() && ${{ needs.test-provider.result == 'success' }}"
if: "failure() || ${{ needs.test-provider.result == 'success' }}"
with:
test_case: TestVmaasInstance TestAccResourceInstance
test_description: Instance test
Expand All @@ -33,7 +33,7 @@ jobs:
test-vmaas-lb:
uses: ./.github/workflows/reusable-dev-acc.yml
needs: [test-provider, test-vmaas-instance]
if: "always() && ${{ needs.test-provider.result == 'success' }}"
if: "failure() || ${{ needs.test-provider.result == 'success' }}"
with:
test_case: TestVmaasLB TestAccResourceLB TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate
test_description: Loadbalancer test
Expand All @@ -42,7 +42,7 @@ jobs:
test-vmaas-network:
uses: ./.github/workflows/reusable-dev-acc.yml
needs: [test-provider, test-vmaas-lb]
if: "always() && ${{ needs.test-provider.result == 'success' }}"
if: "failure() || ${{ needs.test-provider.result == 'success' }}"
with:
test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier TestVmaasRouteBGPNeighborPlan
test_description: Network test
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/reusable-dev-acc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ jobs:
steps:
- name: Checkout workspace
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Set up Go
uses: actions/setup-go@v5
with:
Expand Down Expand Up @@ -92,6 +96,10 @@ jobs:
- name: Print testcases output
if: always()
run: cat "$LOG_FILE"

- name: Print testcases count
if: always()
run: python .github/parse_logs.py "$LOG_FILE"

- name: Push the report to github artifacts
if: always()
Expand Down

0 comments on commit 491d908

Please sign in to comment.