diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 4240d93..89a763b 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -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 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index bd76db6..efc8bcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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/). diff --git a/src/osw_incline/dem_processor.py b/src/osw_incline/dem_processor.py index 9712615..ca40a09 100644 --- a/src/osw_incline/dem_processor.py +++ b/src/osw_incline/dem_processor.py @@ -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 @@ -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 diff --git a/src/osw_incline/version.py b/src/osw_incline/version.py index 8dbfdad..cba8e59 100644 --- a/src/osw_incline/version.py +++ b/src/osw_incline/version.py @@ -1 +1 @@ -__version__ = '0.0.3' \ No newline at end of file +__version__ = '0.0.4' \ No newline at end of file