Skip to content

Commit 6a974ea

Browse files
committed
Updated pipeline
1 parent 12050b2 commit 6a974ea

File tree

1 file changed

+67
-26
lines changed

1 file changed

+67
-26
lines changed

.github/workflows/unit_tests.yml

Lines changed: 67 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,68 @@
11
---
2-
name: Tests
3-
on:
4-
pull_request:
5-
branches: [develop]
6-
7-
jobs:
8-
Tests:
9-
name: Unit tests
10-
# Set the agent to run on
11-
runs-on: ubuntu-latest
12-
steps:
13-
- name: Checkout code
14-
uses: actions/checkout@v3
15-
16-
- name: Set up Python
17-
uses: actions/setup-python@v4
18-
with:
19-
python-version: "3.10"
20-
21-
- name: Install dependencies
22-
run: |
23-
pip install -r requirements.txt
24-
25-
- name: Run unit tests
26-
run: |
27-
python -m unittest discover -v tests/unit_tests
2+
name: Tests
3+
on:
4+
pull_request:
5+
branches: [ develop, main ]
6+
7+
jobs:
8+
Tests:
9+
name: Unit tests
10+
# Set the agent to run on
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: "3.10"
20+
21+
- name: Install dependencies
22+
run: |
23+
pip install -r requirements.txt
24+
25+
- name: Determine output folder
26+
id: set_output_folder
27+
run: |
28+
if [[ $GITHUB_EVENT_NAME == "pull_request" ]]; then
29+
branch_name=$GITHUB_BASE_REF
30+
else
31+
branch_name=$GITHUB_REF_NAME
32+
fi
33+
if [[ $branch_name == "main" ]]; then
34+
echo "output_folder=prod" >> $GITHUB_ENV
35+
elif [[ $branch_name == "stage" ]]; then
36+
echo "output_folder=stage" >> $GITHUB_ENV
37+
elif [[ $branch_name == "develop" ]]; then
38+
echo "output_folder=dev" >> $GITHUB_ENV
39+
else
40+
echo "Unknown branch: $branch_name"
41+
exit 1
42+
fi
43+
44+
- name: Run tests with coverage
45+
run: |
46+
timestamp=$(date '+%Y-%m-%d_%H-%M-%S')
47+
mkdir -p test_results
48+
log_file="test_results/${timestamp}_report.log"
49+
echo -e "\nTest Cases Report Report\n" >> $log_file
50+
# Run the tests and append output to the log file
51+
python -m coverage run --source=src/gtfs_canonical_validator -m unittest discover -s tests/unit_tests >> $log_file 2>&1
52+
echo -e "\nCoverage Report\n" >> $log_file
53+
coverage report >> $log_file
54+
55+
- name: Check coverage
56+
run: |
57+
coverage report --fail-under=85
58+
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: 'python-osw-validation-package'
66+
clean_destination_folder: false
67+
delete_if_exists: false
68+

0 commit comments

Comments
 (0)