Develop to Main #29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Unit Tests | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches-ignore: | |
| - '**' | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| UnitTest: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Updating and installing GDAL | |
| run: | | |
| sudo apt update | |
| sudo apt install gdal-bin libgdal-dev python3-gdal | |
| - 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 GDAL==3.4.1 | |
| 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 == "develop" ]]; 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/osm_osw_reformatter -m unittest discover -v tests/unit_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: 'osm-osw-reformatter-package' | |
| clean_destination_folder: false | |
| delete_if_exists: false |