Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
79 changes: 57 additions & 22 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,66 @@ on:
branches-ignore:
- '**'
pull_request:
branches: [dev]
branches: [ main, dev ]

jobs:
UnitTest:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run tests with coverage
run: |
coverage run --source=src/osw_incline -m unittest discover -s tests/
coverage xml

- name: Check coverage
run: |
coverage report --fail-under=85
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Determine output folder
id: set_output_folder
run: |
if [[ $GITHUB_EVENT_NAME == "pull_request" ]]; then
branch_name=$GITHUB_BASE_REF
else
branch_name=$GITHUB_REF_NAME
fi
if [[ $branch_name == "main" ]]; then
echo "output_folder=prod" >> $GITHUB_ENV
elif [[ $branch_name == "stage" ]]; then
echo "output_folder=stage" >> $GITHUB_ENV
elif [[ $branch_name == "dev" ]]; then
echo "output_folder=dev" >> $GITHUB_ENV
else
echo "Unknown branch: $branch_name"
exit 1
fi

- name: Run tests with coverage
run: |
timestamp=$(date '+%Y-%m-%d_%H-%M-%S')
mkdir -p test_results
log_file="test_results/${timestamp}_report.log"
echo -e "\nTest Cases Report Report\n" >> $log_file
# Run the tests and append output to the log file
python -m coverage run --source=src/osw_incline -m unittest discover -v tests >> $log_file 2>&1
echo -e "\nCoverage Report\n" >> $log_file
coverage report >> $log_file

- name: Check coverage
run: |
coverage report --fail-under=85

- name: Upload report to Azure
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
source_folder: 'test_results'
destination_folder: '${{ env.output_folder }}'
connection_string: ${{ secrets.AZURE_STORAGE_CONNECTION_STRING }}
container_name: 'osw-incline-package'
clean_destination_folder: false
delete_if_exists: false
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 0.0.4
- Fixed [Task-1467](https://dev.azure.com/TDEI-UW/TDEI/_workitems/edit/1467/).
- Updated pipeline to deploy the test results to Azure Blob

### 0.0.3

- Fixed [Task-1369](https://dev.azure.com/TDEI-UW/TDEI/_workitems/edit/1369/).
Expand Down
4 changes: 2 additions & 2 deletions src/osw_incline/dem_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def process(self, nodes_path, edges_path, skip_existing_tags=False, batch_proces
if 'geometry' in d:
if skip_existing_tags:
if 'incline' in d and d['incline'] is not None:
if -1 <= d['incline'] <= 1:
if d['incline'] < -1 or d['incline'] > 1:
del d['incline']
# If incline already exists, skip
continue
Expand Down Expand Up @@ -91,7 +91,7 @@ def _process_in_batches(self, edges, dem, batch_size=10000, skip_existing_tags=F
if 'geometry' in d:
if skip_existing_tags:
if 'incline' in d and d['incline'] is not None:
if -1 <= d['incline'] <= 1:
if d['incline'] < -1 or d['incline'] > 1:
del d['incline']
# If incline already exists, skip
continue
Expand Down
2 changes: 1 addition & 1 deletion src/osw_incline/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.3'
__version__ = '0.0.4'
Loading