Skip to content

Commit 5779f0f

Browse files
committed
Updated unit test cases
1 parent d2921b5 commit 5779f0f

File tree

1 file changed

+53
-48
lines changed

1 file changed

+53
-48
lines changed

.github/workflows/unit_tests.yaml

Lines changed: 53 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,63 +5,68 @@ on:
55
branches-ignore:
66
- '**'
77
pull_request:
8-
branches: [main, dev, stage]
8+
branches: [ main, dev, stage ]
99

1010
jobs:
1111
UnitTest:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v2
15+
- name: Checkout code
16+
uses: actions/checkout@v2
1717

18-
- name: Set up Python
19-
uses: actions/setup-python@v2
20-
with:
21-
python-version: '3.10'
18+
- name: Set up Python
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: '3.10'
2222

23-
- name: Install dependencies
24-
run: |
25-
python -m pip install --upgrade pip
26-
pip install -r requirements.txt
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install -r requirements.txt
2727
28-
- name: Determine output folder
29-
id: set_output_folder
30-
run: |
31-
if [[ $GITHUB_EVENT_NAME == "pull_request" ]]; then
32-
branch_name=$GITHUB_BASE_REF
33-
else
34-
branch_name=$GITHUB_REF_NAME
35-
fi
28+
- name: Determine output folder
29+
id: set_output_folder
30+
run: |
31+
if [[ $GITHUB_EVENT_NAME == "pull_request" ]]; then
32+
branch_name=$GITHUB_BASE_REF
33+
else
34+
branch_name=$GITHUB_REF_NAME
35+
fi
36+
37+
if [[ $branch_name == "main" ]]; then
38+
echo "output_folder=prod" >> $GITHUB_ENV
39+
elif [[ $branch_name == "stage" ]]; then
40+
echo "output_folder=stage" >> $GITHUB_ENV
41+
elif [[ $branch_name == "dev" ]]; then
42+
echo "output_folder=dev" >> $GITHUB_ENV
43+
else
44+
echo "Unknown branch: $branch_name"
45+
exit 1
46+
fi
3647
37-
if [[ $branch_name == "main" ]]; then
38-
echo "output_folder=prod" >> $GITHUB_ENV
39-
elif [[ $branch_name == "stage" ]]; then
40-
echo "output_folder=stage" >> $GITHUB_ENV
41-
elif [[ $branch_name == "dev" ]]; then
42-
echo "output_folder=dev" >> $GITHUB_ENV
43-
else
44-
echo "Unknown branch: $branch_name"
45-
exit 1
46-
fi
48+
- name: Run tests with coverage
49+
run: |
50+
timestamp=$(date '+%Y-%m-%d_%H-%M-%S')
51+
mkdir -p test_results
52+
log_file="test_results/${timestamp}_report.log"
53+
echo -e "\nTest Cases Report Report\n" >> $log_file
54+
# Run the tests and append output to the log file
55+
PYTHONPATH=$(pwd) python -m coverage run --source=src -m unittest discover -v tests/ >> $log_file 2>&1
56+
echo -e "\nCoverage Report\n" >> $log_file
57+
coverage report >> $log_file
58+
coverage xml
4759
48-
- name: Run tests with coverage
49-
run: |
50-
timestamp=$(date '+%Y-%m-%d_%H-%M-%S')
51-
mkdir -p test_results
52-
log_file="test_results/${timestamp}_report.log"
53-
echo -e "\nTest Cases Report Report\n" >> $log_file
54-
# Run the tests and append output to the log file
55-
PYTHONPATH=$(pwd) python -m coverage run --source=src -m unittest discover -v tests/ >> $log_file 2>&1
56-
echo -e "\nCoverage Report\n" >> $log_file
57-
coverage report >> $log_file
60+
- name: Check coverage
61+
run: |
62+
coverage report --fail-under=85
5863
59-
- name: Upload report to Azure
60-
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
61-
with:
62-
source_folder: 'test_results'
63-
destination_folder: '${{ env.output_folder }}'
64-
connection_string: ${{ secrets.AZURE_STORAGE_CONNECTION_STRING }}
65-
container_name: 'osw-quality-metric-service'
66-
clean_destination_folder: false
67-
delete_if_exists: false
64+
- name: Upload report to Azure
65+
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
66+
with:
67+
source_folder: 'test_results'
68+
destination_folder: '${{ env.output_folder }}'
69+
connection_string: ${{ secrets.AZURE_STORAGE_CONNECTION_STRING }}
70+
container_name: 'osw-quality-metric-service'
71+
clean_destination_folder: false
72+
delete_if_exists: false

0 commit comments

Comments
 (0)