diff --git a/.github/workflows/code-check.yml b/.github/workflows/code-check.yml index e474926b1c2..f39034bc8f1 100644 --- a/.github/workflows/code-check.yml +++ b/.github/workflows/code-check.yml @@ -1,4 +1,4 @@ -name: Python code checks +name: Code quality checks on: workflow_call: diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 987ba4ff5c4..209622cb8ea 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -1,4 +1,4 @@ -name: Run integration tests +name: Integration tests on: workflow_dispatch: workflow_call: diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 7153208b6b1..d19da4c30ab 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -16,6 +16,9 @@ jobs: uses: ./.github/workflows/code-check.yml unit-tests: uses: ./.github/workflows/unit-tests.yml + secrets: + GIST_PAT: ${{ secrets.GIST_PAT }} + security-scan: needs: [unit-tests] uses: ./.github/workflows/security-scan.yml diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index d6652a2578d..fd4f1bb2587 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -5,6 +5,9 @@ name: Unit tests on: workflow_call: + secrets: + GIST_PAT: + required: true push: branches: [ main ] @@ -36,3 +39,27 @@ jobs: 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 "::set-output name=colour::$colour" + echo "::set-output name=covered::$percentage_whole" + + - name: Create Coverage Badge + uses: schneegans/dynamic-badges-action@v1.2.0 + if: github.event_name == 'push' + continue-on-error: true + with: + auth: ${{ secrets.GIST_PAT }} + gistID: 65d5a42849fd78f4c6e62fad18490d20 + filename: firebolt-sdk-coverage.json + label: Coverage + message: ${{steps.coverage.outputs.covered}}% + color: ${{steps.coverage.outputs.colour}} diff --git a/README.md b/README.md index 3f5b50f47a0..00e82b54bb4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,12 @@ # firebolt-sdk +[![Nightly code check](https://github.com/firebolt-db/firebolt-python-sdk/actions/workflows/nightly.yml/badge.svg)](https://github.com/firebolt-db/firebolt-python-sdk/actions/workflows/nightly.yml) +[![Unit tests](https://github.com/firebolt-db/firebolt-python-sdk/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/firebolt-db/firebolt-python-sdk/actions/workflows/unit-tests.yml) +[![Code quality checks](https://github.com/firebolt-db/firebolt-python-sdk/actions/workflows/code-check.yml/badge.svg)](https://github.com/firebolt-db/firebolt-python-sdk/actions/workflows/code-check.yml) +[![Firebolt Security Scan](https://github.com/firebolt-db/firebolt-python-sdk/actions/workflows/security-scan.yml/badge.svg)](https://github.com/firebolt-db/firebolt-python-sdk/actions/workflows/security-scan.yml) +[![Integration tests](https://github.com/firebolt-db/firebolt-python-sdk/actions/workflows/integration-tests.yml/badge.svg)](https://github.com/firebolt-db/firebolt-python-sdk/actions/workflows/integration-tests.yml) +![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/ptiurin/65d5a42849fd78f4c6e62fad18490d20/raw/firebolt-sdk-coverage.json) + + ### Installation * Requires Python `>=3.7`