test(FIR-47589): Fix async tests (#115) #81
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_call: | |
| inputs: | |
| branch: | |
| required: false | |
| type: string | |
| description: 'Branch to run on' | |
| secrets: | |
| GIST_PAT: | |
| required: true | |
| push: | |
| branches: [ main, 0.x ] | |
| jobs: | |
| unit-tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v2 | |
| with: | |
| ref: ${{ inputs.branch }} | |
| - name: Set up Python 3.9 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: 3.9 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Run unit tests | |
| run: | | |
| pytest --cov=src/ tests/unit --cov-report=xml | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pytest-coverage-report | |
| path: coverage.xml | |
| - name: Extract coverage percent | |
| id: coverage | |
| if: github.event_name == 'push' | |
| continue-on-error: true | |
| run: | | |
| fraction=$(sed -n 2p coverage.xml | sed 's/.*line-rate=\"\([0-9.]*\)\".*$/\1/') | |
| percentage=$(echo "scale=1; $fraction * 100" | bc -l) | |
| percentage_whole=$(echo "${percentage%.*}") | |
| colour=$(if [ $percentage_whole -ge 80 ]; then echo "green"; else echo "orange"; fi) | |
| echo "colour=$colour" >> $GITHUB_OUTPUT | |
| echo "covered=$percentage_whole" >> $GITHUB_OUTPUT | |
| - name: Create Coverage Badge | |
| uses: schneegans/[email protected] | |
| if: github.event_name == 'push' | |
| continue-on-error: true | |
| with: | |
| auth: ${{ secrets.GIST_PAT }} | |
| gistID: 64f31d124b7249319234d247ade4a7db | |
| filename: firebolt-sqlalchemy-coverage.json | |
| label: Coverage | |
| message: ${{steps.coverage.outputs.covered}}% | |
| color: ${{steps.coverage.outputs.colour}} |